Skip to content
Permalink
Browse files

Fix some warnings in future Rust nightlies

  • Loading branch information
SimonSapin committed Jan 2, 2020
1 parent 7281336 commit fdcc7653f2783ad6702d1dc4dabca24e1811b1cf
@@ -288,7 +288,7 @@ impl BluetoothManager {
self.adapter = BluetoothAdapter::init_mock().ok();
match test::test(self, data_set_name) {
Ok(_) => return Ok(()),
Err(error) => Err(BluetoothError::Type(error.description().to_owned())),
Err(error) => Err(BluetoothError::Type(error.to_string())),
}
}

@@ -8,7 +8,6 @@

use serde::Serialize;
use serde_json::{self, Value};
use std::error::Error;
use std::io::{Read, Write};
use std::net::TcpStream;

@@ -62,7 +61,7 @@ impl JsonPacketStream for TcpStream {
Ok(0) => return Ok(None), // EOF
Ok(1) => buf[0],
Ok(_) => unreachable!(),
Err(e) => return Err(e.description().to_owned()),
Err(e) => return Err(e.to_string()),
};
match byte {
b':' => {
@@ -79,7 +78,7 @@ impl JsonPacketStream for TcpStream {
debug!("{}", packet);
return match serde_json::from_str(&packet) {
Ok(json) => Ok(Some(json)),
Err(err) => Err(err.description().to_owned()),
Err(err) => Err(err.to_string()),
};
},
c => buffer.push(c),
@@ -44,7 +44,6 @@ use net_traits::{
use servo_arc::Arc;
use servo_url::{ImmutableOrigin, ServoUrl};
use std::collections::{HashMap, HashSet};
use std::error::Error;
use std::iter::FromIterator;
use std::mem;
use std::ops::Deref;
@@ -622,7 +621,7 @@ pub fn http_fetch(
HeaderValue::to_str(v)
.map(|l| {
ServoUrl::parse_with_base(response.actual_response().url(), &l)
.map_err(|err| err.description().into())
.map_err(|err| err.to_string())
})
.ok()
});
@@ -40,7 +40,6 @@ use servo_arc::Arc as ServoArc;
use servo_url::ServoUrl;
use std::borrow::{Cow, ToOwned};
use std::collections::HashMap;
use std::error::Error;
use std::fs::{self, File};
use std::io::prelude::*;
use std::ops::Deref;
@@ -361,19 +360,15 @@ where

let mut file = match File::open(&path) {
Err(why) => {
warn!("couldn't open {}: {}", display, Error::description(&why));
warn!("couldn't open {}: {}", display, why);
return;
},
Ok(file) => file,
};

let mut string_buffer: String = String::new();
match file.read_to_string(&mut string_buffer) {
Err(why) => panic!(
"couldn't read from {}: {}",
display,
Error::description(&why)
),
Err(why) => panic!("couldn't read from {}: {}", display, why),
Ok(_) => println!("successfully read from {}", display),
}

@@ -396,16 +391,12 @@ where
let display = path.display();

let mut file = match File::create(&path) {
Err(why) => panic!("couldn't create {}: {}", display, Error::description(&why)),
Err(why) => panic!("couldn't create {}: {}", display, why),
Ok(file) => file,
};

match file.write_all(json_encoded.as_bytes()) {
Err(why) => panic!(
"couldn't write to {}: {}",
display,
Error::description(&why)
),
Err(why) => panic!("couldn't write to {}: {}", display, why),
Ok(_) => println!("successfully wrote to {}", display),
}
}
@@ -31,7 +31,6 @@ use ipc_channel::Error as IpcError;
use mime::Mime;
use msg::constellation_msg::HistoryStateId;
use servo_url::ServoUrl;
use std::error::Error;
use time::precise_time_ns;
use webrender_api::ImageKey;

@@ -699,11 +698,11 @@ pub enum NetworkError {

impl NetworkError {
pub fn from_hyper_error(error: &HyperError) -> Self {
NetworkError::Internal(error.description().to_owned())
NetworkError::Internal(error.to_string())
}

pub fn from_http_error(error: &HttpError) -> Self {
NetworkError::Internal(error.description().to_owned())
NetworkError::Internal(error.to_string())
}
}

@@ -7,7 +7,6 @@ use heartbeats_simple::HeartbeatPow as Heartbeat;
use profile_traits::time::ProfilerCategory;
use std::collections::HashMap;
use std::env::var_os;
use std::error::Error;
use std::fs::File;
use std::path::Path;

@@ -85,7 +84,7 @@ fn open_heartbeat_log<P: AsRef<Path>>(name: P) -> Option<File> {
match File::create(name) {
Ok(f) => Some(f),
Err(e) => {
warn!("Failed to open heartbeat log: {}", Error::description(&e));
warn!("Failed to open heartbeat log: {}", e);
None
},
}
@@ -138,7 +137,7 @@ fn maybe_create_heartbeat(
fn log_heartbeat_records(hb: &mut Heartbeat) {
match hb.log_to_buffer_index() {
Ok(_) => (),
Err(e) => warn!("Failed to write heartbeat log: {}", Error::description(&e)),
Err(e) => warn!("Failed to write heartbeat log: {}", e),
}
}

@@ -19,7 +19,6 @@ use servo_config::opts::OutputOptions;
use std::borrow::ToOwned;
use std::cmp::Ordering;
use std::collections::{BTreeMap, HashMap};
use std::error::Error;
use std::fs::File;
use std::io::{self, Write};
use std::path::Path;
@@ -397,11 +396,7 @@ impl Profiler {
Some(OutputOptions::FileName(ref filename)) => {
let path = Path::new(&filename);
let mut file = match File::create(&path) {
Err(e) => panic!(
"Couldn't create {}: {}",
path.display(),
Error::description(&e)
),
Err(e) => panic!("Couldn't create {}: {}", path.display(), e),
Ok(file) => file,
};
write!(
@@ -47,10 +47,12 @@ pub enum TexImageValidationError {
InvalidOffsets,
}

impl std::error::Error for TexImageValidationError {
fn description(&self) -> &str {
impl std::error::Error for TexImageValidationError {}

impl fmt::Display for TexImageValidationError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use self::TexImageValidationError::*;
match *self {
let description = match *self {
InvalidTextureTarget(_) => "Invalid texture target",
TextureTargetNotBound(_) => "Texture was not bound",
InvalidCubicTextureDimensions => {
@@ -68,17 +70,8 @@ impl std::error::Error for TexImageValidationError {
NonPotTexture => "Expected a power of two texture",
InvalidCompressionFormat => "Unrecognized texture compression format",
InvalidOffsets => "Invalid X/Y texture offset parameters",
}
}
}

impl fmt::Display for TexImageValidationError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"TexImageValidationError({})",
std::error::Error::description(self)
)
};
write!(f, "TexImageValidationError({})", description)
}
}

0 comments on commit fdcc765

Please sign in to comment.
You can’t perform that action at this time.