Fix clippy::needless_borrow
in the compiler
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
This commit is contained in:
parent
0ff8610964
commit
21a870515b
304 changed files with 1101 additions and 1174 deletions
|
@ -75,7 +75,7 @@ pub(crate) fn parse_token_trees<'a>(
|
|||
|
||||
let mut buffer = Vec::with_capacity(1);
|
||||
for unmatched in unmatched_delims {
|
||||
if let Some(err) = make_unclosed_delims_error(unmatched, &sess) {
|
||||
if let Some(err) = make_unclosed_delims_error(unmatched, sess) {
|
||||
err.buffer(&mut buffer);
|
||||
}
|
||||
}
|
||||
|
@ -362,7 +362,7 @@ impl<'a> StringReader<'a> {
|
|||
if contains_text_flow_control_chars(content) {
|
||||
let span = self.mk_sp(start, self.pos);
|
||||
self.sess.buffer_lint_with_diagnostic(
|
||||
&TEXT_DIRECTION_CODEPOINT_IN_COMMENT,
|
||||
TEXT_DIRECTION_CODEPOINT_IN_COMMENT,
|
||||
span,
|
||||
ast::CRATE_NODE_ID,
|
||||
"unicode codepoint changing visible direction of text present in comment",
|
||||
|
@ -683,7 +683,7 @@ impl<'a> StringReader<'a> {
|
|||
} else {
|
||||
// Before Rust 2021, only emit a lint for migration.
|
||||
self.sess.buffer_lint_with_diagnostic(
|
||||
&RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX,
|
||||
RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX,
|
||||
prefix_span,
|
||||
ast::CRATE_NODE_ID,
|
||||
format!("prefix `{prefix}` is unknown"),
|
||||
|
|
|
@ -97,7 +97,7 @@ impl<'a> TokenTreesReader<'a> {
|
|||
report_suspicious_mismatch_block(
|
||||
&mut err,
|
||||
&self.diag_info,
|
||||
&self.string_reader.sess.source_map(),
|
||||
self.string_reader.sess.source_map(),
|
||||
*delim,
|
||||
)
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ impl<'a> TokenTreesReader<'a> {
|
|||
unclosed_delimiter = Some(sp);
|
||||
};
|
||||
for (brace, brace_span) in &self.diag_info.open_braces {
|
||||
if same_indentation_level(&sm, self.token.span, *brace_span)
|
||||
if same_indentation_level(sm, self.token.span, *brace_span)
|
||||
&& brace == &close_delim
|
||||
{
|
||||
// high likelihood of these two corresponding
|
||||
|
@ -271,7 +271,7 @@ impl<'a> TokenTreesReader<'a> {
|
|||
report_suspicious_mismatch_block(
|
||||
&mut err,
|
||||
&self.diag_info,
|
||||
&self.string_reader.sess.source_map(),
|
||||
self.string_reader.sess.source_map(),
|
||||
delim,
|
||||
);
|
||||
err.span_label(self.token.span, "unexpected closing delimiter");
|
||||
|
|
|
@ -1281,11 +1281,11 @@ impl<'a> Parser<'a> {
|
|||
(BinOpKind::Ge, AssocOp::GreaterEqual | AssocOp::Greater) => {
|
||||
let expr_to_str = |e: &Expr| {
|
||||
self.span_to_snippet(e.span)
|
||||
.unwrap_or_else(|_| pprust::expr_to_string(&e))
|
||||
.unwrap_or_else(|_| pprust::expr_to_string(e))
|
||||
};
|
||||
err.chaining_sugg = Some(ComparisonOperatorsCannotBeChainedSugg::SplitComparison {
|
||||
span: inner_op.span.shrink_to_hi(),
|
||||
middle_term: expr_to_str(&r1),
|
||||
middle_term: expr_to_str(r1),
|
||||
});
|
||||
false // Keep the current parse behavior, where the AST is `(x < y) < z`.
|
||||
}
|
||||
|
@ -1506,7 +1506,7 @@ impl<'a> Parser<'a> {
|
|||
|
||||
pub(super) fn maybe_report_ambiguous_plus(&mut self, impl_dyn_multi: bool, ty: &Ty) {
|
||||
if impl_dyn_multi {
|
||||
self.sess.emit_err(AmbiguousPlus { sum_ty: pprust::ty_to_string(&ty), span: ty.span });
|
||||
self.sess.emit_err(AmbiguousPlus { sum_ty: pprust::ty_to_string(ty), span: ty.span });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1939,7 +1939,7 @@ impl<'a> Parser<'a> {
|
|||
self.sess.emit_err(IncorrectAwait {
|
||||
span,
|
||||
sugg_span: (span, applicability),
|
||||
expr: self.span_to_snippet(expr.span).unwrap_or_else(|_| pprust::expr_to_string(&expr)),
|
||||
expr: self.span_to_snippet(expr.span).unwrap_or_else(|_| pprust::expr_to_string(expr)),
|
||||
question_mark: if is_question { "?" } else { "" },
|
||||
});
|
||||
|
||||
|
|
|
@ -1060,7 +1060,7 @@ impl<'a> Parser<'a> {
|
|||
match &*components {
|
||||
// 1e2
|
||||
[IdentLike(i)] => {
|
||||
DestructuredFloat::Single(Symbol::intern(&i), span)
|
||||
DestructuredFloat::Single(Symbol::intern(i), span)
|
||||
}
|
||||
// 1.
|
||||
[IdentLike(i), Punct('.')] => {
|
||||
|
@ -1072,7 +1072,7 @@ impl<'a> Parser<'a> {
|
|||
} else {
|
||||
(span, span)
|
||||
};
|
||||
let symbol = Symbol::intern(&i);
|
||||
let symbol = Symbol::intern(i);
|
||||
DestructuredFloat::TrailingDot(symbol, ident_span, dot_span)
|
||||
}
|
||||
// 1.2 | 1.2e3
|
||||
|
@ -1088,8 +1088,8 @@ impl<'a> Parser<'a> {
|
|||
} else {
|
||||
(span, span, span)
|
||||
};
|
||||
let symbol1 = Symbol::intern(&i1);
|
||||
let symbol2 = Symbol::intern(&i2);
|
||||
let symbol1 = Symbol::intern(i1);
|
||||
let symbol2 = Symbol::intern(i2);
|
||||
DestructuredFloat::MiddleDot(symbol1, ident1_span, dot_span, symbol2, ident2_span)
|
||||
}
|
||||
// 1e+ | 1e- (recovered)
|
||||
|
@ -2052,7 +2052,7 @@ impl<'a> Parser<'a> {
|
|||
Err(err) => {
|
||||
let span = token.uninterpolated_span();
|
||||
self.bump();
|
||||
report_lit_error(&self.sess, err, lit, span);
|
||||
report_lit_error(self.sess, err, lit, span);
|
||||
// Pack possible quotes and prefixes from the original literal into
|
||||
// the error literal's symbol so they can be pretty-printed faithfully.
|
||||
let suffixless_lit = token::Lit::new(lit.kind, lit.symbol, None);
|
||||
|
@ -3207,7 +3207,7 @@ impl<'a> Parser<'a> {
|
|||
if let Some((ident, _)) = self.token.ident()
|
||||
&& !self.token.is_reserved_ident()
|
||||
&& self.look_ahead(1, |t| {
|
||||
AssocOp::from_token(&t).is_some()
|
||||
AssocOp::from_token(t).is_some()
|
||||
|| matches!(t.kind, token::OpenDelim(_))
|
||||
|| t.kind == token::Dot
|
||||
})
|
||||
|
|
|
@ -2271,7 +2271,7 @@ impl<'a> Parser<'a> {
|
|||
} else {
|
||||
&[token::Semi, token::OpenDelim(Delimiter::Brace)]
|
||||
};
|
||||
if let Err(mut err) = self.expected_one_of_not_found(&[], &expected) {
|
||||
if let Err(mut err) = self.expected_one_of_not_found(&[], expected) {
|
||||
if self.token.kind == token::CloseDelim(Delimiter::Brace) {
|
||||
// The enclosing `mod`, `trait` or `impl` is being closed, so keep the `fn` in
|
||||
// the AST for typechecking.
|
||||
|
|
|
@ -541,7 +541,7 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
|
||||
self.sess
|
||||
.emit_err(AmbiguousRangePattern { span: pat.span, pat: pprust::pat_to_string(&pat) });
|
||||
.emit_err(AmbiguousRangePattern { span: pat.span, pat: pprust::pat_to_string(pat) });
|
||||
}
|
||||
|
||||
/// Parse `&pat` / `&mut pat`.
|
||||
|
@ -641,7 +641,7 @@ impl<'a> Parser<'a> {
|
|||
self.sess.emit_err(if changed_any_binding {
|
||||
InvalidMutInPattern::NestedIdent {
|
||||
span: lo.to(pat.span),
|
||||
pat: pprust::pat_to_string(&pat),
|
||||
pat: pprust::pat_to_string(pat),
|
||||
}
|
||||
} else {
|
||||
InvalidMutInPattern::NonIdent { span: lo.until(pat.span) }
|
||||
|
|
|
@ -188,7 +188,7 @@ fn emit_malformed_attribute(
|
|||
}
|
||||
suggestions.sort();
|
||||
if should_warn(name) {
|
||||
sess.buffer_lint(&ILL_FORMED_ATTRIBUTE_INPUT, span, ast::CRATE_NODE_ID, msg);
|
||||
sess.buffer_lint(ILL_FORMED_ATTRIBUTE_INPUT, span, ast::CRATE_NODE_ID, msg);
|
||||
} else {
|
||||
sess.span_diagnostic
|
||||
.struct_span_err(span, error_msg)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue