diff options
| author | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2023-11-21 20:07:32 +0100 |
|---|---|---|
| committer | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2023-11-21 20:13:40 +0100 |
| commit | 21a870515b18e5b2b90435d0f1a6d3089b5217ae (patch) | |
| tree | 4e2c8766f7f64f8a122f38338db2614f1f909a63 /compiler/rustc_resolve | |
| parent | 0ff861096449f47956521b40e5e4e88caa7fe27c (diff) | |
| download | rust-21a870515b18e5b2b90435d0f1a6d3089b5217ae.tar.gz rust-21a870515b18e5b2b90435d0f1a6d3089b5217ae.zip | |
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.
Diffstat (limited to 'compiler/rustc_resolve')
| -rw-r--r-- | compiler/rustc_resolve/src/build_reduced_graph.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/diagnostics.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/effective_visibilities.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/imports.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/late.rs | 24 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/late/diagnostics.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/macros.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/rustdoc.rs | 2 |
8 files changed, 25 insertions, 25 deletions
diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index 0407db528af..0b1a43f3282 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -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)), diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 84225bbe39b..863834a122e 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -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, diff --git a/compiler/rustc_resolve/src/effective_visibilities.rs b/compiler/rustc_resolve/src/effective_visibilities.rs index 4477b967283..a71c50dd82f 100644 --- a/compiler/rustc_resolve/src/effective_visibilities.rs +++ b/compiler/rustc_resolve/src/effective_visibilities.rs @@ -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); diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index b34790a925e..3774ae66420 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -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}")) diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 9b7897d69e7..75a0541b89b 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -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, diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index d62d7fdcae0..4587ad14db7 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -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; } } diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index 2ff6fb424e6..7242aa890f8 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -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, diff --git a/compiler/rustc_resolve/src/rustdoc.rs b/compiler/rustc_resolve/src/rustdoc.rs index fe4b8c7f69c..f95c0acd750 100644 --- a/compiler/rustc_resolve/src/rustdoc.rs +++ b/compiler/rustc_resolve/src/rustdoc.rs @@ -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), ) |
