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
|
@ -123,7 +123,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
.map(|parent_id| self.get_nearest_non_block_module(parent_id));
|
||||
// Query `expn_that_defined` is not used because
|
||||
// hashing spans in its result is expensive.
|
||||
let expn_id = self.cstore().expn_that_defined_untracked(def_id, &self.tcx.sess);
|
||||
let expn_id = self.cstore().expn_that_defined_untracked(def_id, self.tcx.sess);
|
||||
return Some(self.new_module(
|
||||
parent,
|
||||
ModuleKind::Def(def_kind, def_id, self.tcx.item_name(def_id)),
|
||||
|
|
|
@ -979,7 +979,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
path_span: path.span,
|
||||
// intentionally converting to String, as the text would also be used as
|
||||
// in suggestion context
|
||||
path_str: pprust::path_to_string(&path),
|
||||
path_str: pprust::path_to_string(path),
|
||||
})
|
||||
}
|
||||
VisResolutionError::AncestorOnly(span) => {
|
||||
|
@ -1444,7 +1444,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
if let Ok(binding) = self.early_resolve_ident_in_lexical_scope(
|
||||
ident,
|
||||
ScopeSet::All(ns),
|
||||
&parent_scope,
|
||||
parent_scope,
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
|
|
|
@ -115,7 +115,7 @@ impl<'r, 'a, 'tcx> EffectiveVisibilitiesVisitor<'r, 'a, 'tcx> {
|
|||
/// Update effective visibilities of bindings in the given module,
|
||||
/// including their whole reexport chains.
|
||||
fn set_bindings_effective_visibilities(&mut self, module_id: LocalDefId) {
|
||||
assert!(self.r.module_map.contains_key(&&module_id.to_def_id()));
|
||||
assert!(self.r.module_map.contains_key(&module_id.to_def_id()));
|
||||
let module = self.r.get_module(module_id.to_def_id()).unwrap();
|
||||
let resolutions = self.r.resolutions(module);
|
||||
|
||||
|
|
|
@ -708,7 +708,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
self.tcx,
|
||||
&mut diag,
|
||||
Some(err.span),
|
||||
&candidates,
|
||||
candidates,
|
||||
DiagnosticMode::Import,
|
||||
(source != target)
|
||||
.then(|| format!(" as {target}"))
|
||||
|
@ -720,7 +720,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
self.tcx,
|
||||
&mut diag,
|
||||
None,
|
||||
&candidates,
|
||||
candidates,
|
||||
DiagnosticMode::Normal,
|
||||
(source != target)
|
||||
.then(|| format!(" as {target}"))
|
||||
|
|
|
@ -739,7 +739,7 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
|
|||
}
|
||||
TyKind::Path(qself, path) => {
|
||||
self.diagnostic_metadata.current_type_path = Some(ty);
|
||||
self.smart_resolve_path(ty.id, &qself, path, PathSource::Type);
|
||||
self.smart_resolve_path(ty.id, qself, path, PathSource::Type);
|
||||
|
||||
// Check whether we should interpret this as a bare trait object.
|
||||
if qself.is_none()
|
||||
|
@ -759,7 +759,7 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
|
|||
kind: LifetimeBinderKind::PolyTrait,
|
||||
span,
|
||||
},
|
||||
|this| this.visit_path(&path, ty.id),
|
||||
|this| this.visit_path(path, ty.id),
|
||||
);
|
||||
} else {
|
||||
visit::walk_ty(self, ty)
|
||||
|
@ -1043,7 +1043,7 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
|
|||
ClosureBinder::NotPresent => {}
|
||||
ClosureBinder::For { generic_params, .. } => {
|
||||
self.visit_generic_params(
|
||||
&generic_params,
|
||||
generic_params,
|
||||
self.diagnostic_metadata.current_self_item.is_some(),
|
||||
);
|
||||
}
|
||||
|
@ -1187,7 +1187,7 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
|
|||
{
|
||||
let span = predicate_span.shrink_to_lo().to(bounded_ty.span.shrink_to_lo());
|
||||
this.with_generic_param_rib(
|
||||
&bound_generic_params,
|
||||
bound_generic_params,
|
||||
RibKind::Normal,
|
||||
LifetimeRibKind::Generics {
|
||||
binder: bounded_ty.id,
|
||||
|
@ -1195,7 +1195,7 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
|
|||
span,
|
||||
},
|
||||
|this| {
|
||||
this.visit_generic_params(&bound_generic_params, false);
|
||||
this.visit_generic_params(bound_generic_params, false);
|
||||
this.visit_ty(bounded_ty);
|
||||
for bound in bounds {
|
||||
this.visit_param_bound(bound, BoundKind::Bound)
|
||||
|
@ -1997,7 +1997,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
|||
} else {
|
||||
LifetimeRibKind::ElisionFailure
|
||||
};
|
||||
self.with_lifetime_rib(output_rib, |this| visit::walk_fn_ret_ty(this, &output_ty));
|
||||
self.with_lifetime_rib(output_rib, |this| visit::walk_fn_ret_ty(this, output_ty));
|
||||
let elision_failures =
|
||||
replace(&mut self.diagnostic_metadata.current_elision_failures, outer_failures);
|
||||
if !elision_failures.is_empty() {
|
||||
|
@ -2379,7 +2379,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
|||
&item.attrs,
|
||||
generics,
|
||||
of_trait,
|
||||
&self_ty,
|
||||
self_ty,
|
||||
item.id,
|
||||
impl_items,
|
||||
);
|
||||
|
@ -2743,7 +2743,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
|||
/// When evaluating a `trait` use its associated types' idents for suggestions in E0412.
|
||||
fn resolve_trait_items(&mut self, trait_items: &'ast [P<AssocItem>]) {
|
||||
let trait_assoc_items =
|
||||
replace(&mut self.diagnostic_metadata.current_trait_assoc_items, Some(&trait_items));
|
||||
replace(&mut self.diagnostic_metadata.current_trait_assoc_items, Some(trait_items));
|
||||
|
||||
let walk_assoc_item =
|
||||
|this: &mut Self, generics: &Generics, kind, item: &'ast AssocItem| {
|
||||
|
@ -3945,7 +3945,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
|||
)));
|
||||
}
|
||||
|
||||
let result = match self.resolve_path(&path, Some(ns), Some(finalize)) {
|
||||
let result = match self.resolve_path(path, Some(ns), Some(finalize)) {
|
||||
PathResult::NonModule(path_res) => path_res,
|
||||
PathResult::Module(ModuleOrUniformRoot::Module(module)) if !module.is_normal() => {
|
||||
PartialRes::new(module.res().unwrap())
|
||||
|
@ -4208,7 +4208,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
|||
ExprKind::Break(None, Some(ref e)) => {
|
||||
// We use this instead of `visit::walk_expr` to keep the parent expr around for
|
||||
// better diagnostics.
|
||||
self.resolve_expr(e, Some(&expr));
|
||||
self.resolve_expr(e, Some(expr));
|
||||
}
|
||||
|
||||
ExprKind::Let(ref pat, ref scrutinee, _, _) => {
|
||||
|
@ -4229,7 +4229,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
|||
}
|
||||
|
||||
ExprKind::Loop(ref block, label, _) => {
|
||||
self.resolve_labeled_block(label, expr.id, &block)
|
||||
self.resolve_labeled_block(label, expr.id, block)
|
||||
}
|
||||
|
||||
ExprKind::While(ref cond, ref block, label) => {
|
||||
|
@ -4318,7 +4318,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
|||
..
|
||||
}) => {
|
||||
self.with_generic_param_rib(
|
||||
&generic_params,
|
||||
generic_params,
|
||||
RibKind::Normal,
|
||||
LifetimeRibKind::Generics {
|
||||
binder: expr.id,
|
||||
|
|
|
@ -906,7 +906,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
}
|
||||
|
||||
// If the trait has a single item (which wasn't matched by the algorithm), suggest it
|
||||
let suggestion = self.get_single_associated_item(&path, &source, is_expected);
|
||||
let suggestion = self.get_single_associated_item(path, &source, is_expected);
|
||||
if !self.r.add_typo_suggestion(err, suggestion, ident_span) {
|
||||
fallback = !self.let_binding_suggestion(err, ident_span);
|
||||
}
|
||||
|
@ -1397,7 +1397,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
match source {
|
||||
PathSource::Expr(Some(
|
||||
parent @ Expr { kind: ExprKind::Field(..) | ExprKind::MethodCall(..), .. },
|
||||
)) if path_sep(this, err, &parent, DefKind::Struct) => {}
|
||||
)) if path_sep(this, err, parent, DefKind::Struct) => {}
|
||||
PathSource::Expr(
|
||||
None
|
||||
| Some(Expr {
|
||||
|
@ -1556,7 +1556,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||
Res::Def(kind @ (DefKind::Mod | DefKind::Trait), _),
|
||||
PathSource::Expr(Some(parent)),
|
||||
) => {
|
||||
if !path_sep(self, err, &parent, kind) {
|
||||
if !path_sep(self, err, parent, kind) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -371,7 +371,7 @@ impl<'a, 'tcx> ResolverExpand for Resolver<'a, 'tcx> {
|
|||
if opt_ext.is_none() {
|
||||
*opt_ext = Some(
|
||||
match self.resolve_macro_path(
|
||||
&path,
|
||||
path,
|
||||
Some(MacroKind::Derive),
|
||||
&parent_scope,
|
||||
true,
|
||||
|
@ -485,7 +485,7 @@ impl<'a, 'tcx> ResolverExpand for Resolver<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn registered_tools(&self) -> &RegisteredTools {
|
||||
&self.registered_tools
|
||||
self.registered_tools
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -887,7 +887,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
if let Some(depr) = &ext.deprecation {
|
||||
let path = pprust::path_to_string(&path);
|
||||
let path = pprust::path_to_string(path);
|
||||
let (message, lint) = stability::deprecation_message_and_lint(depr, "macro", &path);
|
||||
stability::early_report_deprecation(
|
||||
&mut self.lint_buffer,
|
||||
|
|
|
@ -404,7 +404,7 @@ pub(crate) fn attrs_to_preprocessed_links(attrs: &[ast::Attribute]) -> Vec<Box<s
|
|||
fn parse_links<'md>(doc: &'md str) -> Vec<Box<str>> {
|
||||
let mut broken_link_callback = |link: BrokenLink<'md>| Some((link.reference, "".into()));
|
||||
let mut event_iter = Parser::new_with_broken_link_callback(
|
||||
&doc,
|
||||
doc,
|
||||
main_body_opts(),
|
||||
Some(&mut broken_link_callback),
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue