Bug 1508670 - [webdriver] Fix Rust code to be compatible with Rust 2018 edition. r=ato
authorHenrik Skupin <mail@hskupin.info>
Fri, 30 Nov 2018 06:05:15 +0000
changeset 508145 17e5d1f4b36ad71fa834e8a655e9b13762c90487
parent 508144 03b632f92cded8208495b15dfbd3d8d046d9eb05
child 508146 8c4e43e477e5bd528f07f67d2d404bda38529aec
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1508670
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1508670 - [webdriver] Fix Rust code to be compatible with Rust 2018 edition. r=ato Depends on D13398 Differential Revision: https://phabricator.services.mozilla.com/D13399
testing/webdriver/src/actions.rs
testing/webdriver/src/capabilities.rs
testing/webdriver/src/command.rs
testing/webdriver/src/common.rs
testing/webdriver/src/error.rs
testing/webdriver/src/httpapi.rs
testing/webdriver/src/response.rs
testing/webdriver/src/server.rs
--- a/testing/webdriver/src/actions.rs
+++ b/testing/webdriver/src/actions.rs
@@ -1,9 +1,9 @@
-use common::{WebElement, ELEMENT_KEY};
+use crate::common::{WebElement, ELEMENT_KEY};
 use serde::de::{self, Deserialize, Deserializer};
 use serde::ser::{Serialize, Serializer};
 use serde_json::Value;
 use std::default::Default;
 use unicode_segmentation::UnicodeSegmentation;
 
 #[derive(Debug, PartialEq, Serialize, Deserialize)]
 pub struct ActionSequence {
@@ -234,19 +234,19 @@ where
     D: Deserializer<'de>,
 {
     Option::deserialize(deserializer)?
         .ok_or_else(|| de::Error::custom("invalid type: null, expected i64"))
 }
 
 #[cfg(test)]
 mod test {
+    use crate::test::{check_deserialize, check_serialize_deserialize};
     use super::*;
     use serde_json;
-    use test::{check_deserialize, check_serialize_deserialize};
 
     #[test]
     fn test_json_action_sequence_null() {
         let json = r#"{
             "id":"none",
             "type":"none",
             "actions":[{
                 "type":"pause","duration":1
--- a/testing/webdriver/src/capabilities.rs
+++ b/testing/webdriver/src/capabilities.rs
@@ -1,10 +1,10 @@
-use common::MAX_SAFE_INTEGER;
-use error::{ErrorStatus, WebDriverError, WebDriverResult};
+use crate::common::MAX_SAFE_INTEGER;
+use crate::error::{ErrorStatus, WebDriverError, WebDriverResult};
 use serde_json::{Map, Value};
 use url::Url;
 
 pub type Capabilities = Map<String, Value>;
 
 /// Trait for objects that can be used to inspect browser capabilities
 ///
 /// The main methods in this trait are called with a Capabilites object
@@ -12,49 +12,49 @@ pub type Capabilities = Map<String, Valu
 /// those Capabilities they return a property of the browser instance that
 /// would be initiated. In many cases this will be independent of the input,
 /// but in the case of e.g. browser version, it might depend on a path to the
 /// binary provided as a capability.
 pub trait BrowserCapabilities {
     /// Set up the Capabilites object
     ///
     /// Typically used to create any internal caches
-    fn init(&mut self, &Capabilities);
+    fn init(&mut self, _: &Capabilities);
 
     /// Name of the browser
-    fn browser_name(&mut self, &Capabilities) -> WebDriverResult<Option<String>>;
+    fn browser_name(&mut self, _: &Capabilities) -> WebDriverResult<Option<String>>;
 
     /// Version number of the browser
-    fn browser_version(&mut self, &Capabilities) -> WebDriverResult<Option<String>>;
+    fn browser_version(&mut self, _: &Capabilities) -> WebDriverResult<Option<String>>;
 
     /// Compare actual browser version to that provided in a version specifier
     ///
     /// Parameters are the actual browser version and the comparison string,
     /// respectively. The format of the comparison string is
     /// implementation-defined.
     fn compare_browser_version(&mut self, version: &str, comparison: &str)
         -> WebDriverResult<bool>;
 
     /// Name of the platform/OS
-    fn platform_name(&mut self, &Capabilities) -> WebDriverResult<Option<String>>;
+    fn platform_name(&mut self, _: &Capabilities) -> WebDriverResult<Option<String>>;
 
     /// Whether insecure certificates are supported
-    fn accept_insecure_certs(&mut self, &Capabilities) -> WebDriverResult<bool>;
+    fn accept_insecure_certs(&mut self, _: &Capabilities) -> WebDriverResult<bool>;
 
     /// Indicates whether driver supports all of the window resizing and
     /// repositioning commands.
-    fn set_window_rect(&mut self, &Capabilities) -> WebDriverResult<bool>;
+    fn set_window_rect(&mut self, _: &Capabilities) -> WebDriverResult<bool>;
 
     /// Indicates that interactability checks will be applied to `<input type=file>`.
-    fn strict_file_interactability(&mut self, &Capabilities) -> WebDriverResult<bool>;
+    fn strict_file_interactability(&mut self, _: &Capabilities) -> WebDriverResult<bool>;
 
     fn accept_proxy(
         &mut self,
         proxy_settings: &Map<String, Value>,
-        &Capabilities,
+        _: &Capabilities,
     ) -> WebDriverResult<bool>;
 
     /// Type check custom properties
     ///
     /// Check that custom properties containing ":" have the correct data types.
     /// Properties that are unrecognised must be ignored i.e. return without
     /// error.
     fn validate_custom(&self, name: &str, value: &Value) -> WebDriverResult<()>;
@@ -556,18 +556,18 @@ impl CapabilitiesMatching for LegacyNewS
         browser_capabilities.init(&capabilities);
         Ok(Some(capabilities))
     }
 }
 
 #[cfg(test)]
 mod tests {
     use super::*;
+    use crate::test::check_deserialize;
     use serde_json::{self, Value};
-    use test::check_deserialize;
 
     fn validate_proxy(value: &str) -> WebDriverResult<()> {
         let data = serde_json::from_str::<Value>(value).unwrap();
         SpecNewSessionParameters::validate_proxy(&data)
     }
 
     #[test]
     fn test_json_spec_new_session_parameters_alwaysMatch_only() {
--- a/testing/webdriver/src/command.rs
+++ b/testing/webdriver/src/command.rs
@@ -1,14 +1,16 @@
-use actions::ActionSequence;
-use capabilities::{BrowserCapabilities, Capabilities, CapabilitiesMatching,
-                   LegacyNewSessionParameters, SpecNewSessionParameters};
-use common::{Date, FrameId, LocatorStrategy, WebElement, MAX_SAFE_INTEGER};
-use error::{ErrorStatus, WebDriverError, WebDriverResult};
-use httpapi::{Route, VoidWebDriverExtensionRoute, WebDriverExtensionRoute};
+use crate::actions::ActionSequence;
+use crate::capabilities::{
+    BrowserCapabilities, Capabilities, CapabilitiesMatching, LegacyNewSessionParameters,
+    SpecNewSessionParameters,
+};
+use crate::common::{Date, FrameId, LocatorStrategy, WebElement, MAX_SAFE_INTEGER};
+use crate::error::{ErrorStatus, WebDriverError, WebDriverResult};
+use crate::httpapi::{Route, VoidWebDriverExtensionRoute, WebDriverExtensionRoute};
 use regex::Captures;
 use serde::de::{self, Deserialize, Deserializer};
 use serde_json::{self, Value};
 
 #[derive(Debug, PartialEq)]
 pub enum WebDriverCommand<T: WebDriverExtensionCommand> {
     NewSession(NewSessionParameters),
     DeleteSession,
@@ -606,19 +608,19 @@ where
     };
 
     Ok(value)
 }
 
 #[cfg(test)]
 mod tests {
     use super::*;
-    use capabilities::SpecNewSessionParameters;
+    use crate::capabilities::SpecNewSessionParameters;
+    use crate::test::check_deserialize;
     use serde_json;
-    use test::check_deserialize;
 
     #[test]
     fn test_json_actions_parameters_missing_actions_field() {
         let json = r#"{}"#;
         assert!(serde_json::from_str::<ActionsParameters>(&json).is_err());
     }
 
     #[test]
--- a/testing/webdriver/src/common.rs
+++ b/testing/webdriver/src/common.rs
@@ -65,18 +65,18 @@ impl WebElement {
     pub fn new(id: String) -> WebElement {
         WebElement { id }
     }
 }
 
 #[cfg(test)]
 mod tests {
     use super::*;
+    use crate::test::{check_serialize, check_serialize_deserialize};
     use serde_json;
-    use test::{check_serialize, check_serialize_deserialize};
 
     #[test]
     fn test_json_date() {
         let json = r#"1234"#;
         let data = Date(1234);
 
         check_serialize_deserialize(&json, &data);
     }
--- a/testing/webdriver/src/error.rs
+++ b/testing/webdriver/src/error.rs
@@ -358,17 +358,17 @@ impl From<Box<Error>> for WebDriverError
     fn from(err: Box<Error>) -> WebDriverError {
         WebDriverError::new(ErrorStatus::UnknownError, err.description().to_string())
     }
 }
 
 #[cfg(test)]
 mod tests {
     use super::*;
-    use test::check_serialize;
+    use crate::test::check_serialize;
 
     #[test]
     fn test_json_webdriver_error() {
         let json = r#"{"value":{
             "error":"unknown error",
             "message":"foo bar",
             "stacktrace":"foo\nbar"
         }}"#;
--- a/testing/webdriver/src/httpapi.rs
+++ b/testing/webdriver/src/httpapi.rs
@@ -1,16 +1,17 @@
 use regex::{Captures, Regex};
 
 use hyper::Method;
 use serde_json::Value;
 
-use command::{VoidWebDriverExtensionCommand, WebDriverCommand, WebDriverExtensionCommand,
-              WebDriverMessage};
-use error::{ErrorStatus, WebDriverError, WebDriverResult};
+use crate::command::{
+    VoidWebDriverExtensionCommand, WebDriverCommand, WebDriverExtensionCommand, WebDriverMessage,
+};
+use crate::error::{ErrorStatus, WebDriverError, WebDriverResult};
 
 fn standard_routes<U: WebDriverExtensionRoute>() -> Vec<(Method, &'static str, Route<U>)> {
     return vec![
         (Method::POST, "/session", Route::NewSession),
         (Method::DELETE, "/session/{sessionId}", Route::DeleteSession),
         (Method::POST, "/session/{sessionId}/url", Route::Get),
         (Method::GET, "/session/{sessionId}/url", Route::GetCurrentUrl),
         (Method::POST, "/session/{sessionId}/back", Route::GoBack),
@@ -277,17 +278,17 @@ pub enum Route<U: WebDriverExtensionRout
     TakeElementScreenshot,
     Status,
     Extension(U),
 }
 
 pub trait WebDriverExtensionRoute: Clone + Send + PartialEq {
     type Command: WebDriverExtensionCommand + 'static;
 
-    fn command(&self, &Captures, &Value) -> WebDriverResult<WebDriverCommand<Self::Command>>;
+    fn command(&self, _: &Captures, _: &Value) -> WebDriverResult<WebDriverCommand<Self::Command>>;
 }
 
 #[derive(Clone, Debug, PartialEq)]
 pub struct VoidWebDriverExtensionRoute;
 
 impl WebDriverExtensionRoute for VoidWebDriverExtensionRoute {
     type Command = VoidWebDriverExtensionCommand;
 
--- a/testing/webdriver/src/response.rs
+++ b/testing/webdriver/src/response.rs
@@ -1,9 +1,9 @@
-use common::Cookie;
+use crate::common::Cookie;
 use serde::ser::{Serialize, Serializer};
 use serde_json::Value;
 
 #[derive(Debug, PartialEq, Serialize)]
 #[serde(untagged, remote = "Self")]
 pub enum WebDriverResponse {
     CloseWindow(CloseWindowResponse),
     Cookie(CookieResponse),
@@ -124,19 +124,19 @@ pub struct WindowRectResponse {
     /// any browser chrome and externally drawn window decorations in CSS
     /// reference pixels.
     pub height: i32,
 }
 
 #[cfg(test)]
 mod tests {
     use super::*;
-    use common::Date;
+    use crate::common::Date;
+    use crate::test::check_serialize;
     use serde_json;
-    use test::check_serialize;
 
     #[test]
     fn test_json_close_window_response() {
         let json = r#"{"value":["1234"]}"#;
         let data = WebDriverResponse::CloseWindow(CloseWindowResponse(vec!["1234".into()]));
 
         check_serialize(&json, &data);
     }
--- a/testing/webdriver/src/server.rs
+++ b/testing/webdriver/src/server.rs
@@ -1,28 +1,28 @@
 use serde_json;
 use std::marker::PhantomData;
 use std::net::{SocketAddr, TcpListener as StdTcpListener};
 use std::sync::mpsc::{channel, Receiver, Sender};
 use std::sync::{Arc, Mutex};
 use std::thread;
 
 use futures::{future, Future, Stream};
-use hyper::{self, Body, Method, Request, Response, StatusCode};
-use hyper::service::Service;
+use http;
 use hyper::server::conn::Http;
-use http;
-use tokio::runtime::current_thread::Runtime;
+use hyper::service::Service;
+use hyper::{self, Body, Method, Request, Response, StatusCode};
+use tokio::net::TcpListener;
 use tokio::reactor::Handle;
-use tokio::net::TcpListener;
+use tokio::runtime::current_thread::Runtime;
 
-use command::{WebDriverCommand, WebDriverMessage};
-use error::{ErrorStatus, WebDriverError, WebDriverResult};
-use httpapi::{VoidWebDriverExtensionRoute, WebDriverExtensionRoute, WebDriverHttpApi};
-use response::{CloseWindowResponse, WebDriverResponse};
+use crate::command::{WebDriverCommand, WebDriverMessage};
+use crate::error::{ErrorStatus, WebDriverError, WebDriverResult};
+use crate::httpapi::{VoidWebDriverExtensionRoute, WebDriverExtensionRoute, WebDriverHttpApi};
+use crate::response::{CloseWindowResponse, WebDriverResponse};
 
 // Silence warning about Quit being unused for now.
 #[allow(dead_code)]
 enum DispatchMessage<U: WebDriverExtensionRoute> {
     HandleWebDriver(
         WebDriverMessage<U>,
         Sender<WebDriverResult<WebDriverResponse>>,
     ),