diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2020-01-02 16:41:47 +0100 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2020-01-02 19:22:03 +0100 |
commit | fdcc7653f2783ad6702d1dc4dabca24e1811b1cf (patch) | |
tree | 8be99a41a05a80884d79fbc20af85c35560e039e | |
parent | 728133611656f37480b96103dcc1d025f7d12ba3 (diff) | |
download | servo-fdcc7653f2783ad6702d1dc4dabca24e1811b1cf.tar.gz servo-fdcc7653f2783ad6702d1dc4dabca24e1811b1cf.zip |
Fix some warnings in future Rust nightlies
-rw-r--r-- | components/bluetooth/lib.rs | 2 | ||||
-rw-r--r-- | components/devtools/protocol.rs | 5 | ||||
-rw-r--r-- | components/net/http_loader.rs | 3 | ||||
-rw-r--r-- | components/net/resource_thread.rs | 17 | ||||
-rw-r--r-- | components/net_traits/lib.rs | 5 | ||||
-rw-r--r-- | components/profile/heartbeats.rs | 5 | ||||
-rw-r--r-- | components/profile/time.rs | 7 | ||||
-rw-r--r-- | components/script/dom/webgl_validations/tex_image_2d.rs | 21 |
8 files changed, 20 insertions, 45 deletions
diff --git a/components/bluetooth/lib.rs b/components/bluetooth/lib.rs index 19d6db743e4..5c54860d9e3 100644 --- a/components/bluetooth/lib.rs +++ b/components/bluetooth/lib.rs @@ -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())), } } diff --git a/components/devtools/protocol.rs b/components/devtools/protocol.rs index bfc547f6b75..29fbaa2beeb 100644 --- a/components/devtools/protocol.rs +++ b/components/devtools/protocol.rs @@ -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), diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs index 18e4e696f80..7868556adfe 100644 --- a/components/net/http_loader.rs +++ b/components/net/http_loader.rs @@ -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() }); diff --git a/components/net/resource_thread.rs b/components/net/resource_thread.rs index c948055bc55..f85d623fe4f 100644 --- a/components/net/resource_thread.rs +++ b/components/net/resource_thread.rs @@ -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,7 +360,7 @@ 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, @@ -369,11 +368,7 @@ where 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), } } diff --git a/components/net_traits/lib.rs b/components/net_traits/lib.rs index a25a804ce01..f7b291e420f 100644 --- a/components/net_traits/lib.rs +++ b/components/net_traits/lib.rs @@ -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()) } } diff --git a/components/profile/heartbeats.rs b/components/profile/heartbeats.rs index ac29d12bbb3..5a09ea4f9e6 100644 --- a/components/profile/heartbeats.rs +++ b/components/profile/heartbeats.rs @@ -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), } } diff --git a/components/profile/time.rs b/components/profile/time.rs index 3dac5663799..cea75b54b44 100644 --- a/components/profile/time.rs +++ b/components/profile/time.rs @@ -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!( diff --git a/components/script/dom/webgl_validations/tex_image_2d.rs b/components/script/dom/webgl_validations/tex_image_2d.rs index fc5919132cf..54643e7a2da 100644 --- a/components/script/dom/webgl_validations/tex_image_2d.rs +++ b/components/script/dom/webgl_validations/tex_image_2d.rs @@ -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) } } |