diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2021-10-23 23:21:52 +0200 |
|---|---|---|
| committer | Caleb Cartwright <calebcartwright@users.noreply.github.com> | 2021-10-27 20:41:57 -0500 |
| commit | 0b8ffac0297a46d7d2d2f8328cbc49de7e7144f2 (patch) | |
| tree | dd52d365efca0e3c446641d74915085cad6dc775 | |
| parent | c493ee4828ab8e94ed175ec781afe7351bf89784 (diff) | |
| download | rust-0b8ffac0297a46d7d2d2f8328cbc49de7e7144f2.tar.gz rust-0b8ffac0297a46d7d2d2f8328cbc49de7e7144f2.zip | |
fix a bunch of the other clippy warnings that look interesting
| -rw-r--r-- | src/comment.rs | 4 | ||||
| -rw-r--r-- | src/expr.rs | 6 | ||||
| -rw-r--r-- | src/matches.rs | 2 | ||||
| -rw-r--r-- | src/modules.rs | 2 | ||||
| -rw-r--r-- | src/patterns.rs | 6 |
5 files changed, 10 insertions, 10 deletions
diff --git a/src/comment.rs b/src/comment.rs index a3cd0359e6b..7b76c232937 100644 --- a/src/comment.rs +++ b/src/comment.rs @@ -405,7 +405,7 @@ impl CodeBlockAttribute { /// attributes are valid rust attributes /// See <https://doc.rust-lang.org/rustdoc/print.html#attributes> fn new(attributes: &str) -> CodeBlockAttribute { - for attribute in attributes.split(",") { + for attribute in attributes.split(',') { match attribute.trim() { "" | "rust" | "should_panic" | "no_run" | "edition2015" | "edition2018" | "edition2021" => (), @@ -1384,7 +1384,7 @@ impl<'a> Iterator for LineClasses<'a> { None => unreachable!(), }; - while let Some((kind, c)) = self.base.next() { + for (kind, c) in self.base.by_ref() { // needed to set the kind of the ending character on the last line self.kind = kind; if c == '\n' { diff --git a/src/expr.rs b/src/expr.rs index c67c14b1985..1ca01f9db9a 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -1207,11 +1207,11 @@ fn rewrite_int_lit(context: &RewriteContext<'_>, lit: &ast::Lit, shape: Shape) - let span = lit.span; let symbol = lit.token.symbol.as_str(); - if symbol.starts_with("0x") { + if let Some(symbol_stripped) = symbol.strip_prefix("0x") { let hex_lit = match context.config.hex_literal_case() { HexLiteralCase::Preserve => None, - HexLiteralCase::Upper => Some(symbol[2..].to_ascii_uppercase()), - HexLiteralCase::Lower => Some(symbol[2..].to_ascii_lowercase()), + HexLiteralCase::Upper => Some(symbol_stripped.to_ascii_uppercase()), + HexLiteralCase::Lower => Some(symbol_stripped.to_ascii_lowercase()), }; if let Some(hex_lit) = hex_lit { return wrap_str( diff --git a/src/matches.rs b/src/matches.rs index 25b953ef425..22d23fc1cdb 100644 --- a/src/matches.rs +++ b/src/matches.rs @@ -168,7 +168,7 @@ fn collect_beginning_verts( .map(|a| { context .snippet(a.pat.span) - .starts_with("|") + .starts_with('|') .then(|| a.pat.span().lo()) }) .collect() diff --git a/src/modules.rs b/src/modules.rs index b0c1604a602..88d434d759d 100644 --- a/src/modules.rs +++ b/src/modules.rs @@ -197,7 +197,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> { /// Visit modules from AST. fn visit_mod_from_ast( &mut self, - items: &'ast Vec<rustc_ast::ptr::P<ast::Item>>, + items: &'ast [rustc_ast::ptr::P<ast::Item>], ) -> Result<(), ModuleResolutionError> { for item in items { if is_cfg_if(item) { diff --git a/src/patterns.rs b/src/patterns.rs index 2676c647355..a80d63201f9 100644 --- a/src/patterns.rs +++ b/src/patterns.rs @@ -456,11 +456,11 @@ fn rewrite_tuple_pat( context: &RewriteContext<'_>, shape: Shape, ) -> Option<String> { - let mut pat_vec: Vec<_> = pats.iter().map(|x| TuplePatField::Pat(x)).collect(); - - if pat_vec.is_empty() { + if pats.is_empty() { return Some(format!("{}()", path_str.unwrap_or_default())); } + let mut pat_vec: Vec<_> = pats.iter().map(TuplePatField::Pat).collect(); + let wildcard_suffix_len = count_wildcard_suffix_len(context, &pat_vec, span, shape); let (pat_vec, span) = if context.config.condense_wildcard_suffixes() && wildcard_suffix_len >= 2 { |
