fix a bunch of the other clippy warnings that look interesting

This commit is contained in:
Matthias Krüger 2021-10-23 23:21:52 +02:00 committed by Caleb Cartwright
parent c493ee4828
commit 0b8ffac029
5 changed files with 10 additions and 10 deletions

View File

@ -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' {

View File

@ -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(

View File

@ -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()

View File

@ -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) {

View File

@ -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
{