瀏覽代碼

chore: update crates to 2018 edition

Dirkjan Ochtman 6 年之前
父節點
當前提交
2bf4bedda5

+ 1 - 0
data-url/Cargo.toml

@@ -5,6 +5,7 @@ authors = ["Simon Sapin <simon.sapin@exyr.org>"]
 description = "Processing of data: URL according to WHATWG’s Fetch Standard"
 repository = "https://github.com/servo/rust-url"
 license = "MIT OR Apache-2.0"
+edition = "2018"
 
 [dependencies]
 matches = "0.1"

+ 3 - 3
data-url/src/lib.rs

@@ -45,7 +45,7 @@ impl<'a> DataUrl<'a> {
     /// <https://fetch.spec.whatwg.org/#data-url-processor>
     /// but starting from a string rather than a parsed `Url`, to avoid extra string copies.
     pub fn process(input: &'a str) -> Result<Self, DataUrlError> {
-        use DataUrlError::*;
+        use crate::DataUrlError::*;
 
         let after_colon = pretend_parse_data_url(input).ok_or(NotADataUrl)?;
 
@@ -257,7 +257,7 @@ fn percent_encode(byte: u8, string: &mut String) {
 fn decode_without_base64<F, E>(
     encoded_body_plus_fragment: &str,
     mut write_bytes: F,
-) -> Result<Option<FragmentIdentifier>, E>
+) -> Result<Option<FragmentIdentifier<'_>>, E>
 where
     F: FnMut(&[u8]) -> Result<(), E>,
 {
@@ -310,7 +310,7 @@ where
 fn decode_with_base64<F, E>(
     encoded_body_plus_fragment: &str,
     write_bytes: F,
-) -> Result<Option<FragmentIdentifier>, forgiving_base64::DecodeError<E>>
+) -> Result<Option<FragmentIdentifier<'_>>, forgiving_base64::DecodeError<E>>
 where
     F: FnMut(&[u8]) -> Result<(), E>,
 {

+ 1 - 1
data-url/src/mime.rs

@@ -122,7 +122,7 @@ fn valid_value(s: &str) -> bool {
 
 /// <https://mimesniff.spec.whatwg.org/#serializing-a-mime-type>
 impl fmt::Display for Mime {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         f.write_str(&self.type_)?;
         f.write_str("/")?;
         f.write_str(&self.subtype)?;

+ 0 - 3
data-url/tests/wpt.rs

@@ -1,8 +1,5 @@
-extern crate data_url;
-extern crate rustc_test;
 #[macro_use]
 extern crate serde;
-extern crate serde_json;
 
 fn run_data_url(input: String, expected_mime: Option<String>, expected_body: Option<Vec<u8>>) {
     let url = data_url::DataUrl::process(&input);

+ 1 - 0
form_urlencoded/Cargo.toml

@@ -5,6 +5,7 @@ authors = ["The rust-url developers"]
 description = "Parser and serializer for the application/x-www-form-urlencoded syntax, as used by HTML forms."
 repository = "https://github.com/servo/rust-url"
 license = "MIT/Apache-2.0"
+edition = "2018"
 
 [lib]
 test = false

+ 9 - 10
form_urlencoded/src/lib.rs

@@ -13,18 +13,17 @@
 //! Converts between a string (such as an URL’s query string)
 //! and a sequence of (name, value) pairs.
 
-extern crate percent_encoding;
 #[macro_use]
 extern crate matches;
 
 use percent_encoding::{percent_decode, percent_encode_byte};
-use query_encoding::decode_utf8_lossy;
 use std::borrow::{Borrow, Cow};
 use std::str;
 
-mod query_encoding;
+use crate::query_encoding::decode_utf8_lossy;
+pub use crate::query_encoding::EncodingOverride;
 
-pub use query_encoding::EncodingOverride;
+mod query_encoding;
 
 /// Convert a byte string in the `application/x-www-form-urlencoded` syntax
 /// into a iterator of (name, value) pairs.
@@ -34,7 +33,7 @@ pub use query_encoding::EncodingOverride;
 /// The names and values are percent-decoded. For instance, `%23first=%25try%25` will be
 /// converted to `[("#first", "%try%")]`.
 #[inline]
-pub fn parse(input: &[u8]) -> Parse {
+pub fn parse(input: &[u8]) -> Parse<'_> {
     Parse { input }
 }
 /// The return type of `parse()`.
@@ -65,7 +64,7 @@ impl<'a> Iterator for Parse<'a> {
     }
 }
 
-fn decode(input: &[u8]) -> Cow<str> {
+fn decode(input: &[u8]) -> Cow<'_, str> {
     let replaced = replace_plus(input);
     decode_utf8_lossy(match percent_decode(&replaced).into() {
         Cow::Owned(vec) => Cow::Owned(vec),
@@ -74,7 +73,7 @@ fn decode(input: &[u8]) -> Cow<str> {
 }
 
 /// Replace b'+' with b' '
-fn replace_plus(input: &[u8]) -> Cow<[u8]> {
+fn replace_plus(input: &[u8]) -> Cow<'_, [u8]> {
     match input.iter().position(|&b| b == b'+') {
         None => Cow::Borrowed(input),
         Some(first_position) => {
@@ -116,7 +115,7 @@ impl<'a> Iterator for ParseIntoOwned<'a> {
 /// https://url.spec.whatwg.org/#concept-urlencoded-byte-serializer).
 ///
 /// Return an iterator of `&str` slices.
-pub fn byte_serialize(input: &[u8]) -> ByteSerialize {
+pub fn byte_serialize(input: &[u8]) -> ByteSerialize<'_> {
     ByteSerialize { bytes: input }
 }
 
@@ -327,7 +326,7 @@ fn string<T: Target>(target: &mut Option<T>) -> &mut String {
 fn append_pair(
     string: &mut String,
     start_position: usize,
-    encoding: EncodingOverride,
+    encoding: EncodingOverride<'_>,
     name: &str,
     value: &str,
 ) {
@@ -337,6 +336,6 @@ fn append_pair(
     append_encoded(value, string, encoding);
 }
 
-fn append_encoded(s: &str, string: &mut String, encoding: EncodingOverride) {
+fn append_encoded(s: &str, string: &mut String, encoding: EncodingOverride<'_>) {
     string.extend(byte_serialize(&query_encoding::encode(encoding, s)))
 }

+ 3 - 3
form_urlencoded/src/query_encoding.rs

@@ -8,16 +8,16 @@
 
 use std::borrow::Cow;
 
-pub type EncodingOverride<'a> = Option<&'a dyn Fn(&str) -> Cow<[u8]>>;
+pub type EncodingOverride<'a> = Option<&'a dyn Fn(&str) -> Cow<'_, [u8]>>;
 
-pub(crate) fn encode<'a>(encoding_override: EncodingOverride, input: &'a str) -> Cow<'a, [u8]> {
+pub(crate) fn encode<'a>(encoding_override: EncodingOverride<'_>, input: &'a str) -> Cow<'a, [u8]> {
     if let Some(o) = encoding_override {
         return o(input);
     }
     input.as_bytes().into()
 }
 
-pub(crate) fn decode_utf8_lossy(input: Cow<[u8]>) -> Cow<str> {
+pub(crate) fn decode_utf8_lossy(input: Cow<'_, [u8]>) -> Cow<'_, str> {
     // Note: This function is duplicated in `percent_encoding/lib.rs`.
     match input {
         Cow::Borrowed(bytes) => String::from_utf8_lossy(bytes),

+ 1 - 0
idna/Cargo.toml

@@ -6,6 +6,7 @@ description = "IDNA (Internationalizing Domain Names in Applications) and Punyco
 repository = "https://github.com/servo/rust-url/"
 license = "MIT/Apache-2.0"
 autotests = false
+edition = "2018"
 
 [lib]
 doctest = false

+ 1 - 3
idna/src/lib.rs

@@ -34,13 +34,11 @@
 
 #[macro_use]
 extern crate matches;
-extern crate unicode_bidi;
-extern crate unicode_normalization;
 
 pub mod punycode;
 mod uts46;
 
-pub use uts46::{Config, Errors};
+pub use crate::uts46::{Config, Errors};
 
 /// The [domain to ASCII](https://url.spec.whatwg.org/#concept-domain-to-ascii) algorithm.
 ///

+ 3 - 3
idna/src/uts46.rs

@@ -10,7 +10,7 @@
 //! (Unicode Technical Standard #46)](http://www.unicode.org/reports/tr46/)
 
 use self::Mapping::*;
-use punycode;
+use crate::punycode;
 use std::cmp::Ordering::{Equal, Greater, Less};
 use std::{error::Error as StdError, fmt};
 use unicode_bidi::{bidi_class, BidiClass};
@@ -489,7 +489,7 @@ impl Error {
     }
 }
 impl fmt::Display for Error {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         f.write_str(self.as_str())
     }
 }
@@ -514,7 +514,7 @@ pub struct Errors(Vec<Error>);
 impl StdError for Errors {}
 
 impl fmt::Display for Errors {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         for (i, err) in self.0.iter().enumerate() {
             if i > 0 {
                 f.write_str(", ")?;

+ 1 - 1
idna/tests/punycode.rs

@@ -6,11 +6,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use crate::test::TestFn;
 use idna::punycode::{decode, encode_str};
 use serde_json::map::Map;
 use serde_json::Value;
 use std::str::FromStr;
-use test::TestFn;
 
 fn one_test(decoded: &str, encoded: &str) {
     match decode(encoded) {

+ 1 - 3
idna/tests/tests.rs

@@ -1,6 +1,4 @@
-extern crate idna;
-extern crate rustc_test as test;
-extern crate serde_json;
+use rustc_test as test;
 
 mod punycode;
 mod uts46;

+ 0 - 3
idna/tests/unit.rs

@@ -1,6 +1,3 @@
-extern crate idna;
-extern crate unicode_normalization;
-
 use unicode_normalization::char::is_combining_mark;
 
 fn _to_ascii(domain: &str) -> Result<String, idna::Errors> {

+ 1 - 1
idna/tests/uts46.rs

@@ -6,8 +6,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use crate::test::TestFn;
 use std::char;
-use test::TestFn;
 
 pub fn collect_tests<F: FnMut(String, TestFn)>(add_test: &mut F) {
     // https://www.unicode.org/Public/idna/13.0.0/IdnaTestV2.txt

+ 1 - 0
percent_encoding/Cargo.toml

@@ -5,6 +5,7 @@ authors = ["The rust-url developers"]
 description = "Percent encoding and decoding"
 repository = "https://github.com/servo/rust-url/"
 license = "MIT/Apache-2.0"
+edition = "2018"
 
 [lib]
 test = false

+ 5 - 5
percent_encoding/lib.rs

@@ -285,7 +285,7 @@ impl<'a> Iterator for PercentEncode<'a> {
 }
 
 impl<'a> fmt::Display for PercentEncode<'a> {
-    fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
         for c in (*self).clone() {
             formatter.write_str(c)?
         }
@@ -317,7 +317,7 @@ impl<'a> From<PercentEncode<'a>> for Cow<'a, str> {
 ///
 /// See [`percent_decode`] regarding the return type.
 #[inline]
-pub fn percent_decode_str(input: &str) -> PercentDecode {
+pub fn percent_decode_str(input: &str) -> PercentDecode<'_> {
     percent_decode(input.as_bytes())
 }
 
@@ -345,7 +345,7 @@ assert_eq!(percent_decode(b"foo%20bar%3f").decode_utf8().unwrap(), "foo bar?");
 "##
 )]
 #[inline]
-pub fn percent_decode(input: &[u8]) -> PercentDecode {
+pub fn percent_decode(input: &[u8]) -> PercentDecode<'_> {
     PercentDecode {
         bytes: input.iter(),
     }
@@ -357,7 +357,7 @@ pub struct PercentDecode<'a> {
     bytes: slice::Iter<'a, u8>,
 }
 
-fn after_percent_sign(iter: &mut slice::Iter<u8>) -> Option<u8> {
+fn after_percent_sign(iter: &mut slice::Iter<'_, u8>) -> Option<u8> {
     let mut cloned_iter = iter.clone();
     let h = char::from(*cloned_iter.next()?).to_digit(16)?;
     let l = char::from(*cloned_iter.next()?).to_digit(16)?;
@@ -441,7 +441,7 @@ impl<'a> PercentDecode<'a> {
 }
 
 #[cfg(feature = "std")]
-fn decode_utf8_lossy(input: Cow<[u8]>) -> Cow<str> {
+fn decode_utf8_lossy(input: Cow<'_, [u8]>) -> Cow<'_, str> {
     // Note: This function is duplicated in `form_urlencoded/src/query_encoding.rs`.
     match input {
         Cow::Borrowed(bytes) => String::from_utf8_lossy(bytes),

+ 1 - 0
url/Cargo.toml

@@ -13,6 +13,7 @@ keywords = ["url", "parser"]
 categories = ["parser-implementations", "web-programming", "encoding"]
 license = "MIT/Apache-2.0"
 include = ["src/**/*", "LICENSE-*", "README.md"]
+edition = "2018"
 
 [badges]
 travis-ci = { repository = "servo/rust-url" }

+ 0 - 2
url/benches/parse_url.rs

@@ -1,8 +1,6 @@
 #[macro_use]
 extern crate bencher;
 
-extern crate url;
-
 use bencher::{black_box, Bencher};
 
 use url::Url;

+ 8 - 7
url/src/host.rs

@@ -6,15 +6,16 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use idna;
-use parser::{ParseError, ParseResult};
-use percent_encoding::{percent_decode, utf8_percent_encode, CONTROLS};
-#[cfg(feature = "serde")]
-use serde::{Deserialize, Serialize};
 use std::cmp;
 use std::fmt::{self, Formatter};
 use std::net::{Ipv4Addr, Ipv6Addr};
 
+use percent_encoding::{percent_decode, utf8_percent_encode, CONTROLS};
+#[cfg(feature = "serde")]
+use serde::{Deserialize, Serialize};
+
+use crate::parser::{ParseError, ParseResult};
+
 #[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
 #[derive(Copy, Clone, Debug, Eq, PartialEq)]
 pub(crate) enum HostInternal {
@@ -158,7 +159,7 @@ impl Host<String> {
 }
 
 impl<S: AsRef<str>> fmt::Display for Host<S> {
-    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
         match *self {
             Host::Domain(ref domain) => domain.as_ref().fmt(f),
             Host::Ipv4(ref addr) => addr.fmt(f),
@@ -171,7 +172,7 @@ impl<S: AsRef<str>> fmt::Display for Host<S> {
     }
 }
 
-fn write_ipv6(addr: &Ipv6Addr, f: &mut Formatter) -> fmt::Result {
+fn write_ipv6(addr: &Ipv6Addr, f: &mut Formatter<'_>) -> fmt::Result {
     let segments = addr.segments();
     let (compress_start, compress_end) = longest_zero_sequence(&segments);
     let mut i = 0;

+ 23 - 24
url/src/lib.rs

@@ -109,14 +109,13 @@ assert_eq!(css_url.as_str(), "http://servo.github.io/rust-url/main.css");
 
 #[macro_use]
 extern crate matches;
-pub extern crate form_urlencoded;
-extern crate idna;
-extern crate percent_encoding;
+pub use form_urlencoded;
+
 #[cfg(feature = "serde")]
 extern crate serde;
 
-use host::HostInternal;
-use parser::{to_u32, Context, Parser, SchemeType, PATH_SEGMENT, USERINFO};
+use crate::host::HostInternal;
+use crate::parser::{to_u32, Context, Parser, SchemeType, PATH_SEGMENT, USERINFO};
 use percent_encoding::{percent_decode, percent_encode, utf8_percent_encode};
 use std::borrow::Borrow;
 use std::cmp;
@@ -133,12 +132,12 @@ use std::str;
 
 use std::convert::TryFrom;
 
+pub use crate::host::Host;
+pub use crate::origin::{OpaqueOrigin, Origin};
+pub use crate::parser::{ParseError, SyntaxViolation};
+pub use crate::path_segments::PathSegmentsMut;
+pub use crate::slicing::Position;
 pub use form_urlencoded::EncodingOverride;
-pub use host::Host;
-pub use origin::{OpaqueOrigin, Origin};
-pub use parser::{ParseError, SyntaxViolation};
-pub use path_segments::PathSegmentsMut;
-pub use slicing::Position;
 
 mod host;
 mod origin;
@@ -225,7 +224,7 @@ impl<'a> ParseOptions<'a> {
     }
 
     /// Parse an URL string with the configuration so far.
-    pub fn parse(self, input: &str) -> Result<Url, ::ParseError> {
+    pub fn parse(self, input: &str) -> Result<Url, crate::ParseError> {
         Parser {
             serialization: String::with_capacity(input.len()),
             base_url: self.base_url,
@@ -260,7 +259,7 @@ impl Url {
     ///
     /// [`ParseError`]: enum.ParseError.html
     #[inline]
-    pub fn parse(input: &str) -> Result<Url, ::ParseError> {
+    pub fn parse(input: &str) -> Result<Url, crate::ParseError> {
         Url::options().parse(input)
     }
 
@@ -290,7 +289,7 @@ impl Url {
     ///
     /// [`ParseError`]: enum.ParseError.html
     #[inline]
-    pub fn parse_with_params<I, K, V>(input: &str, iter: I) -> Result<Url, ::ParseError>
+    pub fn parse_with_params<I, K, V>(input: &str, iter: I) -> Result<Url, crate::ParseError>
     where
         I: IntoIterator,
         I::Item: Borrow<(K, V)>,
@@ -338,7 +337,7 @@ impl Url {
     ///
     /// [`ParseError`]: enum.ParseError.html
     #[inline]
-    pub fn join(&self, input: &str) -> Result<Url, ::ParseError> {
+    pub fn join(&self, input: &str) -> Result<Url, crate::ParseError> {
         Url::options().base_url(Some(self)).parse(input)
     }
 
@@ -1081,7 +1080,7 @@ impl Url {
     /// # }
     /// # run().unwrap();
     /// ```
-    pub fn path_segments(&self) -> Option<str::Split<char>> {
+    pub fn path_segments(&self) -> Option<str::Split<'_, char>> {
         let path = self.path();
         if path.starts_with('/') {
             Some(path[1..].split('/'))
@@ -1153,7 +1152,7 @@ impl Url {
     ///
 
     #[inline]
-    pub fn query_pairs(&self) -> form_urlencoded::Parse {
+    pub fn query_pairs(&self) -> form_urlencoded::Parse<'_> {
         form_urlencoded::parse(self.query().unwrap_or("").as_bytes())
     }
 
@@ -1196,7 +1195,7 @@ impl Url {
         })
     }
 
-    fn mutate<F: FnOnce(&mut Parser) -> R, R>(&mut self, f: F) -> R {
+    fn mutate<F: FnOnce(&mut Parser<'_>) -> R, R>(&mut self, f: F) -> R {
         let mut parser = Parser::for_setter(mem::replace(&mut self.serialization, String::new()));
         let result = f(&mut parser);
         self.serialization = parser.serialization;
@@ -1338,7 +1337,7 @@ impl Url {
     /// not `url.set_query(None)`.
     ///
     /// The state of `Url` is unspecified if this return value is leaked without being dropped.
-    pub fn query_pairs_mut(&mut self) -> form_urlencoded::Serializer<UrlQuery> {
+    pub fn query_pairs_mut(&mut self) -> form_urlencoded::Serializer<'_, UrlQuery<'_>> {
         let fragment = self.take_fragment();
 
         let query_start;
@@ -1415,7 +1414,7 @@ impl Url {
     /// Return an object with methods to manipulate this URL’s path segments.
     ///
     /// Return `Err(())` if this URL is cannot-be-a-base.
-    pub fn path_segments_mut(&mut self) -> Result<PathSegmentsMut, ()> {
+    pub fn path_segments_mut(&mut self) -> Result<PathSegmentsMut<'_>, ()> {
         if self.cannot_be_a_base() {
             Err(())
         } else {
@@ -2327,7 +2326,7 @@ impl str::FromStr for Url {
     type Err = ParseError;
 
     #[inline]
-    fn from_str(input: &str) -> Result<Url, ::ParseError> {
+    fn from_str(input: &str) -> Result<Url, crate::ParseError> {
         Url::parse(input)
     }
 }
@@ -2343,7 +2342,7 @@ impl<'a> TryFrom<&'a str> for Url {
 /// Display the serialization of this URL.
 impl fmt::Display for Url {
     #[inline]
-    fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
         fmt::Display::fmt(&self.serialization, formatter)
     }
 }
@@ -2351,7 +2350,7 @@ impl fmt::Display for Url {
 /// Debug the serialization of this URL.
 impl fmt::Debug for Url {
     #[inline]
-    fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
         fmt::Debug::fmt(&self.serialization, formatter)
     }
 }
@@ -2571,7 +2570,7 @@ fn path_to_file_url_segments_windows(
 #[cfg(any(unix, target_os = "redox"))]
 fn file_url_segments_to_pathbuf(
     host: Option<&str>,
-    segments: str::Split<char>,
+    segments: str::Split<'_, char>,
 ) -> Result<PathBuf, ()> {
     use std::ffi::OsStr;
     use std::os::unix::prelude::OsStrExt;
@@ -2617,7 +2616,7 @@ fn file_url_segments_to_pathbuf(
 #[cfg_attr(not(windows), allow(dead_code))]
 fn file_url_segments_to_pathbuf_windows(
     host: Option<&str>,
-    mut segments: str::Split<char>,
+    mut segments: str::Split<'_, char>,
 ) -> Result<PathBuf, ()> {
     let mut string = if let Some(host) = host {
         r"\\".to_owned() + host

+ 3 - 3
url/src/origin.rs

@@ -6,11 +6,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use host::Host;
+use crate::host::Host;
+use crate::parser::default_port;
+use crate::Url;
 use idna::domain_to_unicode;
-use parser::default_port;
 use std::sync::atomic::{AtomicUsize, Ordering};
-use Url;
 
 pub fn url_origin(url: &Url) -> Origin {
     let scheme = url.scheme();

+ 21 - 21
url/src/parser.rs

@@ -10,10 +10,10 @@ use std::error::Error;
 use std::fmt::{self, Formatter, Write};
 use std::str;
 
+use crate::host::{Host, HostInternal};
+use crate::Url;
 use form_urlencoded::EncodingOverride;
-use host::{Host, HostInternal};
 use percent_encoding::{percent_encode, utf8_percent_encode, AsciiSet, CONTROLS};
-use Url;
 
 /// https://url.spec.whatwg.org/#fragment-percent-encode-set
 const FRAGMENT: &AsciiSet = &CONTROLS.add(b' ').add(b'"').add(b'<').add(b'>').add(b'`');
@@ -149,7 +149,7 @@ syntax_violation_enum! {
 }
 
 impl fmt::Display for SyntaxViolation {
-    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
         fmt::Display::fmt(self.description(), f)
     }
 }
@@ -422,8 +422,8 @@ impl<'a> Parser<'a> {
         }
     }
 
-    fn parse_with_scheme(mut self, input: Input) -> ParseResult<Url> {
-        use SyntaxViolation::{ExpectedDoubleSlash, ExpectedFileDoubleSlash};
+    fn parse_with_scheme(mut self, input: Input<'_>) -> ParseResult<Url> {
+        use crate::SyntaxViolation::{ExpectedDoubleSlash, ExpectedFileDoubleSlash};
         let scheme_end = to_u32(self.serialization.len())?;
         let scheme_type = SchemeType::from(&self.serialization);
         self.serialization.push(':');
@@ -470,7 +470,7 @@ impl<'a> Parser<'a> {
     /// Scheme other than file, http, https, ws, ws, ftp.
     fn parse_non_special(
         mut self,
-        input: Input,
+        input: Input<'_>,
         scheme_type: SchemeType,
         scheme_end: u32,
     ) -> ParseResult<Url> {
@@ -507,11 +507,11 @@ impl<'a> Parser<'a> {
 
     fn parse_file(
         mut self,
-        input: Input,
+        input: Input<'_>,
         scheme_type: SchemeType,
         base_file_url: Option<&Url>,
     ) -> ParseResult<Url> {
-        use SyntaxViolation::Backslash;
+        use crate::SyntaxViolation::Backslash;
         // file state
         debug_assert!(self.serialization.is_empty());
         let (first_char, input_after_first_char) = input.split_first();
@@ -718,7 +718,7 @@ impl<'a> Parser<'a> {
 
     fn parse_relative(
         mut self,
-        input: Input,
+        input: Input<'_>,
         scheme_type: SchemeType,
         base_url: &Url,
     ) -> ParseResult<Url> {
@@ -839,7 +839,7 @@ impl<'a> Parser<'a> {
 
     fn after_double_slash(
         mut self,
-        input: Input,
+        input: Input<'_>,
         scheme_type: SchemeType,
         scheme_end: u32,
     ) -> ParseResult<Url> {
@@ -981,9 +981,9 @@ impl<'a> Parser<'a> {
     }
 
     pub fn parse_host(
-        mut input: Input,
+        mut input: Input<'_>,
         scheme_type: SchemeType,
-    ) -> ParseResult<(Host<String>, Input)> {
+    ) -> ParseResult<(Host<String>, Input<'_>)> {
         if scheme_type.is_file() {
             return Parser::get_file_host(input);
         }
@@ -1037,7 +1037,7 @@ impl<'a> Parser<'a> {
         Ok((host, input))
     }
 
-    fn get_file_host(input: Input) -> ParseResult<(Host<String>, Input)> {
+    fn get_file_host(input: Input<'_>) -> ParseResult<(Host<String>, Input<'_>)> {
         let (_, host_str, remaining) = Parser::file_host(input)?;
         let host = match Host::parse(&host_str)? {
             Host::Domain(ref d) if d == "localhost" => Host::Domain("".to_string()),
@@ -1106,10 +1106,10 @@ impl<'a> Parser<'a> {
     }
 
     pub fn parse_port<P>(
-        mut input: Input,
+        mut input: Input<'_>,
         default_port: P,
         context: Context,
-    ) -> ParseResult<(Option<u16>, Input)>
+    ) -> ParseResult<(Option<u16>, Input<'_>)>
     where
         P: Fn() -> Option<u16>,
     {
@@ -1369,7 +1369,7 @@ impl<'a> Parser<'a> {
         host: HostInternal,
         port: Option<u16>,
         path_start: u32,
-        remaining: Input,
+        remaining: Input<'_>,
     ) -> ParseResult<Url> {
         let (query_start, fragment_start) =
             self.parse_query_and_fragment(scheme_type, scheme_end, remaining)?;
@@ -1392,7 +1392,7 @@ impl<'a> Parser<'a> {
         &mut self,
         scheme_type: SchemeType,
         scheme_end: u32,
-        mut input: Input,
+        mut input: Input<'_>,
     ) -> ParseResult<(Option<u32>, Option<u32>)> {
         let mut query_start = None;
         match input.next() {
@@ -1453,7 +1453,7 @@ impl<'a> Parser<'a> {
         remaining
     }
 
-    fn fragment_only(mut self, base_url: &Url, mut input: Input) -> ParseResult<Url> {
+    fn fragment_only(mut self, base_url: &Url, mut input: Input<'_>) -> ParseResult<Url> {
         let before_fragment = match base_url.fragment_start {
             Some(i) => base_url.slice(..i),
             None => &*base_url.serialization,
@@ -1473,7 +1473,7 @@ impl<'a> Parser<'a> {
         })
     }
 
-    pub fn parse_fragment(&mut self, mut input: Input) {
+    pub fn parse_fragment(&mut self, mut input: Input<'_>) {
         while let Some((c, utf8_c)) = input.next_utf8() {
             if c == '\0' {
                 self.log_violation(SyntaxViolation::NullInFragment)
@@ -1485,7 +1485,7 @@ impl<'a> Parser<'a> {
         }
     }
 
-    fn check_url_code_point(&self, c: char, input: &Input) {
+    fn check_url_code_point(&self, c: char, input: &Input<'_>) {
         if let Some(vfn) = self.violation_fn {
             if c == '%' {
                 let mut input = input.clone();
@@ -1588,7 +1588,7 @@ fn starts_with_windows_drive_letter(s: &str) -> bool {
 }
 
 /// https://url.spec.whatwg.org/#start-with-a-windows-drive-letter
-fn starts_with_windows_drive_letter_segment(input: &Input) -> bool {
+fn starts_with_windows_drive_letter_segment(input: &Input<'_>) -> bool {
     let mut input = input.clone();
     match (input.next(), input.next(), input.next()) {
         // its first two code points are a Windows drive letter

+ 3 - 3
url/src/path_segments.rs

@@ -6,9 +6,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use parser::{self, to_u32, SchemeType};
+use crate::parser::{self, to_u32, SchemeType};
+use crate::Url;
 use std::str;
-use Url;
 
 /// Exposes methods to manipulate the path of an URL that is not cannot-be-base.
 ///
@@ -42,7 +42,7 @@ pub struct PathSegmentsMut<'a> {
 }
 
 // Not re-exported outside the crate
-pub fn new(url: &mut Url) -> PathSegmentsMut {
+pub fn new(url: &mut Url) -> PathSegmentsMut<'_> {
     let after_path = url.take_after_path();
     let old_after_path_position = to_u32(url.serialization.len()).unwrap();
     // Special urls always have a non empty path

+ 2 - 2
url/src/quirks.rs

@@ -11,8 +11,8 @@
 //! Unless you need to be interoperable with web browsers,
 //! you probably want to use `Url` method instead.
 
-use parser::{default_port, Context, Input, Parser, SchemeType};
-use {idna, Host, ParseError, Position, Url};
+use crate::parser::{default_port, Context, Input, Parser, SchemeType};
+use crate::{Host, ParseError, Position, Url};
 
 /// https://url.spec.whatwg.org/#dom-url-domaintoascii
 pub fn domain_to_ascii(domain: &str) -> String {

+ 1 - 1
url/src/slicing.rs

@@ -6,8 +6,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use crate::Url;
 use std::ops::{Index, Range, RangeFrom, RangeFull, RangeTo};
-use Url;
 
 impl Index<RangeFull> for Url {
     type Output = str;

+ 1 - 4
url/tests/data.rs

@@ -8,10 +8,7 @@
 
 //! Data-driven tests
 
-extern crate rustc_test as test;
-extern crate serde_json;
-extern crate url;
-
+use rustc_test as test;
 use serde_json::Value;
 use std::str::FromStr;
 use url::{quirks, Url};

+ 1 - 4
url/tests/unit.rs

@@ -8,9 +8,6 @@
 
 //! Unit tests
 
-extern crate percent_encoding;
-extern crate url;
-
 use std::borrow::Cow;
 use std::cell::{Cell, RefCell};
 use std::net::{Ipv4Addr, Ipv6Addr};
@@ -337,7 +334,7 @@ fn test_serialization() {
 
 #[test]
 fn test_form_urlencoded() {
-    let pairs: &[(Cow<str>, Cow<str>)] = &[
+    let pairs: &[(Cow<'_, str>, Cow<'_, str>)] = &[
         ("foo".into(), "é&".into()),
         ("bar".into(), "".into()),
         ("foo".into(), "#".into()),