Просмотр исходного кода

Fix clippy warnings

- `clippy::explicit_auto_deref`
- `clippy::manual_is_ascii_check`
- `clippy::needless_borrowed_reference`
- `clippy::needless_lifetimes`
- `clippy::partial_eq_none`
Constantin Nickel 3 лет назад
Родитель
Сommit
1e39e75907
7 измененных файлов с 16 добавлено и 16 удалено
  1. 4 4
      data-url/src/mime.rs
  2. 2 2
      form_urlencoded/src/lib.rs
  3. 4 4
      idna/src/uts46.rs
  4. 1 1
      idna/tests/punycode.rs
  5. 2 2
      url/src/lib.rs
  6. 2 2
      url/src/parser.rs
  7. 1 1
      url/tests/data.rs

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

@@ -17,8 +17,8 @@ impl Mime {
     {
     {
         self.parameters
         self.parameters
             .iter()
             .iter()
-            .find(|&&(ref n, _)| name == &**n)
-            .map(|&(_, ref v)| &**v)
+            .find(|&(n, _)| name == &**n)
+            .map(|(_, v)| &**v)
     }
     }
 }
 }
 
 
@@ -124,7 +124,7 @@ fn parse_parameters(s: &str, parameters: &mut Vec<(String, String)>) {
 }
 }
 
 
 fn contains(parameters: &[(String, String)], name: &str) -> bool {
 fn contains(parameters: &[(String, String)], name: &str) -> bool {
-    parameters.iter().any(|&(ref n, _)| n == name)
+    parameters.iter().any(|(n, _)| n == name)
 }
 }
 
 
 fn valid_value(s: &str) -> bool {
 fn valid_value(s: &str) -> bool {
@@ -140,7 +140,7 @@ impl fmt::Display for Mime {
         f.write_str(&self.type_)?;
         f.write_str(&self.type_)?;
         f.write_str("/")?;
         f.write_str("/")?;
         f.write_str(&self.subtype)?;
         f.write_str(&self.subtype)?;
-        for &(ref name, ref value) in &self.parameters {
+        for (name, value) in &self.parameters {
             f.write_str(";")?;
             f.write_str(";")?;
             f.write_str(name)?;
             f.write_str(name)?;
             f.write_str("=")?;
             f.write_str("=")?;

+ 2 - 2
form_urlencoded/src/lib.rs

@@ -186,7 +186,7 @@ impl Target for String {
 
 
 impl<'a> Target for &'a mut String {
 impl<'a> Target for &'a mut String {
     fn as_mut_string(&mut self) -> &mut String {
     fn as_mut_string(&mut self) -> &mut String {
-        &mut **self
+        self
     }
     }
     fn finish(self) -> Self {
     fn finish(self) -> Self {
         self
         self
@@ -282,7 +282,7 @@ impl<'a, T: Target> Serializer<'a, T> {
         {
         {
             let string = string(&mut self.target);
             let string = string(&mut self.target);
             for pair in iter {
             for pair in iter {
-                let &(ref k, ref v) = pair.borrow();
+                let (k, v) = pair.borrow();
                 append_pair(
                 append_pair(
                     string,
                     string,
                     self.start_position,
                     self.start_position,

+ 4 - 4
idna/src/uts46.rs

@@ -274,7 +274,7 @@ fn passes_bidi(label: &str, is_bidi_domain: bool) -> bool {
 /// http://www.unicode.org/reports/tr46/#Validity_Criteria
 /// http://www.unicode.org/reports/tr46/#Validity_Criteria
 fn check_validity(label: &str, config: Config, errors: &mut Errors) {
 fn check_validity(label: &str, config: Config, errors: &mut Errors) {
     let first_char = label.chars().next();
     let first_char = label.chars().next();
-    if first_char == None {
+    if first_char.is_none() {
         // Empty string, pass
         // Empty string, pass
         return;
         return;
     }
     }
@@ -475,7 +475,7 @@ impl Idna {
 
 
     /// http://www.unicode.org/reports/tr46/#ToASCII
     /// http://www.unicode.org/reports/tr46/#ToASCII
     #[allow(clippy::wrong_self_convention)]
     #[allow(clippy::wrong_self_convention)]
-    pub fn to_ascii<'a>(&'a mut self, domain: &str, out: &mut String) -> Result<(), Errors> {
+    pub fn to_ascii(&mut self, domain: &str, out: &mut String) -> Result<(), Errors> {
         let mut errors = self.to_ascii_inner(domain, out);
         let mut errors = self.to_ascii_inner(domain, out);
 
 
         if self.config.verify_dns_length {
         if self.config.verify_dns_length {
@@ -497,7 +497,7 @@ impl Idna {
 
 
     /// http://www.unicode.org/reports/tr46/#ToUnicode
     /// http://www.unicode.org/reports/tr46/#ToUnicode
     #[allow(clippy::wrong_self_convention)]
     #[allow(clippy::wrong_self_convention)]
-    pub fn to_unicode<'a>(&'a mut self, domain: &str, out: &mut String) -> Result<(), Errors> {
+    pub fn to_unicode(&mut self, domain: &str, out: &mut String) -> Result<(), Errors> {
         if is_simple(domain) {
         if is_simple(domain) {
             out.push_str(domain);
             out.push_str(domain);
             return Errors::default().into();
             return Errors::default().into();
@@ -685,7 +685,7 @@ impl fmt::Debug for Errors {
                 if !empty {
                 if !empty {
                     f.write_str(", ")?;
                     f.write_str(", ")?;
                 }
                 }
-                f.write_str(*name)?;
+                f.write_str(name)?;
                 empty = false;
                 empty = false;
             }
             }
         }
         }

+ 1 - 1
idna/tests/punycode.rs

@@ -41,7 +41,7 @@ fn one_test(decoded: &str, encoded: &str) {
 
 
 fn get_string<'a>(map: &'a Map<String, Value>, key: &str) -> &'a str {
 fn get_string<'a>(map: &'a Map<String, Value>, key: &str) -> &'a str {
     match map.get(&key.to_string()) {
     match map.get(&key.to_string()) {
-        Some(&Value::String(ref s)) => s,
+        Some(Value::String(s)) => s,
         None => "",
         None => "",
         _ => panic!(),
         _ => panic!(),
     }
     }

+ 2 - 2
url/src/lib.rs

@@ -601,7 +601,7 @@ impl Url {
         }
         }
 
 
         assert!(self.scheme_end >= 1);
         assert!(self.scheme_end >= 1);
-        assert!(matches!(self.byte_at(0), b'a'..=b'z' | b'A'..=b'Z'));
+        assert!(self.byte_at(0).is_ascii_alphabetic());
         assert!(self
         assert!(self
             .slice(1..self.scheme_end)
             .slice(1..self.scheme_end)
             .chars()
             .chars()
@@ -2848,7 +2848,7 @@ fn file_url_segments_to_pathbuf(
 
 
     // A windows drive letter must end with a slash.
     // A windows drive letter must end with a slash.
     if bytes.len() > 2
     if bytes.len() > 2
-        && matches!(bytes[bytes.len() - 2], b'a'..=b'z' | b'A'..=b'Z')
+        && bytes[bytes.len() - 2].is_ascii_alphabetic()
         && matches!(bytes[bytes.len() - 1], b':' | b'|')
         && matches!(bytes[bytes.len() - 1], b':' | b'|')
     {
     {
         bytes.push(b'/');
         bytes.push(b'/');

+ 2 - 2
url/src/parser.rs

@@ -1156,7 +1156,7 @@ impl<'a> Parser<'a> {
             return input;
             return input;
         }
         }
 
 
-        if maybe_c != None && maybe_c != Some('/') {
+        if maybe_c.is_some() && maybe_c != Some('/') {
             self.serialization.push('/');
             self.serialization.push('/');
         }
         }
         // Otherwise, if c is not the EOF code point:
         // Otherwise, if c is not the EOF code point:
@@ -1534,7 +1534,7 @@ fn ascii_tab_or_new_line(ch: char) -> bool {
 /// https://url.spec.whatwg.org/#ascii-alpha
 /// https://url.spec.whatwg.org/#ascii-alpha
 #[inline]
 #[inline]
 pub fn ascii_alpha(ch: char) -> bool {
 pub fn ascii_alpha(ch: char) -> bool {
-    matches!(ch, 'a'..='z' | 'A'..='Z')
+    ch.is_ascii_alphabetic()
 }
 }
 
 
 #[inline]
 #[inline]

+ 1 - 1
url/tests/data.rs

@@ -228,7 +228,7 @@ fn get<'a>(url: &'a Url, attr: &str) -> &'a str {
 }
 }
 
 
 #[allow(clippy::unit_arg)]
 #[allow(clippy::unit_arg)]
-fn set<'a>(url: &'a mut Url, attr: &str, new: &str) {
+fn set(url: &mut Url, attr: &str, new: &str) {
     let _ = match attr {
     let _ = match attr {
         "protocol" => quirks::set_protocol(url, new),
         "protocol" => quirks::set_protocol(url, new),
         "username" => quirks::set_username(url, new),
         "username" => quirks::set_username(url, new),