From 21a870515b18e5b2b90435d0f1a6d3089b5217ae Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Tue, 21 Nov 2023 20:07:32 +0100 Subject: [PATCH] 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. --- compiler/rustc_abi/src/layout.rs | 6 +- compiler/rustc_ast/src/attr/mod.rs | 2 +- compiler/rustc_ast_lowering/src/expr.rs | 8 +- compiler/rustc_ast_lowering/src/format.rs | 4 +- compiler/rustc_ast_lowering/src/index.rs | 2 +- compiler/rustc_ast_lowering/src/item.rs | 17 +-- compiler/rustc_ast_lowering/src/lib.rs | 16 ++- compiler/rustc_ast_lowering/src/path.rs | 6 +- .../rustc_ast_passes/src/ast_validation.rs | 6 +- compiler/rustc_ast_passes/src/feature_gate.rs | 6 +- compiler/rustc_ast_pretty/src/pprust/state.rs | 4 +- .../rustc_ast_pretty/src/pprust/state/item.rs | 2 +- compiler/rustc_attr/src/builtin.rs | 2 +- compiler/rustc_borrowck/src/borrow_set.rs | 6 +- .../src/diagnostics/conflict_errors.rs | 32 +++--- .../src/diagnostics/explain_borrow.rs | 2 +- .../rustc_borrowck/src/diagnostics/mod.rs | 6 +- .../src/diagnostics/move_errors.rs | 4 +- .../src/diagnostics/region_errors.rs | 6 +- .../src/diagnostics/region_name.rs | 2 +- compiler/rustc_borrowck/src/invalidation.rs | 4 +- compiler/rustc_borrowck/src/lib.rs | 18 +-- compiler/rustc_borrowck/src/nll.rs | 12 +- .../src/type_check/free_region_relations.rs | 2 +- .../src/type_check/liveness/local_use_map.rs | 2 +- .../src/type_check/liveness/mod.rs | 4 +- .../src/type_check/liveness/polonius.rs | 2 +- .../src/type_check/liveness/trace.rs | 10 +- compiler/rustc_borrowck/src/type_check/mod.rs | 34 +++--- compiler/rustc_borrowck/src/used_muts.rs | 2 +- .../src/cfg_accessible.rs | 2 +- compiler/rustc_builtin_macros/src/cfg_eval.rs | 28 ++--- .../rustc_builtin_macros/src/cmdline_attrs.rs | 2 +- .../rustc_builtin_macros/src/concat_bytes.rs | 2 +- compiler/rustc_builtin_macros/src/derive.rs | 6 +- .../src/deriving/generic/mod.rs | 6 +- .../src/deriving/generic/ty.rs | 2 +- compiler/rustc_builtin_macros/src/format.rs | 5 +- .../rustc_builtin_macros/src/source_util.rs | 4 +- compiler/rustc_builtin_macros/src/test.rs | 10 +- .../rustc_builtin_macros/src/test_harness.rs | 4 +- compiler/rustc_builtin_macros/src/util.rs | 2 +- compiler/rustc_codegen_llvm/src/abi.rs | 2 +- compiler/rustc_codegen_llvm/src/allocator.rs | 2 +- compiler/rustc_codegen_llvm/src/attributes.rs | 4 +- .../rustc_codegen_llvm/src/back/archive.rs | 2 +- compiler/rustc_codegen_llvm/src/back/write.rs | 4 +- compiler/rustc_codegen_llvm/src/callee.rs | 2 +- compiler/rustc_codegen_llvm/src/consts.rs | 2 +- .../src/coverageinfo/mapgen.rs | 2 +- .../src/debuginfo/metadata.rs | 2 +- .../src/debuginfo/metadata/enums/cpp_like.rs | 2 +- .../src/debuginfo/metadata/enums/native.rs | 2 +- compiler/rustc_codegen_llvm/src/llvm_util.rs | 3 +- .../src/assert_module_sources.rs | 2 +- .../rustc_codegen_ssa/src/back/archive.rs | 3 +- compiler/rustc_codegen_ssa/src/back/link.rs | 34 +++--- compiler/rustc_codegen_ssa/src/back/linker.rs | 8 +- .../src/back/symbol_export.rs | 2 +- compiler/rustc_codegen_ssa/src/back/write.rs | 6 +- compiler/rustc_codegen_ssa/src/base.rs | 13 +-- .../rustc_codegen_ssa/src/codegen_attrs.rs | 8 +- .../src/debuginfo/type_names.rs | 2 +- compiler/rustc_codegen_ssa/src/mir/analyze.rs | 4 +- compiler/rustc_codegen_ssa/src/mir/block.rs | 43 ++++--- .../rustc_codegen_ssa/src/mir/debuginfo.rs | 4 +- compiler/rustc_codegen_ssa/src/mir/mod.rs | 6 +- compiler/rustc_codegen_ssa/src/mir/rvalue.rs | 2 +- compiler/rustc_codegen_ssa/src/mono_item.rs | 8 +- .../src/const_eval/eval_queries.rs | 2 +- .../src/const_eval/machine.rs | 2 +- .../src/const_eval/valtrees.rs | 2 +- .../rustc_const_eval/src/interpret/cast.rs | 2 +- .../rustc_const_eval/src/interpret/intern.rs | 2 +- .../src/interpret/intrinsics.rs | 4 +- .../src/interpret/operator.rs | 2 +- .../rustc_const_eval/src/interpret/place.rs | 4 +- .../src/interpret/terminator.rs | 6 +- .../src/interpret/validity.rs | 2 +- .../rustc_const_eval/src/interpret/visitor.rs | 4 +- .../src/transform/check_consts/check.rs | 18 +-- .../src/transform/check_consts/mod.rs | 2 +- .../src/transform/check_consts/ops.rs | 2 +- .../check_consts/post_drop_elaboration.rs | 2 +- .../src/transform/promote_consts.rs | 6 +- compiler/rustc_data_structures/src/sharded.rs | 4 +- .../src/annotate_snippet_emitter_writer.rs | 4 +- compiler/rustc_errors/src/emitter.rs | 8 +- compiler/rustc_expand/src/base.rs | 12 +- compiler/rustc_expand/src/config.rs | 4 +- compiler/rustc_expand/src/expand.rs | 16 +-- compiler/rustc_expand/src/mbe/macro_check.rs | 2 +- compiler/rustc_expand/src/mbe/macro_parser.rs | 2 +- compiler/rustc_expand/src/mbe/macro_rules.rs | 10 +- compiler/rustc_expand/src/mbe/quoted.rs | 12 +- compiler/rustc_expand/src/mbe/transcribe.rs | 8 +- compiler/rustc_expand/src/module.rs | 4 +- .../rustc_expand/src/proc_macro_server.rs | 2 +- .../rustc_hir_analysis/src/astconv/errors.rs | 2 +- .../rustc_hir_analysis/src/astconv/lint.rs | 4 +- .../rustc_hir_analysis/src/astconv/mod.rs | 4 +- compiler/rustc_hir_analysis/src/autoderef.rs | 2 +- .../rustc_hir_analysis/src/check/check.rs | 12 +- .../src/check/compare_impl_item.rs | 4 +- .../src/check/intrinsicck.rs | 12 +- .../rustc_hir_analysis/src/check/region.rs | 36 +++--- .../rustc_hir_analysis/src/check/wfcheck.rs | 8 +- .../src/coherence/orphan.rs | 2 +- compiler/rustc_hir_analysis/src/collect.rs | 6 +- .../src/collect/generics_of.rs | 6 +- .../src/collect/predicates_of.rs | 6 +- .../src/collect/resolve_bound_vars.rs | 12 +- compiler/rustc_hir_pretty/src/lib.rs | 38 +++---- compiler/rustc_hir_typeck/src/_match.rs | 6 +- compiler/rustc_hir_typeck/src/callee.rs | 2 +- compiler/rustc_hir_typeck/src/cast.rs | 4 +- compiler/rustc_hir_typeck/src/check.rs | 8 +- compiler/rustc_hir_typeck/src/closure.rs | 6 +- compiler/rustc_hir_typeck/src/coercion.rs | 12 +- compiler/rustc_hir_typeck/src/demand.rs | 2 +- compiler/rustc_hir_typeck/src/expr.rs | 76 ++++++------- .../rustc_hir_typeck/src/expr_use_visitor.rs | 20 ++-- .../rustc_hir_typeck/src/fn_ctxt/_impl.rs | 12 +- .../src/fn_ctxt/adjust_fulfillment_errors.rs | 2 +- .../rustc_hir_typeck/src/fn_ctxt/checks.rs | 22 ++-- compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs | 4 +- .../src/fn_ctxt/suggestions.rs | 26 ++--- .../rustc_hir_typeck/src/gather_locals.rs | 2 +- compiler/rustc_hir_typeck/src/lib.rs | 2 +- .../src/mem_categorization.rs | 14 +-- .../rustc_hir_typeck/src/method/confirm.rs | 12 +- compiler/rustc_hir_typeck/src/method/probe.rs | 4 +- .../rustc_hir_typeck/src/method/suggest.rs | 20 ++-- compiler/rustc_hir_typeck/src/pat.rs | 2 +- compiler/rustc_hir_typeck/src/place_op.rs | 6 +- .../rustc_incremental/src/assert_dep_graph.rs | 8 +- .../src/persist/dirty_clean.rs | 6 +- compiler/rustc_incremental/src/persist/fs.rs | 8 +- .../rustc_incremental/src/persist/load.rs | 2 +- .../src/persist/work_product.rs | 2 +- .../src/infer/canonical/query_response.rs | 2 +- .../src/infer/error_reporting/mod.rs | 10 +- .../infer/error_reporting/need_type_info.rs | 2 +- .../nice_region_error/find_anon_type.rs | 2 +- .../mismatched_static_lifetime.rs | 2 +- .../nice_region_error/static_impl_trait.rs | 6 +- .../src/infer/error_reporting/note.rs | 2 +- .../src/infer/error_reporting/suggest.rs | 6 +- .../rustc_infer/src/infer/opaque_types.rs | 8 +- .../src/infer/outlives/components.rs | 4 +- .../src/infer/outlives/obligations.rs | 4 +- .../infer/region_constraints/leak_check.rs | 2 +- compiler/rustc_interface/src/passes.rs | 20 ++-- compiler/rustc_interface/src/queries.rs | 2 +- compiler/rustc_lint/src/builtin.rs | 34 +++--- compiler/rustc_lint/src/context.rs | 20 ++-- compiler/rustc_lint/src/early.rs | 2 +- compiler/rustc_lint/src/expect.rs | 2 +- .../src/for_loops_over_fallibles.rs | 2 +- compiler/rustc_lint/src/internal.rs | 2 +- compiler/rustc_lint/src/late.rs | 12 +- compiler/rustc_lint/src/levels.rs | 16 +-- compiler/rustc_lint/src/lints.rs | 2 +- compiler/rustc_lint/src/non_ascii_idents.rs | 2 +- compiler/rustc_lint/src/nonstandard_style.rs | 6 +- .../src/opaque_hidden_inferred_bound.rs | 2 +- compiler/rustc_lint/src/pass_by_value.rs | 2 +- compiler/rustc_lint/src/types.rs | 26 ++--- compiler/rustc_lint/src/unused.rs | 16 +-- compiler/rustc_metadata/src/creader.rs | 6 +- compiler/rustc_metadata/src/fs.rs | 2 +- compiler/rustc_metadata/src/locator.rs | 2 +- .../src/rmeta/decoder/cstore_impl.rs | 2 +- compiler/rustc_metadata/src/rmeta/encoder.rs | 22 ++-- compiler/rustc_metadata/src/rmeta/table.rs | 4 +- compiler/rustc_middle/src/hir/map/mod.rs | 12 +- compiler/rustc_middle/src/middle/region.rs | 2 +- compiler/rustc_middle/src/mir/consts.rs | 2 +- compiler/rustc_middle/src/mir/mod.rs | 2 +- compiler/rustc_middle/src/mir/spanview.rs | 6 +- compiler/rustc_middle/src/mir/statement.rs | 2 +- compiler/rustc_middle/src/mir/tcx.rs | 6 +- .../rustc_middle/src/query/on_disk_cache.rs | 11 +- compiler/rustc_middle/src/thir/visit.rs | 4 +- compiler/rustc_middle/src/traits/mod.rs | 2 +- compiler/rustc_middle/src/ty/adt.rs | 4 +- compiler/rustc_middle/src/ty/codec.rs | 2 +- compiler/rustc_middle/src/ty/consts.rs | 8 +- compiler/rustc_middle/src/ty/error.rs | 4 +- compiler/rustc_middle/src/ty/generic_args.rs | 2 +- compiler/rustc_middle/src/ty/generics.rs | 2 +- compiler/rustc_middle/src/ty/impls_ty.rs | 2 +- compiler/rustc_middle/src/ty/layout.rs | 4 +- compiler/rustc_middle/src/ty/mod.rs | 8 +- compiler/rustc_middle/src/ty/print/mod.rs | 2 +- compiler/rustc_middle/src/ty/print/pretty.rs | 16 +-- compiler/rustc_middle/src/ty/relate.rs | 2 +- compiler/rustc_middle/src/ty/sty.rs | 8 +- .../rustc_middle/src/ty/typeck_results.rs | 2 +- compiler/rustc_mir_build/src/build/block.rs | 6 +- .../rustc_mir_build/src/build/custom/mod.rs | 2 +- .../src/build/expr/as_place.rs | 4 +- .../rustc_mir_build/src/build/matches/mod.rs | 14 +-- .../src/build/matches/simplify.rs | 2 +- .../rustc_mir_build/src/build/matches/test.rs | 2 +- compiler/rustc_mir_build/src/build/mod.rs | 6 +- compiler/rustc_mir_build/src/build/scope.rs | 2 +- .../rustc_mir_build/src/check_unsafety.rs | 2 +- compiler/rustc_mir_build/src/thir/cx/block.rs | 4 +- compiler/rustc_mir_build/src/thir/cx/expr.rs | 89 +++++++-------- compiler/rustc_mir_build/src/thir/cx/mod.rs | 4 +- .../src/thir/pattern/check_match.rs | 2 +- .../src/thir/pattern/deconstruct_pat.rs | 6 +- .../rustc_mir_build/src/thir/pattern/mod.rs | 16 +-- .../src/thir/pattern/usefulness.rs | 4 +- .../rustc_mir_dataflow/src/elaborate_drops.rs | 14 +-- .../src/framework/direction.rs | 2 +- .../src/framework/engine.rs | 2 +- .../src/framework/lattice.rs | 2 +- .../src/impls/initialized.rs | 4 +- compiler/rustc_mir_dataflow/src/rustc_peek.rs | 2 +- .../src/check_const_item_mutation.rs | 11 +- .../src/check_packed_ref.rs | 2 +- .../rustc_mir_transform/src/check_unsafety.rs | 2 +- .../rustc_mir_transform/src/const_prop.rs | 2 +- .../src/const_prop_lint.rs | 4 +- compiler/rustc_mir_transform/src/copy_prop.rs | 4 +- compiler/rustc_mir_transform/src/coroutine.rs | 16 +-- .../src/coverage/counters.rs | 6 +- .../rustc_mir_transform/src/coverage/graph.rs | 2 +- .../rustc_mir_transform/src/coverage/mod.rs | 4 +- .../rustc_mir_transform/src/ctfe_limit.rs | 2 +- .../src/dataflow_const_prop.rs | 2 +- .../src/elaborate_drops.rs | 4 +- .../src/function_item_references.rs | 6 +- compiler/rustc_mir_transform/src/inline.rs | 2 +- .../rustc_mir_transform/src/instsimplify.rs | 7 +- .../rustc_mir_transform/src/jump_threading.rs | 4 +- compiler/rustc_mir_transform/src/lib.rs | 4 +- .../rustc_mir_transform/src/pass_manager.rs | 6 +- .../src/remove_uninit_drops.rs | 2 +- compiler/rustc_mir_transform/src/simplify.rs | 2 +- compiler/rustc_mir_transform/src/sroa.rs | 2 +- .../src/uninhabited_enum_branching.rs | 2 +- compiler/rustc_monomorphize/src/collector.rs | 14 +-- .../rustc_monomorphize/src/partitioning.rs | 6 +- compiler/rustc_parse/src/lexer/mod.rs | 6 +- compiler/rustc_parse/src/lexer/tokentrees.rs | 6 +- .../rustc_parse/src/parser/diagnostics.rs | 8 +- compiler/rustc_parse/src/parser/expr.rs | 12 +- compiler/rustc_parse/src/parser/item.rs | 2 +- compiler/rustc_parse/src/parser/pat.rs | 4 +- compiler/rustc_parse/src/validate_attr.rs | 2 +- compiler/rustc_passes/src/check_attr.rs | 52 ++++----- compiler/rustc_passes/src/check_const.rs | 2 +- compiler/rustc_passes/src/dead.rs | 16 +-- compiler/rustc_passes/src/entry.rs | 2 +- compiler/rustc_passes/src/lang_items.rs | 2 +- compiler/rustc_passes/src/liveness.rs | 106 +++++++++--------- compiler/rustc_passes/src/loops.rs | 12 +- compiler/rustc_passes/src/naked_functions.rs | 6 +- compiler/rustc_passes/src/stability.rs | 10 +- compiler/rustc_privacy/src/lib.rs | 8 +- compiler/rustc_query_impl/src/plumbing.rs | 2 +- .../rustc_query_system/src/dep_graph/graph.rs | 2 +- .../rustc_query_system/src/query/plumbing.rs | 10 +- .../rustc_resolve/src/build_reduced_graph.rs | 2 +- compiler/rustc_resolve/src/diagnostics.rs | 4 +- .../src/effective_visibilities.rs | 2 +- compiler/rustc_resolve/src/imports.rs | 4 +- compiler/rustc_resolve/src/late.rs | 24 ++-- .../rustc_resolve/src/late/diagnostics.rs | 6 +- compiler/rustc_resolve/src/macros.rs | 6 +- compiler/rustc_resolve/src/rustdoc.rs | 2 +- compiler/rustc_session/src/config.rs | 2 +- compiler/rustc_session/src/session.rs | 2 +- .../rustc_smir/src/rustc_internal/internal.rs | 4 +- .../src/typeid/typeid_itanium_cxx_abi.rs | 6 +- .../src/solve/assembly/mod.rs | 2 +- .../src/solve/assembly/structural_traits.rs | 6 +- .../src/solve/inspect/analyse.rs | 2 +- .../src/traits/auto_trait.rs | 2 +- .../src/traits/engine.rs | 4 +- .../traits/error_reporting/infer_ctxt_ext.rs | 7 +- .../error_reporting/on_unimplemented.rs | 4 +- .../src/traits/error_reporting/suggestions.rs | 36 +++--- .../error_reporting/type_err_ctxt_ext.rs | 18 +-- .../src/traits/object_safety.rs | 2 +- .../src/traits/project.rs | 10 +- .../src/traits/query/dropck_outlives.rs | 4 +- .../src/traits/query/evaluate_obligation.rs | 2 +- .../src/traits/select/candidate_assembly.rs | 7 +- .../src/traits/select/confirmation.rs | 10 +- .../src/traits/select/mod.rs | 14 +-- .../src/traits/specialize/mod.rs | 31 +++-- .../rustc_trait_selection/src/traits/wf.rs | 2 +- .../rustc_traits/src/evaluate_obligation.rs | 2 +- compiler/rustc_ty_utils/src/assoc.rs | 8 +- compiler/rustc_ty_utils/src/consts.rs | 2 +- compiler/rustc_ty_utils/src/layout.rs | 4 +- compiler/rustc_ty_utils/src/ty.rs | 4 +- compiler/stable_mir/src/mir/pretty.rs | 4 +- compiler/stable_mir/src/mir/visit.rs | 2 +- compiler/stable_mir/src/ty.rs | 2 +- 304 files changed, 1101 insertions(+), 1174 deletions(-) diff --git a/compiler/rustc_abi/src/layout.rs b/compiler/rustc_abi/src/layout.rs index 996fd5bbecf..815edcc0dc4 100644 --- a/compiler/rustc_abi/src/layout.rs +++ b/compiler/rustc_abi/src/layout.rs @@ -111,8 +111,8 @@ pub trait LayoutCalculator { alt_tail_space, layout.fields.count(), prefer_alt_layout, - format_field_niches(&layout, &fields, &dl), - format_field_niches(&alt_layout, &fields, &dl), + format_field_niches(layout, fields, dl), + format_field_niches(&alt_layout, fields, dl), ); if prefer_alt_layout { @@ -1025,7 +1025,7 @@ fn univariant< // At the bottom of this function, we invert `inverse_memory_index` to // produce `memory_index` (see `invert_mapping`). let mut sized = true; - let mut offsets = IndexVec::from_elem(Size::ZERO, &fields); + let mut offsets = IndexVec::from_elem(Size::ZERO, fields); let mut offset = Size::ZERO; let mut largest_niche = None; let mut largest_niche_available = 0; diff --git a/compiler/rustc_ast/src/attr/mod.rs b/compiler/rustc_ast/src/attr/mod.rs index 152ef4bcbfd..851ab46345f 100644 --- a/compiler/rustc_ast/src/attr/mod.rs +++ b/compiler/rustc_ast/src/attr/mod.rs @@ -391,7 +391,7 @@ impl MetaItemKind { MetaItemKind::name_value_from_tokens(&mut inner_tokens.trees()) } Some(TokenTree::Token(token, _)) => { - MetaItemLit::from_token(&token).map(MetaItemKind::NameValue) + MetaItemLit::from_token(token).map(MetaItemKind::NameValue) } _ => None, } diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 2c13e1523f1..d44c585a07d 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -959,7 +959,7 @@ impl<'hir> LoweringContext<'_, 'hir> { e }); let coroutine_option = - this.coroutine_movability_for_fn(&decl, fn_decl_span, coroutine_kind, movability); + this.coroutine_movability_for_fn(decl, fn_decl_span, coroutine_kind, movability); this.current_item = prev; (body_id, coroutine_option) }); @@ -1057,7 +1057,7 @@ impl<'hir> LoweringContext<'_, 'hir> { let body_id = this.lower_fn_body(&outer_decl, |this| { let async_ret_ty = if let FnRetTy::Ty(ty) = &decl.output { let itctx = ImplTraitContext::Disallowed(ImplTraitPosition::AsyncBlock); - Some(hir::FnRetTy::Return(this.lower_ty(&ty, &itctx))) + Some(hir::FnRetTy::Return(this.lower_ty(ty, &itctx))) } else { None }; @@ -1156,7 +1156,7 @@ impl<'hir> LoweringContext<'_, 'hir> { .alloc_from_iter(std::iter::once(destructure_let).chain(assignments.into_iter())); // Wrap everything in a block. - hir::ExprKind::Block(&self.block_all(whole_span, stmts, None), None) + hir::ExprKind::Block(self.block_all(whole_span, stmts, None), None) } /// If the given expression is a path to a tuple struct, returns that path. @@ -1413,7 +1413,7 @@ impl<'hir> LoweringContext<'_, 'hir> { let fields = self.arena.alloc_from_iter( e1.iter().map(|e| (sym::start, e)).chain(e2.iter().map(|e| (sym::end, e))).map( |(s, e)| { - let expr = self.lower_expr(&e); + let expr = self.lower_expr(e); let ident = Ident::new(s, self.lower_span(e.span)); self.expr_field(ident, expr, e.span) }, diff --git a/compiler/rustc_ast_lowering/src/format.rs b/compiler/rustc_ast_lowering/src/format.rs index c7d0719e71a..b6202be4f52 100644 --- a/compiler/rustc_ast_lowering/src/format.rs +++ b/compiler/rustc_ast_lowering/src/format.rs @@ -338,8 +338,8 @@ fn make_format_spec<'hir>( | ((debug_hex == Some(FormatDebugHex::Lower)) as u32) << 4 | ((debug_hex == Some(FormatDebugHex::Upper)) as u32) << 5; let flags = ctx.expr_u32(sp, flags); - let precision = make_count(ctx, sp, &precision, argmap); - let width = make_count(ctx, sp, &width, argmap); + let precision = make_count(ctx, sp, precision, argmap); + let width = make_count(ctx, sp, width, argmap); let format_placeholder_new = ctx.arena.alloc(ctx.expr_lang_item_type_relative( sp, hir::LangItem::FormatPlaceholder, diff --git a/compiler/rustc_ast_lowering/src/index.rs b/compiler/rustc_ast_lowering/src/index.rs index eff362f3ff0..33e15d386c8 100644 --- a/compiler/rustc_ast_lowering/src/index.rs +++ b/compiler/rustc_ast_lowering/src/index.rs @@ -47,7 +47,7 @@ pub(super) fn index_hir<'hir>( match item { OwnerNode::Crate(citem) => { - collector.visit_mod(&citem, citem.spans.inner_span, hir::CRATE_HIR_ID) + collector.visit_mod(citem, citem.spans.inner_span, hir::CRATE_HIR_ID) } OwnerNode::Item(item) => collector.visit_item(item), OwnerNode::TraitItem(item) => collector.visit_trait_item(item), diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index 9a70e6d7c4a..c4c08096b8b 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -276,19 +276,14 @@ impl<'hir> LoweringContext<'_, 'hir> { // only cares about the input argument patterns in the function // declaration (decl), not the return types. let asyncness = header.asyncness; - let body_id = this.lower_maybe_async_body( - span, - hir_id, - &decl, - asyncness, - body.as_deref(), - ); + let body_id = + this.lower_maybe_async_body(span, hir_id, decl, asyncness, body.as_deref()); let itctx = ImplTraitContext::Universal; let (generics, decl) = this.lower_generics(generics, header.constness, id, &itctx, |this| { let ret_id = asyncness.opt_return_id(); - this.lower_fn_decl(&decl, id, *fn_sig_span, FnDeclKind::Fn, ret_id) + this.lower_fn_decl(decl, id, *fn_sig_span, FnDeclKind::Fn, ret_id) }); let sig = hir::FnSig { decl, @@ -744,7 +739,7 @@ impl<'hir> LoweringContext<'_, 'hir> { let (generics, kind, has_default) = match &i.kind { AssocItemKind::Const(box ConstItem { generics, ty, expr, .. }) => { let (generics, kind) = self.lower_generics( - &generics, + generics, Const::No, i.id, &ImplTraitContext::Disallowed(ImplTraitPosition::Generic), @@ -775,7 +770,7 @@ impl<'hir> LoweringContext<'_, 'hir> { AssocItemKind::Fn(box Fn { sig, generics, body: Some(body), .. }) => { let asyncness = sig.header.asyncness; let body_id = - self.lower_maybe_async_body(i.span, hir_id, &sig.decl, asyncness, Some(&body)); + self.lower_maybe_async_body(i.span, hir_id, &sig.decl, asyncness, Some(body)); let (generics, sig) = self.lower_method_sig( generics, sig, @@ -857,7 +852,7 @@ impl<'hir> LoweringContext<'_, 'hir> { let (generics, kind) = match &i.kind { AssocItemKind::Const(box ConstItem { generics, ty, expr, .. }) => self.lower_generics( - &generics, + generics, Const::No, i.id, &ImplTraitContext::Disallowed(ImplTraitPosition::Generic), diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 3db9d0b31e0..e9554f10776 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -1157,7 +1157,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { itctx: &ImplTraitContext, ) -> hir::GenericArg<'hir> { match arg { - ast::GenericArg::Lifetime(lt) => GenericArg::Lifetime(self.lower_lifetime(<)), + ast::GenericArg::Lifetime(lt) => GenericArg::Lifetime(self.lower_lifetime(lt)), ast::GenericArg::Type(ty) => { match &ty.kind { TyKind::Infer if self.tcx.features().generic_arg_infer => { @@ -1221,10 +1221,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { } _ => {} } - GenericArg::Type(self.lower_ty(&ty, itctx)) + GenericArg::Type(self.lower_ty(ty, itctx)) } ast::GenericArg::Const(ct) => GenericArg::Const(ConstArg { - value: self.lower_anon_const(&ct), + value: self.lower_anon_const(ct), span: self.lower_span(ct.value.span), is_desugared_from_effects: false, }), @@ -1267,7 +1267,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { let lifetime_bound = this.elided_dyn_bound(t.span); (bounds, lifetime_bound) }); - let kind = hir::TyKind::TraitObject(bounds, &lifetime_bound, TraitObjectSyntax::None); + let kind = hir::TyKind::TraitObject(bounds, lifetime_bound, TraitObjectSyntax::None); return hir::Ty { kind, span: self.lower_span(t.span), hir_id: self.next_id() }; } @@ -1551,7 +1551,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { // in fn return position, like the `fn test<'a>() -> impl Debug + 'a` // example, we only need to duplicate lifetimes that appear in the // bounds, since those are the only ones that are captured by the opaque. - lifetime_collector::lifetimes_in_bounds(&self.resolver, bounds) + lifetime_collector::lifetimes_in_bounds(self.resolver, bounds) } } hir::OpaqueTyOrigin::AsyncFn(..) => { @@ -2067,10 +2067,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { (hir::ParamName::Plain(self.lower_ident(param.ident)), kind) } GenericParamKind::Const { ty, kw_span: _, default } => { - let ty = self.lower_ty( - &ty, - &ImplTraitContext::Disallowed(ImplTraitPosition::GenericDefault), - ); + let ty = self + .lower_ty(ty, &ImplTraitContext::Disallowed(ImplTraitPosition::GenericDefault)); let default = default.as_ref().map(|def| self.lower_anon_const(def)); ( hir::ParamName::Plain(self.lower_ident(param.ident)), diff --git a/compiler/rustc_ast_lowering/src/path.rs b/compiler/rustc_ast_lowering/src/path.rs index 899f92a9958..8050f5826aa 100644 --- a/compiler/rustc_ast_lowering/src/path.rs +++ b/compiler/rustc_ast_lowering/src/path.rs @@ -372,10 +372,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { // ``` FnRetTy::Ty(ty) if matches!(itctx, ImplTraitContext::ReturnPositionOpaqueTy { .. }) => { if self.tcx.features().impl_trait_in_fn_trait_return { - self.lower_ty(&ty, itctx) + self.lower_ty(ty, itctx) } else { self.lower_ty( - &ty, + ty, &ImplTraitContext::FeatureGated( ImplTraitPosition::FnTraitReturn, sym::impl_trait_in_fn_trait_return, @@ -384,7 +384,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { } } FnRetTy::Ty(ty) => { - self.lower_ty(&ty, &ImplTraitContext::Disallowed(ImplTraitPosition::FnTraitReturn)) + self.lower_ty(ty, &ImplTraitContext::Disallowed(ImplTraitPosition::FnTraitReturn)) } FnRetTy::Default(_) => self.arena.alloc(self.ty_tup(*span, &[])), }; diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index f73d791db49..1a45c8eb1a5 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -221,7 +221,7 @@ impl<'a> AstValidator<'a> { } fn err_handler(&self) -> &rustc_errors::Handler { - &self.session.diagnostic() + self.session.diagnostic() } fn check_lifetime(&self, ident: Ident) { @@ -622,7 +622,7 @@ impl<'a> AstValidator<'a> { data: data.span, constraint_spans: errors::EmptyLabelManySpans(constraint_spans), arg_spans2: errors::EmptyLabelManySpans(arg_spans), - suggestion: self.correct_generic_order_suggestion(&data), + suggestion: self.correct_generic_order_suggestion(data), constraint_len, args_len, }); @@ -738,7 +738,7 @@ fn validate_generic_param_order( if !bounds.is_empty() { ordered_params += ": "; - ordered_params += &pprust::bounds_to_string(&bounds); + ordered_params += &pprust::bounds_to_string(bounds); } match kind { diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index e1cf0a2589d..8fb7c7de50c 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -88,7 +88,7 @@ impl<'a> PostExpansionVisitor<'a> { } } - match abi::is_enabled(&self.features, span, symbol_unescaped.as_str()) { + match abi::is_enabled(self.features, span, symbol_unescaped.as_str()) { Ok(()) => (), Err(abi::AbiDisabled::Unstable { feature, explain }) => { feature_err_issue( @@ -182,7 +182,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { .. }) = attr_info { - gate_alt!(self, has_feature(&self.features), *name, attr.span, *descr); + gate_alt!(self, has_feature(self.features), *name, attr.span, *descr); } // Check unstable flavors of the `#[doc]` attribute. if attr.has_name(sym::doc) { @@ -300,7 +300,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } ast::ItemKind::TyAlias(box ast::TyAlias { ty: Some(ty), .. }) => { - self.check_impl_trait(&ty, false) + self.check_impl_trait(ty, false) } _ => {} diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index 0962cb1b8d4..e486ab8e3b8 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -1078,11 +1078,11 @@ impl<'a> State<'a> { } ast::TyKind::AnonStruct(fields) => { self.head("struct"); - self.print_record_struct_body(&fields, ty.span); + self.print_record_struct_body(fields, ty.span); } ast::TyKind::AnonUnion(fields) => { self.head("union"); - self.print_record_struct_body(&fields, ty.span); + self.print_record_struct_body(fields, ty.span); } ast::TyKind::Paren(typ) => { self.popen(); diff --git a/compiler/rustc_ast_pretty/src/pprust/state/item.rs b/compiler/rustc_ast_pretty/src/pprust/state/item.rs index 3393f034bc3..e94bfd81658 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/item.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/item.rs @@ -368,7 +368,7 @@ impl<'a> State<'a> { self.nbsp(); if !bounds.is_empty() { self.word_nbsp("="); - self.print_type_bounds(&bounds); + self.print_type_bounds(bounds); } self.print_where_clause(&generics.where_clause); self.word(";"); diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index ad92d585510..7e87d1c3130 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -552,7 +552,7 @@ pub fn cfg_matches( fn try_gate_cfg(name: Symbol, span: Span, sess: &ParseSess, features: Option<&Features>) { let gate = find_gated_cfg(|sym| sym == name); if let (Some(feats), Some(gated_cfg)) = (features, gate) { - gate_cfg(&gated_cfg, span, sess, feats); + gate_cfg(gated_cfg, span, sess, feats); } } diff --git a/compiler/rustc_borrowck/src/borrow_set.rs b/compiler/rustc_borrowck/src/borrow_set.rs index 5248a649c34..948af039537 100644 --- a/compiler/rustc_borrowck/src/borrow_set.rs +++ b/compiler/rustc_borrowck/src/borrow_set.rs @@ -107,7 +107,7 @@ impl LocalsStateAtExit { LocalsStateAtExit::AllAreInvalidated } else { let mut has_storage_dead = HasStorageDead(BitSet::new_empty(body.local_decls.len())); - has_storage_dead.visit_body(&body); + has_storage_dead.visit_body(body); let mut has_storage_dead_or_moved = has_storage_dead.0; for move_out in &move_data.moves { if let Some(index) = move_data.base_local(move_out.path) { @@ -128,7 +128,7 @@ impl<'tcx> BorrowSet<'tcx> { ) -> Self { let mut visitor = GatherBorrows { tcx, - body: &body, + body: body, location_map: Default::default(), activation_map: Default::default(), local_map: Default::default(), @@ -140,7 +140,7 @@ impl<'tcx> BorrowSet<'tcx> { ), }; - for (block, block_data) in traversal::preorder(&body) { + for (block, block_data) in traversal::preorder(body) { visitor.visit_basic_block_data(block, block_data); } diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 875a71145fa..a09b24d3422 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -490,7 +490,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let mut spans = vec![]; for init_idx in inits { let init = &self.move_data.inits[*init_idx]; - let span = init.span(&self.body); + let span = init.span(self.body); if !span.is_dummy() { spans.push(span); } @@ -518,7 +518,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let body = map.body(body_id); let mut visitor = ConditionVisitor { spans: &spans, name: &name, errors: vec![] }; - visitor.visit_body(&body); + visitor.visit_body(body); let mut show_assign_sugg = false; let isnt_initialized = if let InitializationRequiringAction::PartialAssignment @@ -614,7 +614,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } let mut visitor = LetVisitor { decl_span, sugg_span: None }; - visitor.visit_body(&body); + visitor.visit_body(body); if let Some(span) = visitor.sugg_span { self.suggest_assign_value(&mut err, moved_place, span); } @@ -779,7 +779,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { return; }; // Try to find predicates on *generic params* that would allow copying `ty` - let ocx = ObligationCtxt::new(&self.infcx); + let ocx = ObligationCtxt::new(self.infcx); let copy_did = tcx.require_lang_item(LangItem::Copy, Some(span)); let cause = ObligationCause::misc(span, self.mir_def_id()); @@ -856,7 +856,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { self.explain_why_borrow_contains_point(location, borrow, None) .add_explanation_to_diagnostic( self.infcx.tcx, - &self.body, + self.body, &self.local_names, &mut err, "", @@ -903,7 +903,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { self.explain_why_borrow_contains_point(location, borrow, None) .add_explanation_to_diagnostic( self.infcx.tcx, - &self.body, + self.body, &self.local_names, &mut err, "", @@ -1174,7 +1174,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { explanation.add_explanation_to_diagnostic( self.infcx.tcx, - &self.body, + self.body, &self.local_names, &mut err, first_borrow_desc, @@ -1932,7 +1932,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let place_desc = self.describe_place(borrow.borrowed_place.as_ref()); let kind_place = kind.filter(|_| place_desc.is_some()).map(|k| (k, place_span.0)); - let explanation = self.explain_why_borrow_contains_point(location, &borrow, kind_place); + let explanation = self.explain_why_borrow_contains_point(location, borrow, kind_place); debug!(?place_desc, ?explanation); @@ -2001,14 +2001,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { (Some(name), explanation) => self.report_local_value_does_not_live_long_enough( location, &name, - &borrow, + borrow, drop_span, borrow_spans, explanation, ), (None, explanation) => self.report_temporary_value_does_not_live_long_enough( location, - &borrow, + borrow, drop_span, borrow_spans, proper_span, @@ -2098,7 +2098,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } else { explanation.add_explanation_to_diagnostic( self.infcx.tcx, - &self.body, + self.body, &self.local_names, &mut err, "", @@ -2119,7 +2119,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { explanation.add_explanation_to_diagnostic( self.infcx.tcx, - &self.body, + self.body, &self.local_names, &mut err, "", @@ -2180,7 +2180,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { explanation.add_explanation_to_diagnostic( self.infcx.tcx, - &self.body, + self.body, &self.local_names, &mut err, "", @@ -2365,7 +2365,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } explanation.add_explanation_to_diagnostic( self.infcx.tcx, - &self.body, + self.body, &self.local_names, &mut err, "", @@ -2842,7 +2842,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { self.explain_why_borrow_contains_point(location, loan, None).add_explanation_to_diagnostic( self.infcx.tcx, - &self.body, + self.body, &self.local_names, &mut err, "", @@ -3020,7 +3020,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } } let mut visitor = FakeReadCauseFinder { place, cause: None }; - visitor.visit_body(&self.body); + visitor.visit_body(self.body); match visitor.cause { Some(FakeReadCause::ForMatchGuard) => Some("match guard"), Some(FakeReadCause::ForIndex) => Some("indexing expression"), diff --git a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs index 78e9e104bda..bed3df4809d 100644 --- a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs +++ b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs @@ -422,7 +422,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { kind_place: Option<(WriteKind, Place<'tcx>)>, ) -> BorrowExplanation<'tcx> { let regioncx = &self.regioncx; - let body: &Body<'_> = &self.body; + let body: &Body<'_> = self.body; let tcx = self.infcx.tcx; let borrow_region_vid = borrow.region; diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index c85b2f0a9d7..fca3d695935 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -354,7 +354,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { ty::Adt(def, _) => { let variant = if let Some(idx) = variant_index { assert!(def.is_enum()); - &def.variant(idx) + def.variant(idx) } else { def.non_enum_variant() }; @@ -851,7 +851,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { { let Some((method_did, method_args)) = rustc_middle::util::find_self_call( self.infcx.tcx, - &self.body, + self.body, target_temp, location.block, ) else { @@ -1048,7 +1048,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let ty = moved_place.ty(self.body, tcx).ty; let suggest = match tcx.get_diagnostic_item(sym::IntoIterator) { Some(def_id) => type_known_to_meet_bound_modulo_regions( - &self.infcx, + self.infcx, self.param_env, Ty::new_imm_ref(tcx, tcx.lifetimes.re_erased, ty), def_id, diff --git a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs index aec1cd504c1..86b761eadf5 100644 --- a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs @@ -321,7 +321,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { let deref_base = match deref_target_place.projection.as_ref() { [proj_base @ .., ProjectionElem::Deref] => { - PlaceRef { local: deref_target_place.local, projection: &proj_base } + PlaceRef { local: deref_target_place.local, projection: proj_base } } _ => bug!("deref_target_place is not a deref projection"), }; @@ -583,7 +583,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { err.subdiagnostic(crate::session_diagnostics::TypeNoCopy::Label { is_partial_move: false, ty: bind_to.ty, - place: &place_desc, + place: place_desc, span: binding_span, }); } diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index 3f702c9d9a0..759d8ef30b1 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -650,14 +650,14 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { let fr_name_and_span = self.regioncx.get_var_name_and_span_for_region( self.infcx.tcx, - &self.body, + self.body, &self.local_names, &self.upvars, errci.fr, ); let outlived_fr_name_and_span = self.regioncx.get_var_name_and_span_for_region( self.infcx.tcx, - &self.body, + self.body, &self.local_names, &self.upvars, errci.outlived_fr, @@ -971,7 +971,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { for found_did in found_dids { let mut traits = vec![]; let mut hir_v = HirTraitObjectVisitor(&mut traits, *found_did); - hir_v.visit_ty(&self_ty); + hir_v.visit_ty(self_ty); debug!("trait spans found: {:?}", traits); for span in &traits { let mut multi_span: MultiSpan = vec![*span].into(); diff --git a/compiler/rustc_borrowck/src/diagnostics/region_name.rs b/compiler/rustc_borrowck/src/diagnostics/region_name.rs index fee35485cd7..5cec966e1b5 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_name.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_name.rs @@ -387,7 +387,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { let arg_ty = self.regioncx.universal_regions().unnormalized_input_tys [implicit_inputs + argument_index]; let (_, span) = self.regioncx.get_argument_name_and_span_for_region( - &self.body, + self.body, &self.local_names, argument_index, ); diff --git a/compiler/rustc_borrowck/src/invalidation.rs b/compiler/rustc_borrowck/src/invalidation.rs index ec6d7b74e61..a3db101311f 100644 --- a/compiler/rustc_borrowck/src/invalidation.rs +++ b/compiler/rustc_borrowck/src/invalidation.rs @@ -34,7 +34,7 @@ pub(super) fn generate_invalidates<'tcx>( borrow_set, tcx, location_table, - body: &body, + body: body, dominators, }; ig.visit_body(body); @@ -383,7 +383,7 @@ impl<'cx, 'tcx> InvalidationGenerator<'cx, 'tcx> { (Read(_), BorrowKind::Mut { .. }) => { // Reading from mere reservations of mutable-borrows is OK. - if !is_active(&this.dominators, borrow, location) { + if !is_active(this.dominators, borrow, location) { // If the borrow isn't active yet, reads don't invalidate it assert!(allow_two_phase_borrow(borrow.kind)); return Control::Continue; diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index 353e4cf0829..0bfd2e7e710 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -219,18 +219,18 @@ fn do_mir_borrowck<'tcx>( let location_table_owned = LocationTable::new(body); let location_table = &location_table_owned; - let move_data = MoveData::gather_moves(&body, tcx, param_env, |_| true); + let move_data = MoveData::gather_moves(body, tcx, param_env, |_| true); let promoted_move_data = promoted .iter_enumerated() - .map(|(idx, body)| (idx, MoveData::gather_moves(&body, tcx, param_env, |_| true))); + .map(|(idx, body)| (idx, MoveData::gather_moves(body, tcx, param_env, |_| true))); let mdpe = MoveDataParamEnv { move_data, param_env }; - let mut flow_inits = MaybeInitializedPlaces::new(tcx, &body, &mdpe) - .into_engine(tcx, &body) + let mut flow_inits = MaybeInitializedPlaces::new(tcx, body, &mdpe) + .into_engine(tcx, body) .pass_name("borrowck") .iterate_to_fixpoint() - .into_results_cursor(&body); + .into_results_cursor(body); let locals_are_invalidated_at_exit = tcx.hir().body_owner_kind(def).is_fn_or_closure(); let borrow_set = @@ -260,13 +260,13 @@ fn do_mir_borrowck<'tcx>( // Dump MIR results into a file, if that is enabled. This let us // write unit-tests, as well as helping with debugging. - nll::dump_mir_results(&infcx, &body, ®ioncx, &opt_closure_req); + nll::dump_mir_results(&infcx, body, ®ioncx, &opt_closure_req); // We also have a `#[rustc_regions]` annotation that causes us to dump // information. nll::dump_annotation( &infcx, - &body, + body, ®ioncx, &opt_closure_req, &opaque_type_values, @@ -1538,7 +1538,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { if places_conflict::borrow_conflicts_with_place( self.infcx.tcx, - &self.body, + self.body, place, borrow.kind, root_place, @@ -2193,7 +2193,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // If this is a mutate access to an immutable local variable with no projections // report the error as an illegal reassignment let init = &self.move_data.inits[init_index]; - let assigned_span = init.span(&self.body); + let assigned_span = init.span(self.body); self.report_illegal_reassignment(location, (place, span), assigned_span, place); } else { self.report_mutability_error(place, span, the_place_err, error_access, location) diff --git a/compiler/rustc_borrowck/src/nll.rs b/compiler/rustc_borrowck/src/nll.rs index 0ea4401a878..08db3a62ece 100644 --- a/compiler/rustc_borrowck/src/nll.rs +++ b/compiler/rustc_borrowck/src/nll.rs @@ -179,7 +179,7 @@ pub(crate) fn compute_regions<'cx, 'tcx>( let universal_regions = Rc::new(universal_regions); - let elements = &Rc::new(RegionValueElements::new(&body)); + let elements = &Rc::new(RegionValueElements::new(body)); // Run the MIR type-checker. let MirTypeckResults { @@ -206,7 +206,7 @@ pub(crate) fn compute_regions<'cx, 'tcx>( if let Some(all_facts) = &mut all_facts { let _prof_timer = infcx.tcx.prof.generic_activity("polonius_fact_generation"); all_facts.universal_region.extend(universal_regions.universal_regions()); - populate_polonius_move_facts(all_facts, move_data, location_table, &body); + populate_polonius_move_facts(all_facts, move_data, location_table, body); // Emit universal regions facts, and their relations, for Polonius. // @@ -263,7 +263,7 @@ pub(crate) fn compute_regions<'cx, 'tcx>( &mut liveness_constraints, &mut all_facts, location_table, - &body, + body, borrow_set, ); @@ -302,7 +302,7 @@ pub(crate) fn compute_regions<'cx, 'tcx>( let algorithm = Algorithm::from_str(&algorithm).unwrap(); debug!("compute_regions: using polonius algorithm {:?}", algorithm); let _prof_timer = infcx.tcx.prof.generic_activity("polonius_analysis"); - Some(Rc::new(Output::compute(&all_facts, algorithm, false))) + Some(Rc::new(Output::compute(all_facts, algorithm, false))) } else { None } @@ -310,7 +310,7 @@ pub(crate) fn compute_regions<'cx, 'tcx>( // Solve the region constraints. let (closure_region_requirements, nll_errors) = - regioncx.solve(infcx, param_env, &body, polonius_output.clone()); + regioncx.solve(infcx, param_env, body, polonius_output.clone()); if !nll_errors.is_empty() { // Suppress unhelpful extra errors in `infer_opaque_types`. @@ -320,7 +320,7 @@ pub(crate) fn compute_regions<'cx, 'tcx>( )); } - let remapped_opaque_tys = regioncx.infer_opaque_types(&infcx, opaque_type_values); + let remapped_opaque_tys = regioncx.infer_opaque_types(infcx, opaque_type_values); NllOutput { regioncx, diff --git a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs index 478eedc26d3..4a76d877af0 100644 --- a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs +++ b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs @@ -303,7 +303,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> { Locations::All(span), span, ConstraintCategory::Internal, - &mut self.constraints, + self.constraints, ) .convert_all(data); } diff --git a/compiler/rustc_borrowck/src/type_check/liveness/local_use_map.rs b/compiler/rustc_borrowck/src/type_check/liveness/local_use_map.rs index a9ca9456787..7433c94a0bc 100644 --- a/compiler/rustc_borrowck/src/type_check/liveness/local_use_map.rs +++ b/compiler/rustc_borrowck/src/type_check/liveness/local_use_map.rs @@ -80,7 +80,7 @@ impl LocalUseMap { live_locals.iter().for_each(|&local| locals_with_use_data[local] = true); LocalUseMapBuild { local_use_map: &mut local_use_map, elements, locals_with_use_data } - .visit_body(&body); + .visit_body(body); local_use_map } diff --git a/compiler/rustc_borrowck/src/type_check/liveness/mod.rs b/compiler/rustc_borrowck/src/type_check/liveness/mod.rs index f1ad0ca55cc..a970dadc479 100644 --- a/compiler/rustc_borrowck/src/type_check/liveness/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/liveness/mod.rs @@ -42,11 +42,11 @@ pub(super) fn generate<'mir, 'tcx>( let free_regions = regions_that_outlive_free_regions( typeck.infcx.num_region_vars(), - &typeck.borrowck_context.universal_regions, + typeck.borrowck_context.universal_regions, &typeck.borrowck_context.constraints.outlives_constraints, ); let (relevant_live_locals, boring_locals) = - compute_relevant_live_locals(typeck.tcx(), &free_regions, &body); + compute_relevant_live_locals(typeck.tcx(), &free_regions, body); let facts_enabled = use_polonius || AllFacts::enabled(typeck.tcx()); let polonius_drop_used = facts_enabled.then(|| { diff --git a/compiler/rustc_borrowck/src/type_check/liveness/polonius.rs b/compiler/rustc_borrowck/src/type_check/liveness/polonius.rs index c621df37106..45f7b07fd5f 100644 --- a/compiler/rustc_borrowck/src/type_check/liveness/polonius.rs +++ b/compiler/rustc_borrowck/src/type_check/liveness/polonius.rs @@ -100,7 +100,7 @@ pub(super) fn populate_access_facts<'a, 'tcx>( location_table, move_data, }; - extractor.visit_body(&body); + extractor.visit_body(body); facts.var_dropped_at.extend( dropped_at.iter().map(|&(local, location)| (local, location_table.mid_index(location))), diff --git a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs index e616449ccd4..525db88aace 100644 --- a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs +++ b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs @@ -64,7 +64,7 @@ pub(super) fn trace<'mir, 'tcx>( let num_region_vars = typeck.infcx.num_region_vars(); let graph = constraint_set.graph(num_region_vars); let region_graph = - graph.region_graph(&constraint_set, borrowck_context.universal_regions.fr_static); + graph.region_graph(constraint_set, borrowck_context.universal_regions.fr_static); // Traverse each issuing region's constraints, and record the loan as flowing into the // outlived region. @@ -489,7 +489,7 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> { } let move_paths = &self.flow_inits.analysis().move_data().move_paths; - move_paths[mpi].find_descendant(&move_paths, |mpi| state.contains(mpi)).is_some() + move_paths[mpi].find_descendant(move_paths, |mpi| state.contains(mpi)).is_some() } /// Returns `true` if the local variable (or some part of it) is initialized in @@ -522,7 +522,7 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> { Self::make_all_regions_live( self.elements, - &mut self.typeck, + self.typeck, value, live_at, &self.inflowing_loans, @@ -579,13 +579,13 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> { for &kind in &drop_data.dropck_result.kinds { Self::make_all_regions_live( self.elements, - &mut self.typeck, + self.typeck, kind, live_at, &self.inflowing_loans, ); - polonius::add_drop_of_var_derefs_origin(&mut self.typeck, dropped_local, &kind); + polonius::add_drop_of_var_derefs_origin(self.typeck, dropped_local, &kind); } } diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index bb9ce5daba2..fdc710c4b4f 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -191,11 +191,11 @@ pub(crate) fn type_check<'mir, 'tcx>( checker.check_user_type_annotations(); let mut verifier = TypeVerifier::new(&mut checker, promoted); - verifier.visit_body(&body); + verifier.visit_body(body); checker.typeck_mir(body); - checker.equate_inputs_and_outputs(&body, universal_regions, &normalized_inputs_and_output); - checker.check_signature_annotation(&body); + checker.equate_inputs_and_outputs(body, universal_regions, &normalized_inputs_and_output); + checker.check_signature_annotation(body); liveness::generate( &mut checker, @@ -389,7 +389,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> { self.cx.ascribe_user_type( constant.const_.ty(), UserType::TypeOf(uv.def, UserArgs { args: uv.args, user_self_ty: None }), - locations.span(&self.cx.body), + locations.span(self.cx.body), ); } } else if let Some(static_def_id) = constant.check_static_ptr(tcx) { @@ -553,7 +553,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { let all_facts = &mut None; let mut constraints = Default::default(); let mut liveness_constraints = - LivenessValues::new(Rc::new(RegionValueElements::new(&promoted_body))); + LivenessValues::new(Rc::new(RegionValueElements::new(promoted_body))); // Don't try to add borrow_region facts for the promoted MIR let mut swap_constraints = |this: &mut Self| { @@ -570,7 +570,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { swap_constraints(self); - self.visit_body(&promoted_body); + self.visit_body(promoted_body); self.cx.typeck_mir(promoted_body); @@ -1127,7 +1127,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { locations, locations.span(self.body), category, - &mut self.borrowck_context.constraints, + self.borrowck_context.constraints, ) .convert_all(data); } @@ -1854,7 +1854,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { for op in ops { self.check_operand(op, location); } - self.check_aggregate_rvalue(&body, rvalue, ak, ops, location) + self.check_aggregate_rvalue(body, rvalue, ak, ops, location) } Rvalue::Repeat(operand, len) => { @@ -2300,7 +2300,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } Rvalue::Ref(region, _borrow_kind, borrowed_place) => { - self.add_reborrow_constraint(&body, location, *region, borrowed_place); + self.add_reborrow_constraint(body, location, *region, borrowed_place); } Rvalue::BinaryOp( @@ -2512,7 +2512,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { let tcx = self.infcx.tcx; let field = path_utils::is_upvar_field_projection( tcx, - &self.borrowck_context.upvars, + self.borrowck_context.upvars, borrowed_place.as_ref(), body, ); @@ -2668,13 +2668,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { location.to_locations(), DUMMY_SP, // irrelevant; will be overridden. ConstraintCategory::Boring, // same as above. - &mut self.borrowck_context.constraints, + self.borrowck_context.constraints, ) - .apply_closure_requirements( - &closure_requirements, - def_id.to_def_id(), - args, - ); + .apply_closure_requirements(closure_requirements, def_id.to_def_id(), args); } // Now equate closure args to regions inherited from `typeck_root_def_id`. Fixes #98589. @@ -2714,7 +2710,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { debug!(?body.span); for (local, local_decl) in body.local_decls.iter_enumerated() { - self.check_local(&body, local, local_decl); + self.check_local(body, local, local_decl); } for (block, block_data) in body.basic_blocks.iter_enumerated() { @@ -2727,8 +2723,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { location.statement_index += 1; } - self.check_terminator(&body, block_data.terminator(), location); - self.check_iscleanup(&body, block_data); + self.check_terminator(body, block_data.terminator(), location); + self.check_iscleanup(body, block_data); } } } diff --git a/compiler/rustc_borrowck/src/used_muts.rs b/compiler/rustc_borrowck/src/used_muts.rs index c5991e0bc25..6ac8e1ba715 100644 --- a/compiler/rustc_borrowck/src/used_muts.rs +++ b/compiler/rustc_borrowck/src/used_muts.rs @@ -35,7 +35,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { never_initialized_mut_locals: &mut never_initialized_mut_locals, mbcx: self, }; - visitor.visit_body(&visitor.mbcx.body); + visitor.visit_body(visitor.mbcx.body); } // Take the union of the existed `used_mut` set with those variables we've found were diff --git a/compiler/rustc_builtin_macros/src/cfg_accessible.rs b/compiler/rustc_builtin_macros/src/cfg_accessible.rs index 37ac09ccdff..64be8da5902 100644 --- a/compiler/rustc_builtin_macros/src/cfg_accessible.rs +++ b/compiler/rustc_builtin_macros/src/cfg_accessible.rs @@ -47,7 +47,7 @@ impl MultiItemModifier for Expander { let template = AttributeTemplate { list: Some("path"), ..Default::default() }; validate_attr::check_builtin_meta_item( &ecx.sess.parse_sess, - &meta_item, + meta_item, ast::AttrStyle::Outer, sym::cfg_accessible, template, diff --git a/compiler/rustc_builtin_macros/src/cfg_eval.rs b/compiler/rustc_builtin_macros/src/cfg_eval.rs index f826c6e7712..ca26b7ed827 100644 --- a/compiler/rustc_builtin_macros/src/cfg_eval.rs +++ b/compiler/rustc_builtin_macros/src/cfg_eval.rs @@ -25,7 +25,7 @@ pub(crate) fn expand( annotatable: Annotatable, ) -> Vec { check_builtin_macro_attribute(ecx, meta_item, sym::cfg_eval); - warn_on_duplicate_attribute(&ecx, &annotatable, sym::cfg_eval); + warn_on_duplicate_attribute(ecx, &annotatable, sym::cfg_eval); vec![cfg_eval(ecx.sess, ecx.ecfg.features, annotatable, ecx.current_expansion.lint_node_id)] } @@ -95,19 +95,19 @@ impl CfgFinder { fn has_cfg_or_cfg_attr(annotatable: &Annotatable) -> bool { let mut finder = CfgFinder { has_cfg_or_cfg_attr: false }; match annotatable { - Annotatable::Item(item) => finder.visit_item(&item), - Annotatable::TraitItem(item) => finder.visit_assoc_item(&item, visit::AssocCtxt::Trait), - Annotatable::ImplItem(item) => finder.visit_assoc_item(&item, visit::AssocCtxt::Impl), - Annotatable::ForeignItem(item) => finder.visit_foreign_item(&item), - Annotatable::Stmt(stmt) => finder.visit_stmt(&stmt), - Annotatable::Expr(expr) => finder.visit_expr(&expr), - Annotatable::Arm(arm) => finder.visit_arm(&arm), - Annotatable::ExprField(field) => finder.visit_expr_field(&field), - Annotatable::PatField(field) => finder.visit_pat_field(&field), - Annotatable::GenericParam(param) => finder.visit_generic_param(¶m), - Annotatable::Param(param) => finder.visit_param(¶m), - Annotatable::FieldDef(field) => finder.visit_field_def(&field), - Annotatable::Variant(variant) => finder.visit_variant(&variant), + Annotatable::Item(item) => finder.visit_item(item), + Annotatable::TraitItem(item) => finder.visit_assoc_item(item, visit::AssocCtxt::Trait), + Annotatable::ImplItem(item) => finder.visit_assoc_item(item, visit::AssocCtxt::Impl), + Annotatable::ForeignItem(item) => finder.visit_foreign_item(item), + Annotatable::Stmt(stmt) => finder.visit_stmt(stmt), + Annotatable::Expr(expr) => finder.visit_expr(expr), + Annotatable::Arm(arm) => finder.visit_arm(arm), + Annotatable::ExprField(field) => finder.visit_expr_field(field), + Annotatable::PatField(field) => finder.visit_pat_field(field), + Annotatable::GenericParam(param) => finder.visit_generic_param(param), + Annotatable::Param(param) => finder.visit_param(param), + Annotatable::FieldDef(field) => finder.visit_field_def(field), + Annotatable::Variant(variant) => finder.visit_variant(variant), Annotatable::Crate(krate) => finder.visit_crate(krate), }; finder.has_cfg_or_cfg_attr diff --git a/compiler/rustc_builtin_macros/src/cmdline_attrs.rs b/compiler/rustc_builtin_macros/src/cmdline_attrs.rs index 7b75d7d84e4..3b1fde1f097 100644 --- a/compiler/rustc_builtin_macros/src/cmdline_attrs.rs +++ b/compiler/rustc_builtin_macros/src/cmdline_attrs.rs @@ -11,7 +11,7 @@ pub fn inject(krate: &mut ast::Crate, parse_sess: &ParseSess, attrs: &[String]) for raw_attr in attrs { let mut parser = rustc_parse::new_parser_from_source_str( parse_sess, - FileName::cli_crate_attr_source_code(&raw_attr), + FileName::cli_crate_attr_source_code(raw_attr), raw_attr.clone(), ); diff --git a/compiler/rustc_builtin_macros/src/concat_bytes.rs b/compiler/rustc_builtin_macros/src/concat_bytes.rs index c4f5af384c1..5499852e177 100644 --- a/compiler/rustc_builtin_macros/src/concat_bytes.rs +++ b/compiler/rustc_builtin_macros/src/concat_bytes.rs @@ -159,7 +159,7 @@ pub fn expand_concat_bytes( accumulator.push(val); } Ok(ast::LitKind::ByteStr(ref bytes, _)) => { - accumulator.extend_from_slice(&bytes); + accumulator.extend_from_slice(bytes); } _ => { if !has_errors { diff --git a/compiler/rustc_builtin_macros/src/derive.rs b/compiler/rustc_builtin_macros/src/derive.rs index 140853db695..5a77c3276e2 100644 --- a/compiler/rustc_builtin_macros/src/derive.rs +++ b/compiler/rustc_builtin_macros/src/derive.rs @@ -35,7 +35,7 @@ impl MultiItemModifier for Expander { AttributeTemplate { list: Some("Trait1, Trait2, ..."), ..Default::default() }; validate_attr::check_builtin_meta_item( &sess.parse_sess, - &meta_item, + meta_item, ast::AttrStyle::Outer, sym::derive, template, @@ -48,14 +48,14 @@ impl MultiItemModifier for Expander { NestedMetaItem::MetaItem(meta) => Some(meta), NestedMetaItem::Lit(lit) => { // Reject `#[derive("Debug")]`. - report_unexpected_meta_item_lit(sess, &lit); + report_unexpected_meta_item_lit(sess, lit); None } }) .map(|meta| { // Reject `#[derive(Debug = "value", Debug(abc))]`, but recover the // paths. - report_path_args(sess, &meta); + report_path_args(sess, meta); meta.path.clone() }) .map(|path| (path, dummy_annotatable(), None, self.0)) diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs index aa1ce1b929d..23502b6eafc 100644 --- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs @@ -467,7 +467,7 @@ impl<'a> TraitDef<'a> { match item { Annotatable::Item(item) => { let is_packed = item.attrs.iter().any(|attr| { - for r in attr::find_repr_attrs(&cx.sess, attr) { + for r in attr::find_repr_attrs(cx.sess, attr) { if let attr::ReprPacked(_) = r { return true; } @@ -478,7 +478,7 @@ impl<'a> TraitDef<'a> { let newitem = match &item.kind { ast::ItemKind::Struct(struct_def, generics) => self.expand_struct_def( cx, - &struct_def, + struct_def, item.ident, generics, from_scratch, @@ -496,7 +496,7 @@ impl<'a> TraitDef<'a> { if self.supports_unions { self.expand_struct_def( cx, - &struct_def, + struct_def, item.ident, generics, from_scratch, diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/ty.rs b/compiler/rustc_builtin_macros/src/deriving/generic/ty.rs index 2d5043112b6..1a45c3279f7 100644 --- a/compiler/rustc_builtin_macros/src/deriving/generic/ty.rs +++ b/compiler/rustc_builtin_macros/src/deriving/generic/ty.rs @@ -182,7 +182,7 @@ impl Bounds { let params = self .bounds .iter() - .map(|&(name, ref bounds)| mk_ty_param(cx, span, name, &bounds, self_ty, self_generics)) + .map(|&(name, ref bounds)| mk_ty_param(cx, span, name, bounds, self_ty, self_generics)) .collect(); Generics { diff --git a/compiler/rustc_builtin_macros/src/format.rs b/compiler/rustc_builtin_macros/src/format.rs index 8a3e15ee24a..12d12d5bff0 100644 --- a/compiler/rustc_builtin_macros/src/format.rs +++ b/compiler/rustc_builtin_macros/src/format.rs @@ -547,7 +547,7 @@ fn make_format_args( span: arg_name.span.into(), msg: format!("named argument `{}` is not used by name", arg_name.name).into(), node_id: rustc_ast::CRATE_NODE_ID, - lint_id: LintId::of(&NAMED_ARGUMENTS_USED_POSITIONALLY), + lint_id: LintId::of(NAMED_ARGUMENTS_USED_POSITIONALLY), diagnostic: BuiltinLintDiagnostics::NamedArgumentUsedPositionally { position_sp_to_replace, position_sp_for_msg, @@ -632,8 +632,7 @@ fn report_missing_placeholders( .collect::>(); if !placeholders.is_empty() { - if let Some(mut new_diag) = - report_redundant_format_arguments(ecx, &args, used, placeholders) + if let Some(mut new_diag) = report_redundant_format_arguments(ecx, args, used, placeholders) { diag.cancel(); new_diag.emit(); diff --git a/compiler/rustc_builtin_macros/src/source_util.rs b/compiler/rustc_builtin_macros/src/source_util.rs index f7bafa2856e..7ae4b1b59dc 100644 --- a/compiler/rustc_builtin_macros/src/source_util.rs +++ b/compiler/rustc_builtin_macros/src/source_util.rs @@ -133,7 +133,7 @@ pub fn expand_include<'cx>( let r = base::parse_expr(&mut self.p)?; if self.p.token != token::Eof { self.p.sess.buffer_lint( - &INCOMPLETE_INCLUDE, + INCOMPLETE_INCLUDE, self.p.token.span, self.node_id, "include macro expected single expression in source", @@ -189,7 +189,7 @@ pub fn expand_include_str( match cx.source_map().load_binary_file(&file) { Ok(bytes) => match std::str::from_utf8(&bytes) { Ok(src) => { - let interned_src = Symbol::intern(&src); + let interned_src = Symbol::intern(src); base::MacEager::expr(cx.expr_str(sp, interned_src)) } Err(_) => { diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs index 6d55603c708..c0055380c25 100644 --- a/compiler/rustc_builtin_macros/src/test.rs +++ b/compiler/rustc_builtin_macros/src/test.rs @@ -26,7 +26,7 @@ pub fn expand_test_case( anno_item: Annotatable, ) -> Vec { check_builtin_macro_attribute(ecx, meta_item, sym::test_case); - warn_on_duplicate_attribute(&ecx, &anno_item, sym::test_case); + warn_on_duplicate_attribute(ecx, &anno_item, sym::test_case); if !ecx.ecfg.should_test { return vec![]; @@ -79,7 +79,7 @@ pub fn expand_test( item: Annotatable, ) -> Vec { check_builtin_macro_attribute(cx, meta_item, sym::test); - warn_on_duplicate_attribute(&cx, &item, sym::test); + warn_on_duplicate_attribute(cx, &item, sym::test); expand_test_or_bench(cx, attr_sp, item, false) } @@ -90,7 +90,7 @@ pub fn expand_bench( item: Annotatable, ) -> Vec { check_builtin_macro_attribute(cx, meta_item, sym::bench); - warn_on_duplicate_attribute(&cx, &item, sym::bench); + warn_on_duplicate_attribute(cx, &item, sym::bench); expand_test_or_bench(cx, attr_sp, item, true) } @@ -134,9 +134,9 @@ pub fn expand_test_or_bench( // will fail. We shouldn't try to expand in this case because the errors // would be spurious. let check_result = if is_bench { - check_bench_signature(cx, &item, &fn_) + check_bench_signature(cx, &item, fn_) } else { - check_test_signature(cx, &item, &fn_) + check_test_signature(cx, &item, fn_) }; if check_result.is_err() { return if is_stmt { diff --git a/compiler/rustc_builtin_macros/src/test_harness.rs b/compiler/rustc_builtin_macros/src/test_harness.rs index c7999a226c7..380556c3ca5 100644 --- a/compiler/rustc_builtin_macros/src/test_harness.rs +++ b/compiler/rustc_builtin_macros/src/test_harness.rs @@ -60,7 +60,7 @@ pub fn inject( // Do this here so that the test_runner crate attribute gets marked as used // even in non-test builds - let test_runner = get_test_runner(span_diagnostic, &krate); + let test_runner = get_test_runner(span_diagnostic, krate); if sess.is_test_crate() { let panic_strategy = match (panic_strategy, sess.opts.unstable_opts.panic_abort_tests) { @@ -372,7 +372,7 @@ fn mk_tests_slice(cx: &TestCtxt<'_>, sp: Span) -> P { let ecx = &cx.ext_cx; let mut tests = cx.test_cases.clone(); - tests.sort_by(|a, b| a.name.as_str().cmp(&b.name.as_str())); + tests.sort_by(|a, b| a.name.as_str().cmp(b.name.as_str())); ecx.expr_array_ref( sp, diff --git a/compiler/rustc_builtin_macros/src/util.rs b/compiler/rustc_builtin_macros/src/util.rs index 9463a1418ce..eeaf00004e6 100644 --- a/compiler/rustc_builtin_macros/src/util.rs +++ b/compiler/rustc_builtin_macros/src/util.rs @@ -10,7 +10,7 @@ pub fn check_builtin_macro_attribute(ecx: &ExtCtxt<'_>, meta_item: &MetaItem, na let template = AttributeTemplate { word: true, ..Default::default() }; validate_attr::check_builtin_meta_item( &ecx.sess.parse_sess, - &meta_item, + meta_item, AttrStyle::Outer, name, template, diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs index a5ffe0650a8..b5f53f51838 100644 --- a/compiler/rustc_codegen_llvm/src/abi.rs +++ b/compiler/rustc_codegen_llvm/src/abi.rs @@ -493,7 +493,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { PassMode::Cast { cast, pad_i32: _ } => { cast.attrs.apply_attrs_to_callsite( llvm::AttributePlace::ReturnValue, - &bx.cx, + bx.cx, callsite, ); } diff --git a/compiler/rustc_codegen_llvm/src/allocator.rs b/compiler/rustc_codegen_llvm/src/allocator.rs index db5c1388ef8..798014d668e 100644 --- a/compiler/rustc_codegen_llvm/src/allocator.rs +++ b/compiler/rustc_codegen_llvm/src/allocator.rs @@ -67,7 +67,7 @@ pub(crate) unsafe fn codegen( llcx, llmod, "__rust_alloc_error_handler", - &alloc_error_handler_name(alloc_error_handler_kind), + alloc_error_handler_name(alloc_error_handler_kind), &[usize, usize], // size, align None, true, diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index b6c01545f30..92ae59ad352 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -136,7 +136,7 @@ fn instrument_function_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> SmallVec<[&'ll Attr attrs.push(llvm::CreateAttrStringValue( cx.llcx, "instrument-function-entry-inlined", - &mcount_name, + mcount_name, )); } if let Some(options) = &cx.sess().opts.unstable_opts.instrument_xray { @@ -459,7 +459,7 @@ pub fn from_fn_attrs<'ll, 'tcx>( // If this function is an import from the environment but the wasm // import has a specific module/name, apply them here. if let Some(module) = wasm_import_module(cx.tcx, instance.def_id()) { - to_add.push(llvm::CreateAttrStringValue(cx.llcx, "wasm-import-module", &module)); + to_add.push(llvm::CreateAttrStringValue(cx.llcx, "wasm-import-module", module)); let name = codegen_fn_attrs.link_name.unwrap_or_else(|| cx.tcx.item_name(instance.def_id())); diff --git a/compiler/rustc_codegen_llvm/src/back/archive.rs b/compiler/rustc_codegen_llvm/src/back/archive.rs index f33075a8879..cf47c94a81f 100644 --- a/compiler/rustc_codegen_llvm/src/back/archive.rs +++ b/compiler/rustc_codegen_llvm/src/back/archive.rs @@ -68,7 +68,7 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> { ) -> io::Result<()> { let mut archive = archive.to_path_buf(); if self.sess.target.llvm_target.contains("-apple-macosx") { - if let Some(new_archive) = try_extract_macho_fat_archive(&self.sess, &archive)? { + if let Some(new_archive) = try_extract_macho_fat_archive(self.sess, &archive)? { archive = new_archive } } diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index 8d335ff1718..3a8b8e1ad11 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -124,7 +124,7 @@ pub fn create_target_machine(tcx: TyCtxt<'_>, mod_name: &str) -> OwnedTargetMach let config = TargetMachineFactoryConfig { split_dwarf_file, output_obj_file }; target_machine_factory( - &tcx.sess, + tcx.sess, tcx.backend_optimization_level(()), tcx.global_backend_features(()), )(config) @@ -1106,7 +1106,7 @@ fn record_llvm_cgu_instructions_stats(prof: &SelfProfilerRef, llmod: &llvm::Modu } let raw_stats = - llvm::build_string(|s| unsafe { llvm::LLVMRustModuleInstructionStats(&llmod, s) }) + llvm::build_string(|s| unsafe { llvm::LLVMRustModuleInstructionStats(llmod, s) }) .expect("cannot get module instruction stats"); #[derive(serde::Deserialize)] diff --git a/compiler/rustc_codegen_llvm/src/callee.rs b/compiler/rustc_codegen_llvm/src/callee.rs index 0c9f7f19551..e675362ac33 100644 --- a/compiler/rustc_codegen_llvm/src/callee.rs +++ b/compiler/rustc_codegen_llvm/src/callee.rs @@ -62,7 +62,7 @@ pub fn get_fn<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) -> // exemption for MinGW for backwards compatibility. let llfn = cx.declare_fn( &common::i686_decorated_name( - &dllimport, + dllimport, common::is_mingw_gnu_toolchain(&tcx.sess.target), true, ), diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs index 307c1264dc1..b6bc5395bf6 100644 --- a/compiler/rustc_codegen_llvm/src/consts.rs +++ b/compiler/rustc_codegen_llvm/src/consts.rs @@ -187,7 +187,7 @@ fn check_and_apply_linkage<'ll, 'tcx>( { cx.declare_global( &common::i686_decorated_name( - &dllimport, + dllimport, common::is_mingw_gnu_toolchain(&cx.tcx.sess.target), true, ), diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs index 274e0aeaaba..4f540de7ae0 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs @@ -176,7 +176,7 @@ impl GlobalFileTable { // compilation directory can be combined with the relative paths // to get absolute paths, if needed. use rustc_session::RemapFileNameExt; - let working_dir: &str = &tcx.sess.opts.working_dir.for_codegen(&tcx.sess).to_string_lossy(); + let working_dir: &str = &tcx.sess.opts.working_dir.for_codegen(tcx.sess).to_string_lossy(); llvm::build_byte_buffer(|buffer| { coverageinfo::write_filenames_section_to_buffer( diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index 865bf01c8c1..cf78fc56b49 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -853,7 +853,7 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>( use rustc_session::RemapFileNameExt; let name_in_debuginfo = name_in_debuginfo.to_string_lossy(); - let work_dir = tcx.sess.opts.working_dir.for_codegen(&tcx.sess).to_string_lossy(); + let work_dir = tcx.sess.opts.working_dir.for_codegen(tcx.sess).to_string_lossy(); let flags = "\0"; let output_filenames = tcx.output_filenames(()); let split_name = if tcx.sess.target_can_use_split_dwarf() { diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs index ca7bfbeac25..7ef185250a3 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs @@ -715,7 +715,7 @@ fn build_union_fields_for_direct_tag_coroutine<'ll, 'tcx>( coroutine_type_and_layout, coroutine_type_di_node, coroutine_layout, - &common_upvar_names, + common_upvar_names, ); let span = coroutine_layout.variant_source_info[variant_index].span; diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs index 7eff52b857f..130ca2727e4 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs @@ -197,7 +197,7 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>( coroutine_type_and_layout, coroutine_type_di_node, coroutine_layout, - &common_upvar_names, + common_upvar_names, ), source_info, } diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index c86bf81fc13..156c9b76417 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -537,8 +537,7 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec AssertModuleSource<'tcx> { self.cgu_reuse_tracker.set_expectation( cgu_name, - &user_path, + user_path, attr.span, expected_reuse, comp_kind, diff --git a/compiler/rustc_codegen_ssa/src/back/archive.rs b/compiler/rustc_codegen_ssa/src/back/archive.rs index 1c464b3eca4..4dc28adf336 100644 --- a/compiler/rustc_codegen_ssa/src/back/archive.rs +++ b/compiler/rustc_codegen_ssa/src/back/archive.rs @@ -175,8 +175,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { ) -> io::Result<()> { let mut archive_path = archive_path.to_path_buf(); if self.sess.target.llvm_target.contains("-apple-macosx") { - if let Some(new_archive_path) = - try_extract_macho_fat_archive(&self.sess, &archive_path)? + if let Some(new_archive_path) = try_extract_macho_fat_archive(self.sess, &archive_path)? { archive_path = new_archive_path } diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 33e8f352cd8..903563671a6 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -277,7 +277,7 @@ pub fn each_linked_rlib( let crate_name = info.crate_name[&cnum]; let used_crate_source = &info.used_crate_source[&cnum]; if let Some((path, _)) = &used_crate_source.rlib { - f(cnum, &path); + f(cnum, path); } else { if used_crate_source.rmeta.is_some() { return Err(errors::LinkRlibError::OnlyRmetaFound { crate_name }); @@ -524,7 +524,7 @@ fn link_staticlib<'a>( && !ignored_for_lto(sess, &codegen_results.crate_info, cnum); let native_libs = codegen_results.crate_info.native_libraries[&cnum].iter(); - let relevant = native_libs.clone().filter(|lib| relevant_lib(sess, &lib)); + let relevant = native_libs.clone().filter(|lib| relevant_lib(sess, lib)); let relevant_libs: FxHashSet<_> = relevant.filter_map(|lib| lib.filename).collect(); let bundled_libs: FxHashSet<_> = native_libs.filter_map(|lib| lib.filename).collect(); @@ -689,7 +689,7 @@ fn link_dwarf_object<'a>( // Adding an executable is primarily done to make `thorin` check that all the referenced // dwarf objects are found in the end. package.add_executable( - &executable_out_filename, + executable_out_filename, thorin::MissingReferencedObjectBehaviour::Skip, )?; @@ -945,7 +945,7 @@ fn link_natively<'a>( { let is_vs_installed = windows_registry::find_vs_version().is_ok(); let has_linker = windows_registry::find_tool( - &sess.opts.target_triple.triple(), + sess.opts.target_triple.triple(), "link.exe", ) .is_some(); @@ -1038,14 +1038,14 @@ fn link_natively<'a>( if sess.target.is_like_osx { match (strip, crate_type) { (Strip::Debuginfo, _) => { - strip_symbols_with_external_utility(sess, "strip", &out_filename, Some("-S")) + strip_symbols_with_external_utility(sess, "strip", out_filename, Some("-S")) } // Per the manpage, `-x` is the maximum safe strip level for dynamic libraries. (#93988) (Strip::Symbols, CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro) => { - strip_symbols_with_external_utility(sess, "strip", &out_filename, Some("-x")) + strip_symbols_with_external_utility(sess, "strip", out_filename, Some("-x")) } (Strip::Symbols, _) => { - strip_symbols_with_external_utility(sess, "strip", &out_filename, None) + strip_symbols_with_external_utility(sess, "strip", out_filename, None) } (Strip::None, _) => {} } @@ -1059,7 +1059,7 @@ fn link_natively<'a>( match strip { // Always preserve the symbol table (-x). Strip::Debuginfo => { - strip_symbols_with_external_utility(sess, stripcmd, &out_filename, Some("-x")) + strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-x")) } // Strip::Symbols is handled via the --strip-all linker option. Strip::Symbols => {} @@ -1245,13 +1245,13 @@ fn link_sanitizer_runtime(sess: &Session, linker: &mut dyn Linker, name: &str) { // rpath to the library as well (the rpath should be absolute, see // PR #41352 for details). let filename = format!("rustc{channel}_rt.{name}"); - let path = find_sanitizer_runtime(&sess, &filename); + let path = find_sanitizer_runtime(sess, &filename); let rpath = path.to_str().expect("non-utf8 component in path"); linker.args(&["-Wl,-rpath", "-Xlinker", rpath]); linker.link_dylib(&filename, false, true); } else { let filename = format!("librustc{channel}_rt.{name}.a"); - let path = find_sanitizer_runtime(&sess, &filename).join(&filename); + let path = find_sanitizer_runtime(sess, &filename).join(&filename); linker.link_whole_rlib(&path); } } @@ -1685,7 +1685,7 @@ fn link_output_kind(sess: &Session, crate_type: CrateType) -> LinkOutputKind { // Returns true if linker is located within sysroot fn detect_self_contained_mingw(sess: &Session) -> bool { - let (linker, _) = linker_and_flavor(&sess); + let (linker, _) = linker_and_flavor(sess); // Assume `-C linker=rust-lld` as self-contained mode if linker == Path::new("rust-lld") { return true; @@ -1737,7 +1737,7 @@ fn self_contained_components(sess: &Session, crate_type: CrateType) -> LinkSelfC LinkSelfContainedDefault::InferredForMingw => { sess.host == sess.target && sess.target.vendor != "uwp" - && detect_self_contained_mingw(&sess) + && detect_self_contained_mingw(sess) } } }; @@ -2432,7 +2432,7 @@ fn add_native_libs_from_crate( // If rlib contains native libs as archives, unpack them to tmpdir. let rlib = &codegen_results.crate_info.used_crate_source[&cnum].rlib.as_ref().unwrap().0; archive_builder_builder - .extract_bundled_libs(rlib, tmpdir, &bundled_libs) + .extract_bundled_libs(rlib, tmpdir, bundled_libs) .unwrap_or_else(|e| sess.emit_fatal(e)); } @@ -2485,7 +2485,7 @@ fn add_native_libs_from_crate( cmd.link_whole_staticlib( name, verbatim, - &search_paths.get_or_init(|| archive_search_paths(sess)), + search_paths.get_or_init(|| archive_search_paths(sess)), ); } else { cmd.link_staticlib(name, verbatim) @@ -2719,7 +2719,7 @@ fn rehome_sysroot_lib_dir<'a>(sess: &'a Session, lib_dir: &Path) -> PathBuf { // already had `fix_windows_verbatim_for_gcc()` applied if needed. sysroot_lib_path } else { - fix_windows_verbatim_for_gcc(&lib_dir) + fix_windows_verbatim_for_gcc(lib_dir) } } @@ -2756,7 +2756,7 @@ fn add_static_crate<'a>( let mut link_upstream = |path: &Path| { let rlib_path = if let Some(dir) = path.parent() { let file_name = path.file_name().expect("rlib path has no file name path component"); - rehome_sysroot_lib_dir(sess, &dir).join(file_name) + rehome_sysroot_lib_dir(sess, dir).join(file_name) } else { fix_windows_verbatim_for_gcc(path) }; @@ -2793,7 +2793,7 @@ fn add_static_crate<'a>( let canonical = f.replace('-', "_"); let is_rust_object = - canonical.starts_with(&canonical_name) && looks_like_rust_object_file(&f); + canonical.starts_with(&canonical_name) && looks_like_rust_object_file(f); // If we're performing LTO and this is a rust-generated object // file, then we don't need the object file as it's part of the diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index 09434513e31..0cb35021b62 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -45,7 +45,7 @@ pub fn get_linker<'a>( self_contained: bool, target_cpu: &'a str, ) -> Box { - let msvc_tool = windows_registry::find_tool(&sess.opts.target_triple.triple(), "link.exe"); + let msvc_tool = windows_registry::find_tool(sess.opts.target_triple.triple(), "link.exe"); // If our linker looks like a batch script on Windows then to execute this // we'll need to spawn `cmd` explicitly. This is primarily done to handle @@ -78,7 +78,7 @@ pub fn get_linker<'a>( if matches!(flavor, LinkerFlavor::Msvc(..)) && t.vendor == "uwp" { if let Some(ref tool) = msvc_tool { let original_path = tool.path(); - if let Some(ref root_lib_path) = original_path.ancestors().nth(4) { + if let Some(root_lib_path) = original_path.ancestors().nth(4) { let arch = match t.arch.as_ref() { "x86_64" => Some("x64"), "x86" => Some("x86"), @@ -519,7 +519,7 @@ impl<'a> Linker for GccLinker<'a> { // -force_load is the macOS equivalent of --whole-archive, but it // involves passing the full path to the library to link. self.linker_arg("-force_load"); - let lib = find_native_static_library(lib, verbatim, search_path, &self.sess); + let lib = find_native_static_library(lib, verbatim, search_path, self.sess); self.linker_arg(&lib); } } @@ -1590,7 +1590,7 @@ impl<'a> Linker for AixLinker<'a> { fn link_whole_staticlib(&mut self, lib: &str, verbatim: bool, search_path: &[PathBuf]) { self.hint_static(); - let lib = find_native_static_library(lib, verbatim, search_path, &self.sess); + let lib = find_native_static_library(lib, verbatim, search_path, self.sess); self.cmd.arg(format!("-bkeepfile:{}", lib.to_str().unwrap())); } diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index 9cd4394108a..b12ac881100 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -621,7 +621,7 @@ fn wasm_import_module_map(tcx: TyCtxt<'_>, cnum: CrateNum) -> FxHashMap( let incr_comp_session_dir = cgcx.incr_comp_session_dir.as_ref().unwrap(); let load_from_incr_comp_dir = |output_path: PathBuf, saved_path: &str| { - let source_file = in_incr_comp_dir(&incr_comp_session_dir, saved_path); + let source_file = in_incr_comp_dir(incr_comp_session_dir, saved_path); debug!( "copying preexisting module `{}` from {:?} to {}", module.name, @@ -914,7 +914,7 @@ fn execute_copy_from_cache_work_item( let object = load_from_incr_comp_dir( cgcx.output_filenames.temp_path(OutputType::Object, Some(&module.name)), - &module.source.saved_files.get("o").expect("no saved object file in work product"), + module.source.saved_files.get("o").expect("no saved object file in work product"), ); let dwarf_object = module.source.saved_files.get("dwo").as_ref().and_then(|saved_dwarf_object_file| { @@ -924,7 +924,7 @@ fn execute_copy_from_cache_work_item( .expect( "saved dwarf object in work product but `split_dwarf_path` returned `None`", ); - load_from_incr_comp_dir(dwarf_obj_out, &saved_dwarf_object_file) + load_from_incr_comp_dir(dwarf_obj_out, saved_dwarf_object_file) }); WorkItemResult::Finished(CompiledModule { diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index 23054975548..1d5205ac67a 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -148,10 +148,9 @@ pub fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( (&ty::Array(_, len), &ty::Slice(_)) => { cx.const_usize(len.eval_target_usize(cx.tcx(), ty::ParamEnv::reveal_all())) } - ( - &ty::Dynamic(ref data_a, _, src_dyn_kind), - &ty::Dynamic(ref data_b, _, target_dyn_kind), - ) if src_dyn_kind == target_dyn_kind => { + (&ty::Dynamic(data_a, _, src_dyn_kind), &ty::Dynamic(data_b, _, target_dyn_kind)) + if src_dyn_kind == target_dyn_kind => + { let old_info = old_info.expect("unsized_info: missing old info for trait upcasting coercion"); if data_a.principal_def_id() == data_b.principal_def_id() { @@ -458,8 +457,8 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( cx.set_frame_pointer_type(llfn); cx.apply_target_cpu_attr(llfn); - let llbb = Bx::append_block(&cx, llfn, "top"); - let mut bx = Bx::build(&cx, llbb); + let llbb = Bx::append_block(cx, llfn, "top"); + let mut bx = Bx::build(cx, llbb); bx.insert_reference_to_gdb_debug_scripts_section_global(); @@ -685,7 +684,7 @@ pub fn codegen_crate( // Calculate the CGU reuse let cgu_reuse = tcx.sess.time("find_cgu_reuse", || { - codegen_units.iter().map(|cgu| determine_cgu_reuse(tcx, &cgu)).collect::>() + codegen_units.iter().map(|cgu| determine_cgu_reuse(tcx, cgu)).collect::>() }); crate::assert_module_sources::assert_module_sources(tcx, &|cgu_reuse_tracker| { diff --git a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs index 2e0840f2d1b..f6ae4db62f9 100644 --- a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs +++ b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs @@ -477,9 +477,9 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs { ) .emit(); InlineAttr::None - } else if list_contains_name(&items, sym::always) { + } else if list_contains_name(items, sym::always) { InlineAttr::Always - } else if list_contains_name(&items, sym::never) { + } else if list_contains_name(items, sym::never) { InlineAttr::Never } else { struct_span_err!( @@ -514,9 +514,9 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs { if items.len() != 1 { err(attr.span, "expected one argument"); OptimizeAttr::None - } else if list_contains_name(&items, sym::size) { + } else if list_contains_name(items, sym::size) { OptimizeAttr::Size - } else if list_contains_name(&items, sym::speed) { + } else if list_contains_name(items, sym::speed) { OptimizeAttr::Speed } else { err(items[0].span(), "invalid argument"); diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs index 3c7e8873b4d..839cc4dabe3 100644 --- a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs +++ b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs @@ -216,7 +216,7 @@ fn push_debuginfo_type_name<'tcx>( output.push(']'); } } - ty::Dynamic(ref trait_data, ..) => { + ty::Dynamic(trait_data, ..) => { let auto_traits: SmallVec<[DefId; 4]> = trait_data.auto_traits().collect(); let has_enclosing_parens = if cpp_like_debuginfo { diff --git a/compiler/rustc_codegen_ssa/src/mir/analyze.rs b/compiler/rustc_codegen_ssa/src/mir/analyze.rs index ed859cb20de..c1de9b76fe7 100644 --- a/compiler/rustc_codegen_ssa/src/mir/analyze.rs +++ b/compiler/rustc_codegen_ssa/src/mir/analyze.rs @@ -42,7 +42,7 @@ pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( // If there exists a local definition that dominates all uses of that local, // the definition should be visited first. Traverse blocks in an order that // is a topological sort of dominance partial order. - for (bb, data) in traversal::reverse_postorder(&mir) { + for (bb, data) in traversal::reverse_postorder(mir) { analyzer.visit_basic_block_data(bb, data); } @@ -202,7 +202,7 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx> ) => match &mut self.locals[local] { LocalKind::ZST => {} LocalKind::Memory => {} - LocalKind::SSA(def) if def.dominates(location, &self.dominators) => {} + LocalKind::SSA(def) if def.dominates(location, self.dominators) => {} // Reads from uninitialized variables (e.g., in dead code, after // optimizations) require locals to be in (uninitialized) memory. // N.B., there can be uninitialized reads of a local visited after diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index 3d2d8f8b509..a1662f25e14 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -47,7 +47,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> { &self, fx: &'b mut FunctionCx<'a, 'tcx, Bx>, ) -> Option<&'b Bx::Funclet> { - let cleanup_kinds = (&fx.cleanup_kinds).as_ref()?; + let cleanup_kinds = fx.cleanup_kinds.as_ref()?; let funclet_bb = cleanup_kinds[self.bb].funclet_bb(self.bb)?; // If `landing_pad_for` hasn't been called yet to create the `Funclet`, // it has to be now. This may not seem necessary, as RPO should lead @@ -161,7 +161,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> { ) -> MergingSucc { // If there is a cleanup block and the function we're calling can unwind, then // do an invoke, otherwise do a call. - let fn_ty = bx.fn_decl_backend_type(&fn_abi); + let fn_ty = bx.fn_decl_backend_type(fn_abi); let fn_attrs = if bx.tcx().def_kind(fx.instance.def_id()).has_codegen_attrs() { Some(bx.tcx().codegen_fn_attrs(fx.instance.def_id())) @@ -204,9 +204,9 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> { let invokeret = bx.invoke( fn_ty, fn_attrs, - Some(&fn_abi), + Some(fn_abi), fn_ptr, - &llargs, + llargs, ret_llbb, unwind_block, self.funclet(fx), @@ -225,7 +225,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> { } MergingSucc::False } else { - let llret = bx.call(fn_ty, fn_attrs, Some(&fn_abi), fn_ptr, &llargs, self.funclet(fx)); + let llret = bx.call(fn_ty, fn_attrs, Some(fn_abi), fn_ptr, llargs, self.funclet(fx)); if fx.mir[self.bb].is_cleanup { bx.apply_attrs_to_cleanup_callsite(llret); } @@ -273,7 +273,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> { bx.codegen_inline_asm( template, - &operands, + operands, options, line_spans, instance, @@ -281,7 +281,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> { ); MergingSucc::False } else { - bx.codegen_inline_asm(template, &operands, options, line_spans, instance, None); + bx.codegen_inline_asm(template, operands, options, line_spans, instance, None); if let Some(target) = destination { self.funclet_br(fx, bx, target, mergeable_succ) @@ -318,7 +318,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { discr: &mir::Operand<'tcx>, targets: &SwitchTargets, ) { - let discr = self.codegen_operand(bx, &discr); + let discr = self.codegen_operand(bx, discr); let switch_ty = discr.layout.ty; let mut target_iter = targets.iter(); if target_iter.len() == 1 { @@ -498,7 +498,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { args = &args[..1]; ( meth::VirtualIndex::from_index(ty::COMMON_VTABLE_ENTRIES_DROPINPLACE) - .get_fn(bx, vtable, ty, &fn_abi), + .get_fn(bx, vtable, ty, fn_abi), fn_abi, ) } @@ -540,7 +540,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { debug!("args' = {:?}", args); ( meth::VirtualIndex::from_index(ty::COMMON_VTABLE_ENTRIES_DROPINPLACE) - .get_fn(bx, meta.immediate(), ty, &fn_abi), + .get_fn(bx, meta.immediate(), ty, fn_abi), fn_abi, ) } @@ -864,7 +864,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { // promotes any complex rvalues to constants. if i == 2 && intrinsic == sym::simd_shuffle { if let mir::Operand::Constant(constant) = arg { - let (llval, ty) = self.simd_shuffle_indices(&bx, constant); + let (llval, ty) = self.simd_shuffle_indices(bx, constant); return OperandRef { val: Immediate(llval), layout: bx.layout_of(ty), @@ -881,7 +881,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { Self::codegen_intrinsic_call( bx, *instance.as_ref().unwrap(), - &fn_abi, + fn_abi, &args, dest, span, @@ -937,7 +937,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { bx, meta, op.layout.ty, - &fn_abi, + fn_abi, )); llargs.push(data_ptr); continue 'make_args; @@ -948,7 +948,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { bx, meta, op.layout.ty, - &fn_abi, + fn_abi, )); llargs.push(data_ptr); continue; @@ -975,7 +975,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { bx, meta.immediate(), op.layout.ty, - &fn_abi, + fn_abi, )); llargs.push(data_ptr.llval); continue; @@ -1587,9 +1587,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { self.set_debug_loc(&mut bx, mir::SourceInfo::outermost(self.mir.span)); let (fn_abi, fn_ptr) = common::build_langcall(&bx, None, reason.lang_item()); - let fn_ty = bx.fn_decl_backend_type(&fn_abi); + let fn_ty = bx.fn_decl_backend_type(fn_abi); - let llret = bx.call(fn_ty, None, Some(&fn_abi), fn_ptr, &[], funclet.as_ref()); + let llret = bx.call(fn_ty, None, Some(fn_abi), fn_ptr, &[], funclet.as_ref()); bx.apply_attrs_to_cleanup_callsite(llret); bx.unreachable(); @@ -1662,10 +1662,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } } } else { - self.codegen_place( - bx, - mir::PlaceRef { local: dest.local, projection: &dest.projection }, - ) + self.codegen_place(bx, mir::PlaceRef { local: dest.local, projection: dest.projection }) }; if fn_ret.is_indirect() { if dest.align < dest.layout.align.abi { @@ -1696,7 +1693,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { match dest { Nothing => (), - Store(dst) => bx.store_arg(&ret_abi, llval, dst), + Store(dst) => bx.store_arg(ret_abi, llval, dst), IndirectOperand(tmp, index) => { let op = bx.load_operand(tmp); tmp.storage_dead(bx); @@ -1708,7 +1705,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let op = if let PassMode::Cast { .. } = ret_abi.mode { let tmp = PlaceRef::alloca(bx, ret_abi.layout); tmp.storage_live(bx); - bx.store_arg(&ret_abi, llval, tmp); + bx.store_arg(ret_abi, llval, tmp); let op = bx.load_operand(tmp); tmp.storage_dead(bx); op diff --git a/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs b/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs index 0dc30d21c5b..14915e816ee 100644 --- a/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs +++ b/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs @@ -398,7 +398,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let Some(dbg_loc) = self.dbg_loc(var.source_info) else { return }; let DebugInfoOffset { direct_offset, indirect_offsets, result: _ } = - calculate_debuginfo_offset(bx, &var.projection, base.layout); + calculate_debuginfo_offset(bx, var.projection, base.layout); // When targeting MSVC, create extra allocas for arguments instead of pointing multiple // dbg_var_addr() calls into the same alloca with offsets. MSVC uses CodeView records @@ -416,7 +416,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { if should_create_individual_allocas { let DebugInfoOffset { direct_offset: _, indirect_offsets: _, result: place } = - calculate_debuginfo_offset(bx, &var.projection, base); + calculate_debuginfo_offset(bx, var.projection, base); // Create a variable which will be a pointer to the actual value let ptr_ty = Ty::new_ptr( diff --git a/compiler/rustc_codegen_ssa/src/mir/mod.rs b/compiler/rustc_codegen_ssa/src/mir/mod.rs index d0b799e087b..a6fcf1fd38c 100644 --- a/compiler/rustc_codegen_ssa/src/mir/mod.rs +++ b/compiler/rustc_codegen_ssa/src/mir/mod.rs @@ -168,7 +168,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( let fn_abi = cx.fn_abi_of_instance(instance, ty::List::empty()); debug!("fn_abi: {:?}", fn_abi); - let debug_context = cx.create_function_debug_context(instance, &fn_abi, llfn, &mir); + let debug_context = cx.create_function_debug_context(instance, fn_abi, llfn, mir); let start_llbb = Bx::append_block(cx, llfn, "start"); let mut start_bx = Bx::build(cx, start_llbb); @@ -180,7 +180,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( } let cleanup_kinds = - base::wants_new_eh_instructions(cx.tcx().sess).then(|| analyze::cleanup_kinds(&mir)); + base::wants_new_eh_instructions(cx.tcx().sess).then(|| analyze::cleanup_kinds(mir)); let cached_llbbs: IndexVec> = mir.basic_blocks @@ -261,7 +261,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( drop(start_bx); // Codegen the body of each block using reverse postorder - for (bb, _) in traversal::reverse_postorder(&mir) { + for (bb, _) in traversal::reverse_postorder(mir) { fx.codegen_block(bb); } } diff --git a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs index 8e5019967a4..02b51dfe5bf 100644 --- a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs +++ b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs @@ -702,7 +702,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { }; let fn_ptr = bx.get_fn_addr(instance); let fn_abi = bx.fn_abi_of_instance(instance, ty::List::empty()); - let fn_ty = bx.fn_decl_backend_type(&fn_abi); + let fn_ty = bx.fn_decl_backend_type(fn_abi); let fn_attrs = if bx.tcx().def_kind(instance.def_id()).has_codegen_attrs() { Some(bx.tcx().codegen_fn_attrs(instance.def_id())) } else { diff --git a/compiler/rustc_codegen_ssa/src/mono_item.rs b/compiler/rustc_codegen_ssa/src/mono_item.rs index 6fbf992eda9..295e2769109 100644 --- a/compiler/rustc_codegen_ssa/src/mono_item.rs +++ b/compiler/rustc_codegen_ssa/src/mono_item.rs @@ -34,7 +34,7 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> { } MonoItem::GlobalAsm(item_id) => { let item = cx.tcx().hir().item(item_id); - if let hir::ItemKind::GlobalAsm(ref asm) = item.kind { + if let hir::ItemKind::GlobalAsm(asm) = item.kind { let operands: Vec<_> = asm .operands .iter() @@ -88,7 +88,7 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> { } } MonoItem::Fn(instance) => { - base::codegen_instance::(&cx, instance); + base::codegen_instance::(cx, instance); } } @@ -119,10 +119,10 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> { match *self { MonoItem::Static(def_id) => { - cx.predefine_static(def_id, linkage, visibility, &symbol_name); + cx.predefine_static(def_id, linkage, visibility, symbol_name); } MonoItem::Fn(instance) => { - cx.predefine_fn(instance, linkage, visibility, &symbol_name); + cx.predefine_fn(instance, linkage, visibility, symbol_name); } MonoItem::GlobalAsm(..) => {} } diff --git a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs index 13937a94198..edfece07d19 100644 --- a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs @@ -314,7 +314,7 @@ pub fn eval_in_interpreter<'mir, 'tcx>( is_static: bool, ) -> ::rustc_middle::mir::interpret::EvalToAllocationRawResult<'tcx> { let res = ecx.load_mir(cid.instance.def, cid.promoted); - match res.and_then(|body| eval_body_using_ecx(&mut ecx, cid, &body)) { + match res.and_then(|body| eval_body_using_ecx(&mut ecx, cid, body)) { Err(error) => { let (error, backtrace) = error.into_parts(); backtrace.print_backtrace(); diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs index 739dbcc5aba..bc0327db22e 100644 --- a/compiler/rustc_const_eval/src/const_eval/machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/machine.rs @@ -200,7 +200,7 @@ impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> { &caller .file .name - .for_scope(&self.tcx.sess, RemapPathScopeComponents::DIAGNOSTICS) + .for_scope(self.tcx.sess, RemapPathScopeComponents::DIAGNOSTICS) .to_string_lossy(), ), u32::try_from(caller.line).unwrap(), diff --git a/compiler/rustc_const_eval/src/const_eval/valtrees.rs b/compiler/rustc_const_eval/src/const_eval/valtrees.rs index 2bee4b45ad0..854fe9a0765 100644 --- a/compiler/rustc_const_eval/src/const_eval/valtrees.rs +++ b/compiler/rustc_const_eval/src/const_eval/valtrees.rs @@ -387,7 +387,7 @@ fn valtree_into_mplace<'tcx>( debug!(?place_inner); valtree_into_mplace(ecx, &place_inner, *inner_valtree); - dump_place(&ecx, &place_inner); + dump_place(ecx, &place_inner); } debug!("dump of place_adjusted:"); diff --git a/compiler/rustc_const_eval/src/interpret/cast.rs b/compiler/rustc_const_eval/src/interpret/cast.rs index f4cb12c8d43..d296ff5928b 100644 --- a/compiler/rustc_const_eval/src/interpret/cast.rs +++ b/compiler/rustc_const_eval/src/interpret/cast.rs @@ -256,7 +256,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let addr = addr.to_target_usize(self)?; // Then turn address into pointer. - let ptr = M::ptr_from_addr_cast(&self, addr)?; + let ptr = M::ptr_from_addr_cast(self, addr)?; Ok(ImmTy::from_scalar(Scalar::from_maybe_pointer(ptr, self), cast_to)) } diff --git a/compiler/rustc_const_eval/src/interpret/intern.rs b/compiler/rustc_const_eval/src/interpret/intern.rs index 3d90e95c09c..413963b2fdc 100644 --- a/compiler/rustc_const_eval/src/interpret/intern.rs +++ b/compiler/rustc_const_eval/src/interpret/intern.rs @@ -259,7 +259,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx, const_eval::Memory // to avoid could be expensive: on the potentially larger types, arrays and slices, // rather than on all aggregates unconditionally. if matches!(mplace.layout.ty.kind(), ty::Array(..) | ty::Slice(..)) { - let Some((size, _align)) = self.ecx.size_and_align_of_mplace(&mplace)? else { + let Some((size, _align)) = self.ecx.size_and_align_of_mplace(mplace)? else { // We do the walk if we can't determine the size of the mplace: we may be // dealing with extern types here in the future. return Ok(true); diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index b23cafc193a..80e14f5a884 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -505,7 +505,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { // Performs an exact division, resulting in undefined behavior where // `x % y != 0` or `y == 0` or `x == T::MIN && y == -1`. // First, check x % y != 0 (or if that computation overflows). - let (res, overflow) = self.overflowing_binary_op(BinOp::Rem, &a, &b)?; + let (res, overflow) = self.overflowing_binary_op(BinOp::Rem, a, b)?; assert!(!overflow); // All overflow is UB, so this should never return on overflow. if res.to_scalar().assert_bits(a.layout.size) != 0 { throw_ub_custom!( @@ -515,7 +515,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { ) } // `Rem` says this is all right, so we can let `Div` do its job. - self.binop_ignore_overflow(BinOp::Div, &a, &b, dest) + self.binop_ignore_overflow(BinOp::Div, a, b, dest) } pub fn saturating_arith( diff --git a/compiler/rustc_const_eval/src/interpret/operator.rs b/compiler/rustc_const_eval/src/interpret/operator.rs index 538077a0b77..eef15425764 100644 --- a/compiler/rustc_const_eval/src/interpret/operator.rs +++ b/compiler/rustc_const_eval/src/interpret/operator.rs @@ -20,7 +20,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { right: &ImmTy<'tcx, M::Provenance>, dest: &PlaceTy<'tcx, M::Provenance>, ) -> InterpResult<'tcx> { - let (val, overflowed) = self.overflowing_binary_op(op, &left, &right)?; + let (val, overflowed) = self.overflowing_binary_op(op, left, right)?; debug_assert_eq!( Ty::new_tup(self.tcx.tcx, &[val.layout.ty, self.tcx.types.bool]), dest.layout.ty, diff --git a/compiler/rustc_const_eval/src/interpret/place.rs b/compiler/rustc_const_eval/src/interpret/place.rs index 09ffdec7de7..2ad0c9a8731 100644 --- a/compiler/rustc_const_eval/src/interpret/place.rs +++ b/compiler/rustc_const_eval/src/interpret/place.rs @@ -456,7 +456,7 @@ where ) -> InterpResult<'tcx, Option>> { let (size, _align) = self - .size_and_align_of_mplace(&mplace)? + .size_and_align_of_mplace(mplace)? .unwrap_or((mplace.layout.size, mplace.layout.align.abi)); // We check alignment separately, and *after* checking everything else. // If an access is both OOB and misaligned, we want to see the bounds error. @@ -472,7 +472,7 @@ where ) -> InterpResult<'tcx, Option>> { let (size, _align) = self - .size_and_align_of_mplace(&mplace)? + .size_and_align_of_mplace(mplace)? .unwrap_or((mplace.layout.size, mplace.layout.align.abi)); // We check alignment separately, and raise that error *after* checking everything else. // If an access is both OOB and misaligned, we want to see the bounds error. diff --git a/compiler/rustc_const_eval/src/interpret/terminator.rs b/compiler/rustc_const_eval/src/interpret/terminator.rs index b54c6681456..debae6c8902 100644 --- a/compiler/rustc_const_eval/src/interpret/terminator.rs +++ b/compiler/rustc_const_eval/src/interpret/terminator.rs @@ -51,7 +51,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { ) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> { match arg { FnArg::Copy(op) => Ok(op.clone()), - FnArg::InPlace(place) => self.place_to_op(&place), + FnArg::InPlace(place) => self.place_to_op(place), } } @@ -410,7 +410,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { // so we implement a type-based check that reflects the guaranteed rules for ABI compatibility. if self.layout_compat(caller_abi.layout, callee_abi.layout)? { // Ensure that our checks imply actual ABI compatibility for this concrete call. - assert!(caller_abi.eq_abi(&callee_abi)); + assert!(caller_abi.eq_abi(callee_abi)); return Ok(true); } else { trace!( @@ -464,7 +464,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { // We work with a copy of the argument for now; if this is in-place argument passing, we // will later protect the source it comes from. This means the callee cannot observe if we // did in-place of by-copy argument passing, except for pointer equality tests. - let caller_arg_copy = self.copy_fn_arg(&caller_arg)?; + let caller_arg_copy = self.copy_fn_arg(caller_arg)?; if !already_live { let local = callee_arg.as_local().unwrap(); let meta = caller_arg_copy.meta(); diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index d21fef58f3f..20f251d5c91 100644 --- a/compiler/rustc_const_eval/src/interpret/validity.rs +++ b/compiler/rustc_const_eval/src/interpret/validity.rs @@ -896,7 +896,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let mut visitor = ValidityVisitor { path, ref_tracking, ctfe_mode, ecx: self }; // Run it. - match visitor.visit_value(&op) { + match visitor.visit_value(op) { Ok(()) => Ok(()), // Pass through validation failures and "invalid program" issues. Err(err) diff --git a/compiler/rustc_const_eval/src/interpret/visitor.rs b/compiler/rustc_const_eval/src/interpret/visitor.rs index fc21ad1f183..5c5a6e8db57 100644 --- a/compiler/rustc_const_eval/src/interpret/visitor.rs +++ b/compiler/rustc_const_eval/src/interpret/visitor.rs @@ -97,14 +97,14 @@ pub trait ValueVisitor<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>>: Sized { let inner_mplace = self.ecx().unpack_dyn_trait(&dest)?.0; trace!("walk_value: dyn object layout: {:#?}", inner_mplace.layout); // recurse with the inner type - return self.visit_field(&v, 0, &inner_mplace.into()); + return self.visit_field(v, 0, &inner_mplace.into()); } ty::Dynamic(_, _, ty::DynStar) => { // DynStar types. Very different from a dyn type (but strangely part of the // same variant in `TyKind`): These are pairs where the 2nd component is the // vtable, and the first component is the data (which must be ptr-sized). let data = self.ecx().unpack_dyn_star(v)?.0; - return self.visit_field(&v, 0, &data); + return self.visit_field(v, 0, &data); } // Slices do not need special handling here: they have `Array` field // placement with length 0, so we enter the `Array` case below which diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs index 76116e33985..13742ad273b 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs @@ -60,9 +60,9 @@ impl<'mir, 'tcx> Qualifs<'mir, 'tcx> { let ConstCx { tcx, body, .. } = *ccx; FlowSensitiveAnalysis::new(NeedsDrop, ccx) - .into_engine(tcx, &body) + .into_engine(tcx, body) .iterate_to_fixpoint() - .into_results_cursor(&body) + .into_results_cursor(body) }); needs_drop.seek_before_primary_effect(location); @@ -122,9 +122,9 @@ impl<'mir, 'tcx> Qualifs<'mir, 'tcx> { let ConstCx { tcx, body, .. } = *ccx; FlowSensitiveAnalysis::new(HasMutInterior, ccx) - .into_engine(tcx, &body) + .into_engine(tcx, body) .iterate_to_fixpoint() - .into_results_cursor(&body) + .into_results_cursor(body) }); has_mut_interior.seek_before_primary_effect(location); @@ -170,9 +170,9 @@ impl<'mir, 'tcx> Qualifs<'mir, 'tcx> { hir::ConstContext::Const { .. } | hir::ConstContext::Static(_) => { let mut cursor = FlowSensitiveAnalysis::new(CustomEq, ccx) - .into_engine(ccx.tcx, &ccx.body) + .into_engine(ccx.tcx, ccx.body) .iterate_to_fixpoint() - .into_results_cursor(&ccx.body); + .into_results_cursor(ccx.body); cursor.seek_after_primary_effect(return_loc); cursor.get().contains(RETURN_PLACE) @@ -225,7 +225,7 @@ impl<'mir, 'tcx> Deref for Checker<'mir, 'tcx> { type Target = ConstCx<'mir, 'tcx>; fn deref(&self) -> &Self::Target { - &self.ccx + self.ccx } } @@ -272,7 +272,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> { } if !tcx.has_attr(def_id, sym::rustc_do_not_const_check) { - self.visit_body(&body); + self.visit_body(body); } // If we got through const-checking without emitting any "primary" errors, emit any @@ -503,7 +503,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { Rvalue::Ref(_, BorrowKind::Shared | BorrowKind::Fake, place) | Rvalue::AddressOf(Mutability::Not, place) => { let borrowed_place_has_mut_interior = qualifs::in_place::( - &self.ccx, + self.ccx, &mut |local| self.qualifs.has_mut_interior(self.ccx, local, location), place.as_ref(), ); diff --git a/compiler/rustc_const_eval/src/transform/check_consts/mod.rs b/compiler/rustc_const_eval/src/transform/check_consts/mod.rs index e51082e1ec0..095e119d38c 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/mod.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/mod.rs @@ -83,7 +83,7 @@ pub fn rustc_allow_const_fn_unstable( feature_gate: Symbol, ) -> bool { let attrs = tcx.hir().attrs(tcx.hir().local_def_id_to_hir_id(def_id)); - attr::rustc_allow_const_fn_unstable(&tcx.sess, attrs).any(|name| name == feature_gate) + attr::rustc_allow_const_fn_unstable(tcx.sess, attrs).any(|name| name == feature_gate) } /// Returns `true` if the given `const fn` is "const-stable". diff --git a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs index 40183baccf8..ca63eb135bd 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs @@ -129,7 +129,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> { tcx, generics, err, - ¶m_ty.name.as_str(), + param_ty.name.as_str(), &constraint, None, None, diff --git a/compiler/rustc_const_eval/src/transform/check_consts/post_drop_elaboration.rs b/compiler/rustc_const_eval/src/transform/check_consts/post_drop_elaboration.rs index aff256b3ead..06371438ec1 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/post_drop_elaboration.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/post_drop_elaboration.rs @@ -54,7 +54,7 @@ impl<'mir, 'tcx> std::ops::Deref for CheckLiveDrops<'mir, 'tcx> { type Target = ConstCx<'mir, 'tcx>; fn deref(&self) -> &Self::Target { - &self.ccx + self.ccx } } diff --git a/compiler/rustc_const_eval/src/transform/promote_consts.rs b/compiler/rustc_const_eval/src/transform/promote_consts.rs index b3d6b891b11..66b813e4e59 100644 --- a/compiler/rustc_const_eval/src/transform/promote_consts.rs +++ b/compiler/rustc_const_eval/src/transform/promote_consts.rs @@ -188,7 +188,7 @@ impl<'a, 'tcx> std::ops::Deref for Validator<'a, 'tcx> { type Target = ConstCx<'a, 'tcx>; fn deref(&self) -> &Self::Target { - &self.ccx + self.ccx } } @@ -229,7 +229,7 @@ impl<'tcx> Validator<'_, 'tcx> { let statement = &self.body[loc.block].statements[loc.statement_index]; match &statement.kind { StatementKind::Assign(box (_, rhs)) => qualifs::in_rvalue::( - &self.ccx, + self.ccx, &mut |l| self.qualif_local::(l), rhs, ), @@ -246,7 +246,7 @@ impl<'tcx> Validator<'_, 'tcx> { match &terminator.kind { TerminatorKind::Call { .. } => { let return_ty = self.body.local_decls[local].ty; - Q::in_any_value_of_ty(&self.ccx, return_ty) + Q::in_any_value_of_ty(self.ccx, return_ty) } kind => { span_bug!(terminator.source_info.span, "{:?} not promotable", kind); diff --git a/compiler/rustc_data_structures/src/sharded.rs b/compiler/rustc_data_structures/src/sharded.rs index 639f05c9e52..162dbd234d6 100644 --- a/compiler/rustc_data_structures/src/sharded.rs +++ b/compiler/rustc_data_structures/src/sharded.rs @@ -50,7 +50,7 @@ impl Sharded { #[inline] pub fn get_shard_by_value(&self, _val: &K) -> &Lock { match self { - Self::Single(single) => &single, + Self::Single(single) => single, #[cfg(parallel_compiler)] Self::Shards(..) => self.get_shard_by_hash(make_hash(_val)), } @@ -64,7 +64,7 @@ impl Sharded { #[inline] pub fn get_shard_by_index(&self, _i: usize) -> &Lock { match self { - Self::Single(single) => &single, + Self::Single(single) => single, #[cfg(parallel_compiler)] Self::Shards(shards) => { // SAFETY: The index gets ANDed with the shard mask, ensuring it is always inbounds. diff --git a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs index 203e529120b..da266bf9c63 100644 --- a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs +++ b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs @@ -138,7 +138,7 @@ impl AnnotateSnippetEmitterWriter { let message = self.translate_messages(messages, args); if let Some(source_map) = &self.source_map { // Make sure our primary file comes first - let primary_lo = if let Some(ref primary_span) = msp.primary_span().as_ref() { + let primary_lo = if let Some(primary_span) = msp.primary_span().as_ref() { if primary_span.is_dummy() { // FIXME(#59346): Not sure when this is the case and what // should be done if it happens @@ -203,7 +203,7 @@ impl AnnotateSnippetEmitterWriter { Slice { source, line_start: *line_index, - origin: Some(&file_name), + origin: Some(file_name), // FIXME(#59346): Not really sure when `fold` should be true or false fold: false, annotations: annotations diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 68dba860291..ba9cd02a9ec 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -1297,7 +1297,7 @@ impl EmitterWriter { buffer.append(line_number, line, style_or_override(*style, override_style)); } } else { - buffer.append(line_number, &text, style_or_override(*style, override_style)); + buffer.append(line_number, text, style_or_override(*style, override_style)); } } } @@ -1931,7 +1931,7 @@ impl EmitterWriter { self.draw_code_line( &mut buffer, &mut row_num, - &highlight_parts, + highlight_parts, line_pos + line_start, line, show_code_change, @@ -2338,7 +2338,7 @@ impl FileWithAnnotatedLines { let mut output = vec![]; let mut multiline_annotations = vec![]; - if let Some(ref sm) = emitter.source_map() { + if let Some(sm) = emitter.source_map() { for SpanLabel { span, is_primary, label } in msp.span_labels() { // If we don't have a useful span, pick the primary span if that exists. // Worst case we'll just print an error at the top of the main file. @@ -2362,7 +2362,7 @@ impl FileWithAnnotatedLines { let label = label.as_ref().map(|m| { normalize_whitespace( - &emitter.translate_message(m, &args).map_err(Report::new).unwrap(), + &emitter.translate_message(m, args).map_err(Report::new).unwrap(), ) }); diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index c4d2a374f0c..88e90a3b3d1 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -777,7 +777,7 @@ impl SyntaxExtension { attrs: &[ast::Attribute], ) -> SyntaxExtension { let allow_internal_unstable = - attr::allow_internal_unstable(sess, &attrs).collect::>(); + attr::allow_internal_unstable(sess, attrs).collect::>(); let allow_internal_unsafe = attr::contains_name(attrs, sym::allow_internal_unsafe); let local_inner_macros = attr::find_by_name(attrs, sym::macro_export) @@ -796,9 +796,9 @@ impl SyntaxExtension { ) }) .unwrap_or_else(|| (None, helper_attrs)); - let stability = attr::find_stability(&sess, attrs, span); - let const_stability = attr::find_const_stability(&sess, attrs, span); - let body_stability = attr::find_body_stability(&sess, attrs); + let stability = attr::find_stability(sess, attrs, span); + let const_stability = attr::find_const_stability(sess, attrs, span); + let body_stability = attr::find_body_stability(sess, attrs); if let Some((_, sp)) = const_stability { sess.emit_err(errors::MacroConstStability { span: sp, @@ -818,7 +818,7 @@ impl SyntaxExtension { allow_internal_unstable: (!allow_internal_unstable.is_empty()) .then(|| allow_internal_unstable.into()), stability: stability.map(|(s, _)| s), - deprecation: attr::find_deprecation(&sess, features, attrs).map(|(d, _)| d), + deprecation: attr::find_deprecation(sess, features, attrs).map(|(d, _)| d), helper_attrs, edition, builtin_name, @@ -1464,7 +1464,7 @@ fn pretty_printing_compatibility_hack(item: &Item, sess: &ParseSess) -> bool { if crate_matches { sess.buffer_lint_with_diagnostic( - &PROC_MACRO_BACK_COMPAT, + PROC_MACRO_BACK_COMPAT, item.ident.span, ast::CRATE_NODE_ID, "using an old version of `rental`", diff --git a/compiler/rustc_expand/src/config.rs b/compiler/rustc_expand/src/config.rs index 0d76b1b2974..5ccef343b17 100644 --- a/compiler/rustc_expand/src/config.rs +++ b/compiler/rustc_expand/src/config.rs @@ -434,9 +434,9 @@ impl<'a> StripUnconfigured<'a> { } }; ( - parse_cfg(&meta_item, &self.sess).map_or(true, |meta_item| { + parse_cfg(&meta_item, self.sess).map_or(true, |meta_item| { attr::cfg_matches( - &meta_item, + meta_item, &self.sess.parse_sess, self.lint_node_id, self.features, diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index f87f4aba2b9..1b51d80fb38 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -1096,7 +1096,7 @@ impl InvocationCollectorNode for P { ModKind::Loaded(_, inline, _) => { // Inline `mod foo { ... }`, but we still need to push directories. let (dir_path, dir_ownership) = mod_dir_path( - &ecx.sess, + ecx.sess, ident, &attrs, &ecx.current_expansion.module, @@ -1111,7 +1111,7 @@ impl InvocationCollectorNode for P { let old_attrs_len = attrs.len(); let ParsedExternalMod { items, spans, file_path, dir_path, dir_ownership } = parse_external_mod( - &ecx.sess, + ecx.sess, ident, span, &ecx.current_expansion.module, @@ -1168,14 +1168,14 @@ impl InvocationCollectorNode for P { ast::UseTreeKind::Simple(_) => idents.push(ut.ident()), ast::UseTreeKind::Nested(nested) => { for (ut, _) in nested { - collect_use_tree_leaves(&ut, idents); + collect_use_tree_leaves(ut, idents); } } } } let mut idents = Vec::new(); - collect_use_tree_leaves(&ut, &mut idents); + collect_use_tree_leaves(ut, &mut idents); return idents; } @@ -1531,7 +1531,7 @@ impl InvocationCollectorNode for AstNodeWrapper, OptExprTag> { } } fn pre_flat_map_node_collect_attr(cfg: &StripUnconfigured<'_>, attr: &ast::Attribute) { - cfg.maybe_emit_expr_attr_err(&attr); + cfg.maybe_emit_expr_attr_err(attr); } } @@ -1580,7 +1580,7 @@ struct InvocationCollector<'a, 'b> { impl<'a, 'b> InvocationCollector<'a, 'b> { fn cfg(&self) -> StripUnconfigured<'_> { StripUnconfigured { - sess: &self.cx.sess, + sess: self.cx.sess, features: Some(self.cx.ecfg.features), config_tokens: false, lint_node_id: self.cx.current_expansion.lint_node_id, @@ -1693,7 +1693,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> { if attr.is_doc_comment() { self.cx.sess.parse_sess.buffer_lint_with_diagnostic( - &UNUSED_DOC_COMMENTS, + UNUSED_DOC_COMMENTS, current_span, self.cx.current_expansion.lint_node_id, "unused doc comment", @@ -1705,7 +1705,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> { // eagerly evaluated. if attr_name != sym::cfg && attr_name != sym::cfg_attr { self.cx.sess.parse_sess.buffer_lint_with_diagnostic( - &UNUSED_ATTRIBUTES, + UNUSED_ATTRIBUTES, attr.span, self.cx.current_expansion.lint_node_id, format!("unused attribute `{attr_name}`"), diff --git a/compiler/rustc_expand/src/mbe/macro_check.rs b/compiler/rustc_expand/src/mbe/macro_check.rs index 95f5bb2d2e2..42c91824baf 100644 --- a/compiler/rustc_expand/src/mbe/macro_check.rs +++ b/compiler/rustc_expand/src/mbe/macro_check.rs @@ -650,6 +650,6 @@ fn buffer_lint( ) { // Macros loaded from other crates have dummy node ids. if node_id != DUMMY_NODE_ID { - sess.buffer_lint(&META_VARIABLE_MISUSE, span, node_id, message); + sess.buffer_lint(META_VARIABLE_MISUSE, span, node_id, message); } } diff --git a/compiler/rustc_expand/src/mbe/macro_parser.rs b/compiler/rustc_expand/src/mbe/macro_parser.rs index 1c78232a0f3..965beb9bf84 100644 --- a/compiler/rustc_expand/src/mbe/macro_parser.rs +++ b/compiler/rustc_expand/src/mbe/macro_parser.rs @@ -483,7 +483,7 @@ impl TtParser { if matches!(t, Token { kind: DocComment(..), .. }) { mp.idx += 1; self.cur_mps.push(mp); - } else if token_name_eq(&t, token) { + } else if token_name_eq(t, token) { mp.idx += 1; self.next_mps.push(mp); } diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index ebdd3cb547c..bc3f0ce5a70 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -213,7 +213,7 @@ fn expand_macro<'cx>( let arm_span = rhses[i].span(); // rhs has holes ( `$id` and `$(...)` that need filled) - let mut tts = match transcribe(cx, &named_matches, &rhs, rhs_span, transparency) { + let mut tts = match transcribe(cx, &named_matches, rhs, rhs_span, transparency) { Ok(tts) => tts, Err(mut err) => { err.emit(); @@ -511,7 +511,7 @@ pub fn compile_declarative_macro( ) .pop() .unwrap(); - valid &= check_lhs_nt_follows(&sess.parse_sess, &def, &tt); + valid &= check_lhs_nt_follows(&sess.parse_sess, def, &tt); return tt; } sess.parse_sess.span_diagnostic.span_bug(def.span, "wrong-structured lhs") @@ -927,7 +927,7 @@ impl<'tt> TtHandle<'tt> { fn get(&'tt self) -> &'tt mbe::TokenTree { match self { TtHandle::TtRef(tt) => tt, - TtHandle::Token(token_tt) => &token_tt, + TtHandle::Token(token_tt) => token_tt, } } } @@ -1170,7 +1170,7 @@ fn check_matcher_core<'tt>( Some(NonterminalKind::PatParam { inferred: false }), )); sess.buffer_lint_with_diagnostic( - &RUST_2021_INCOMPATIBLE_OR_PATTERNS, + RUST_2021_INCOMPATIBLE_OR_PATTERNS, span, ast::CRATE_NODE_ID, "the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro", @@ -1407,7 +1407,7 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow { fn quoted_tt_to_string(tt: &mbe::TokenTree) -> String { match tt { - mbe::TokenTree::Token(token) => pprust::token_to_string(&token).into(), + mbe::TokenTree::Token(token) => pprust::token_to_string(token).into(), mbe::TokenTree::MetaVar(_, name) => format!("${name}"), mbe::TokenTree::MetaVarDecl(_, name, Some(kind)) => format!("${name}:{kind}"), mbe::TokenTree::MetaVarDecl(_, name, None) => format!("${name}:"), diff --git a/compiler/rustc_expand/src/mbe/quoted.rs b/compiler/rustc_expand/src/mbe/quoted.rs index 6546199f5e6..6c6dfe53305 100644 --- a/compiler/rustc_expand/src/mbe/quoted.rs +++ b/compiler/rustc_expand/src/mbe/quoted.rs @@ -116,7 +116,7 @@ pub(super) fn parse( fn maybe_emit_macro_metavar_expr_feature(features: &Features, sess: &ParseSess, span: Span) { if !features.macro_metavar_expr { let msg = "meta-variable expressions are unstable"; - feature_err(&sess, sym::macro_metavar_expr, span, msg).emit(); + feature_err(sess, sym::macro_metavar_expr, span, msg).emit(); } } @@ -174,7 +174,7 @@ fn parse_tree<'a>( // The delimiter is `{`. This indicates the beginning // of a meta-variable expression (e.g. `${count(ident)}`). // Try to parse the meta-variable expression. - match MetaVarExpr::parse(&tts, delim_span.entire(), sess) { + match MetaVarExpr::parse(tts, delim_span.entire(), sess) { Err(mut err) => { err.emit(); // Returns early the same read `$` to avoid spanning @@ -242,10 +242,8 @@ fn parse_tree<'a>( // `tree` is followed by some other token. This is an error. Some(tokenstream::TokenTree::Token(token, _)) => { - let msg = format!( - "expected identifier, found `{}`", - pprust::token_to_string(&token), - ); + let msg = + format!("expected identifier, found `{}`", pprust::token_to_string(token),); sess.span_diagnostic.span_err(token.span, msg); TokenTree::MetaVar(token.span, Ident::empty()) } @@ -291,7 +289,7 @@ fn parse_kleene_op<'a>( span: Span, ) -> Result, Span> { match input.next() { - Some(tokenstream::TokenTree::Token(token, _)) => match kleene_op(&token) { + Some(tokenstream::TokenTree::Token(token, _)) => match kleene_op(token) { Some(op) => Ok(Ok((op, token.span))), None => Ok(Err(token.clone())), }, diff --git a/compiler/rustc_expand/src/mbe/transcribe.rs b/compiler/rustc_expand/src/mbe/transcribe.rs index 15e7ab3fe3e..bc03fc0d1b1 100644 --- a/compiler/rustc_expand/src/mbe/transcribe.rs +++ b/compiler/rustc_expand/src/mbe/transcribe.rs @@ -90,7 +90,7 @@ pub(super) fn transcribe<'a>( // We descend into the RHS (`src`), expanding things as we go. This stack contains the things // we have yet to expand/are still expanding. We start the stack off with the whole RHS. - let mut stack: SmallVec<[Frame<'_>; 1]> = smallvec![Frame::new(&src, src_span)]; + let mut stack: SmallVec<[Frame<'_>; 1]> = smallvec![Frame::new(src, src_span)]; // As we descend in the RHS, we will need to be able to match nested sequences of matchers. // `repeats` keeps track of where we are in matching at each level, with the last element being @@ -166,7 +166,7 @@ pub(super) fn transcribe<'a>( // and the matches in `interp` have the same shape. Otherwise, either the caller or the // macro writer has made a mistake. seq @ mbe::TokenTree::Sequence(_, delimited) => { - match lockstep_iter_size(&seq, interp, &repeats) { + match lockstep_iter_size(seq, interp, &repeats) { LockstepIterSize::Unconstrained => { return Err(cx.create_err(NoSyntaxVarsExprRepeat { span: seq.span() })); } @@ -250,7 +250,7 @@ pub(super) fn transcribe<'a>( // Replace meta-variable expressions with the result of their expansion. mbe::TokenTree::MetaVarExpr(sp, expr) => { - transcribe_metavar_expr(cx, expr, interp, &mut marker, &repeats, &mut result, &sp)?; + transcribe_metavar_expr(cx, expr, interp, &mut marker, &repeats, &mut result, sp)?; } // If we are entering a new delimiter, we push its contents to the `stack` to be @@ -529,7 +529,7 @@ fn transcribe_metavar_expr<'a>( match *expr { MetaVarExpr::Count(original_ident, depth_opt) => { let matched = matched_from_ident(cx, original_ident, interp)?; - let count = count_repetitions(cx, depth_opt, matched, &repeats, sp)?; + let count = count_repetitions(cx, depth_opt, matched, repeats, sp)?; let tt = TokenTree::token_alone( TokenKind::lit(token::Integer, sym::integer(count), None), visited_span(), diff --git a/compiler/rustc_expand/src/module.rs b/compiler/rustc_expand/src/module.rs index df6bdc6952b..a0dec89d631 100644 --- a/compiler/rustc_expand/src/module.rs +++ b/compiler/rustc_expand/src/module.rs @@ -57,7 +57,7 @@ pub(crate) fn parse_external_mod( // We bail on the first error, but that error does not cause a fatal error... (1) let result: Result<_, ModError<'_>> = try { // Extract the file path and the new ownership. - let mp = mod_file_path(sess, ident, &attrs, &module.dir_path, dir_ownership)?; + let mp = mod_file_path(sess, ident, attrs, &module.dir_path, dir_ownership)?; dir_ownership = mp.dir_ownership; // Ensure file paths are acyclic. @@ -119,7 +119,7 @@ pub(crate) fn mod_dir_path( Inline::No => { // FIXME: This is a subset of `parse_external_mod` without actual parsing, // check whether the logic for unloaded, loaded and inline modules can be unified. - let file_path = mod_file_path(sess, ident, &attrs, &module.dir_path, dir_ownership) + let file_path = mod_file_path(sess, ident, attrs, &module.dir_path, dir_ownership) .map(|mp| { dir_ownership = mp.dir_ownership; mp.file_path diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs index 41ec0ed84f7..b057a645f81 100644 --- a/compiler/rustc_expand/src/proc_macro_server.rs +++ b/compiler/rustc_expand/src/proc_macro_server.rs @@ -784,6 +784,6 @@ impl server::Server for Rustc<'_, '_> { } fn with_symbol_string(symbol: &Self::Symbol, f: impl FnOnce(&str)) { - f(&symbol.as_str()) + f(symbol.as_str()) } } diff --git a/compiler/rustc_hir_analysis/src/astconv/errors.rs b/compiler/rustc_hir_analysis/src/astconv/errors.rs index 8f4b83966df..5a70a842f0d 100644 --- a/compiler/rustc_hir_analysis/src/astconv/errors.rs +++ b/compiler/rustc_hir_analysis/src/astconv/errors.rs @@ -227,7 +227,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { self.tcx(), generics, &mut err, - &ty_param_name, + ty_param_name, &trait_name, None, None, diff --git a/compiler/rustc_hir_analysis/src/astconv/lint.rs b/compiler/rustc_hir_analysis/src/astconv/lint.rs index bc57bbcca62..14e810d1336 100644 --- a/compiler/rustc_hir_analysis/src/astconv/lint.rs +++ b/compiler/rustc_hir_analysis/src/astconv/lint.rs @@ -106,7 +106,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { ); } // check if the impl trait that we are considering is a impl of a local trait - self.maybe_lint_blanket_trait_impl(&self_ty, &mut diag); + self.maybe_lint_blanket_trait_impl(self_ty, &mut diag); diag.stash(self_ty.span, StashKey::TraitMissingMethod); } else { let msg = "trait objects without an explicit `dyn` are deprecated"; @@ -121,7 +121,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { sugg, Applicability::MachineApplicable, ); - self.maybe_lint_blanket_trait_impl(&self_ty, lint); + self.maybe_lint_blanket_trait_impl(self_ty, lint); lint }, ); diff --git a/compiler/rustc_hir_analysis/src/astconv/mod.rs b/compiler/rustc_hir_analysis/src/astconv/mod.rs index 3542fc7cd33..102c83751aa 100644 --- a/compiler/rustc_hir_analysis/src/astconv/mod.rs +++ b/compiler/rustc_hir_analysis/src/astconv/mod.rs @@ -1666,7 +1666,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { .copied() .filter(|&(impl_, _)| { infcx.probe(|_| { - let ocx = ObligationCtxt::new(&infcx); + let ocx = ObligationCtxt::new(infcx); ocx.register_obligations(obligations.clone()); let impl_args = infcx.fresh_args_for_item(span, impl_); @@ -1979,7 +1979,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { types_and_spans[..types_and_spans.len() - 1] .iter() .map(|(x, _)| x.as_str()) - .intersperse(&", ") + .intersperse(", ") .collect::() ), [(only, _)] => only.to_string(), diff --git a/compiler/rustc_hir_analysis/src/autoderef.rs b/compiler/rustc_hir_analysis/src/autoderef.rs index 39db295044e..5fc500f4807 100644 --- a/compiler/rustc_hir_analysis/src/autoderef.rs +++ b/compiler/rustc_hir_analysis/src/autoderef.rs @@ -182,7 +182,7 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> { } }; - let errors = fulfill_cx.select_where_possible(&self.infcx); + let errors = fulfill_cx.select_where_possible(self.infcx); if !errors.is_empty() { // This shouldn't happen, except for evaluate/fulfill mismatches, // but that's not a reason for an ICE (`predicate_may_hold` is conservative diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index e61ca232de6..e301f0b22ef 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -222,11 +222,11 @@ fn check_opaque(tcx: TyCtxt<'_>, id: hir::ItemId) { if tcx.type_of(item.owner_id.def_id).instantiate_identity().references_error() { return; } - if check_opaque_for_cycles(tcx, item.owner_id.def_id, args, span, &origin).is_err() { + if check_opaque_for_cycles(tcx, item.owner_id.def_id, args, span, origin).is_err() { return; } - let _ = check_opaque_meets_bounds(tcx, item.owner_id.def_id, span, &origin); + let _ = check_opaque_meets_bounds(tcx, item.owner_id.def_id, span, origin); } /// Checks that an opaque type does not contain cycles. @@ -518,7 +518,7 @@ fn check_item_type(tcx: TyCtxt<'_>, id: hir::ItemId) { DefKind::TyAlias => { let pty_ty = tcx.type_of(id.owner_id).instantiate_identity(); let generics = tcx.generics_of(id.owner_id); - check_type_params_are_used(tcx, &generics, pty_ty); + check_type_params_are_used(tcx, generics, pty_ty); } DefKind::ForeignMod => { let it = tcx.hir().item(id); @@ -900,7 +900,7 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) { let repr = def.repr(); if repr.packed() { for attr in tcx.get_attrs(def.did(), sym::repr) { - for r in attr::parse_repr_attr(&tcx.sess, attr) { + for r in attr::parse_repr_attr(tcx.sess, attr) { if let attr::ReprPacked(pack) = r && let Some(repr_pack) = repr.pack && pack as u64 != repr_pack.bytes() @@ -1150,8 +1150,8 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) { let has_disr = |var: &ty::VariantDef| matches!(var.discr, ty::VariantDiscr::Explicit(_)); let has_non_units = def.variants().iter().any(|var| !is_unit(var)); - let disr_units = def.variants().iter().any(|var| is_unit(&var) && has_disr(&var)); - let disr_non_unit = def.variants().iter().any(|var| !is_unit(&var) && has_disr(&var)); + let disr_units = def.variants().iter().any(|var| is_unit(var) && has_disr(var)); + let disr_non_unit = def.variants().iter().any(|var| !is_unit(var) && has_disr(var)); if disr_non_unit || (disr_units && has_non_units) { let mut err = struct_span_err!( diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index f026f78cc2b..d93bb48e0fe 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -307,7 +307,7 @@ fn compare_method_predicate_entailment<'tcx>( debug!(?impl_sig, ?trait_sig, ?terr, "sub_types failed"); let emitted = report_trait_method_mismatch( - &infcx, + infcx, cause, terr, (trait_m, trait_sig), @@ -1140,7 +1140,7 @@ fn report_trait_method_mismatch<'tcx>( ) -> ErrorGuaranteed { let tcx = infcx.tcx; let (impl_err_span, trait_err_span) = - extract_spans_for_error_reporting(&infcx, terr, &cause, impl_m, trait_m); + extract_spans_for_error_reporting(infcx, terr, &cause, impl_m, trait_m); let mut diag = struct_span_err!( tcx.sess, diff --git a/compiler/rustc_hir_analysis/src/check/intrinsicck.rs b/compiler/rustc_hir_analysis/src/check/intrinsicck.rs index cd7e9917204..ba627c740df 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsicck.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsicck.rs @@ -307,7 +307,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> { if let Err(msg) = reg.validate( asm_arch, self.tcx.sess.relocation_model(), - &target_features, + target_features, &self.tcx.sess.target, op.is_clobber(), ) { @@ -382,7 +382,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> { asm.template, true, None, - &target_features, + target_features, ); } hir::InlineAsmOperand::Out { reg, late: _, expr } => { @@ -394,7 +394,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> { asm.template, false, None, - &target_features, + target_features, ); } } @@ -406,7 +406,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> { asm.template, false, None, - &target_features, + target_features, ); } hir::InlineAsmOperand::SplitInOut { reg, late: _, in_expr, out_expr } => { @@ -417,7 +417,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> { asm.template, true, None, - &target_features, + target_features, ); if let Some(out_expr) = out_expr { self.check_asm_operand_type( @@ -427,7 +427,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> { asm.template, false, Some((in_expr, in_ty)), - &target_features, + target_features, ); } } diff --git a/compiler/rustc_hir_analysis/src/check/region.rs b/compiler/rustc_hir_analysis/src/check/region.rs index 40b33117f7c..9557568b387 100644 --- a/compiler/rustc_hir_analysis/src/check/region.rs +++ b/compiler/rustc_hir_analysis/src/check/region.rs @@ -414,11 +414,11 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h // then we'll assign too low a count to any `yield` expressions // we encounter in 'right_expression' - they should really occur after all of the // expressions in 'left_expression'. - visitor.visit_expr(&right_expr); + visitor.visit_expr(right_expr); visitor.pessimistic_yield = prev_pessimistic; debug!("resolve_expr - restoring pessimistic_yield to {}", prev_pessimistic); - visitor.visit_expr(&left_expr); + visitor.visit_expr(left_expr); debug!("resolve_expr - fixing up counts to {}", visitor.expr_and_pat_count); // Remove and process any scopes pushed by the visitor @@ -582,7 +582,7 @@ fn resolve_local<'tcx>( // due to rule C. if let Some(expr) = init { - record_rvalue_scope_if_borrow_expr(visitor, &expr, blk_scope); + record_rvalue_scope_if_borrow_expr(visitor, expr, blk_scope); if let Some(pat) = pat { if is_binding_pat(pat) { @@ -645,21 +645,19 @@ fn resolve_local<'tcx>( match pat.kind { PatKind::Binding(hir::BindingAnnotation(hir::ByRef::Yes, _), ..) => true, - PatKind::Struct(_, field_pats, _) => { - field_pats.iter().any(|fp| is_binding_pat(&fp.pat)) - } + PatKind::Struct(_, field_pats, _) => field_pats.iter().any(|fp| is_binding_pat(fp.pat)), PatKind::Slice(pats1, pats2, pats3) => { - pats1.iter().any(|p| is_binding_pat(&p)) - || pats2.iter().any(|p| is_binding_pat(&p)) - || pats3.iter().any(|p| is_binding_pat(&p)) + pats1.iter().any(|p| is_binding_pat(p)) + || pats2.iter().any(|p| is_binding_pat(p)) + || pats3.iter().any(|p| is_binding_pat(p)) } PatKind::Or(subpats) | PatKind::TupleStruct(_, subpats, _) - | PatKind::Tuple(subpats, _) => subpats.iter().any(|p| is_binding_pat(&p)), + | PatKind::Tuple(subpats, _) => subpats.iter().any(|p| is_binding_pat(p)), - PatKind::Box(subpat) => is_binding_pat(&subpat), + PatKind::Box(subpat) => is_binding_pat(subpat), PatKind::Ref(_, _) | PatKind::Binding(hir::BindingAnnotation(hir::ByRef::No, _), ..) @@ -700,20 +698,20 @@ fn resolve_local<'tcx>( } hir::ExprKind::Struct(_, fields, _) => { for field in fields { - record_rvalue_scope_if_borrow_expr(visitor, &field.expr, blk_id); + record_rvalue_scope_if_borrow_expr(visitor, field.expr, blk_id); } } hir::ExprKind::Array(subexprs) | hir::ExprKind::Tup(subexprs) => { for subexpr in subexprs { - record_rvalue_scope_if_borrow_expr(visitor, &subexpr, blk_id); + record_rvalue_scope_if_borrow_expr(visitor, subexpr, blk_id); } } hir::ExprKind::Cast(subexpr, _) => { - record_rvalue_scope_if_borrow_expr(visitor, &subexpr, blk_id) + record_rvalue_scope_if_borrow_expr(visitor, subexpr, blk_id) } hir::ExprKind::Block(block, _) => { if let Some(subexpr) = block.expr { - record_rvalue_scope_if_borrow_expr(visitor, &subexpr, blk_id); + record_rvalue_scope_if_borrow_expr(visitor, subexpr, blk_id); } } hir::ExprKind::Call(..) | hir::ExprKind::MethodCall(..) => { @@ -795,13 +793,13 @@ impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> { // The arguments and `self` are parented to the fn. self.cx.var_parent = self.cx.parent.take(); for param in body.params { - self.visit_pat(¶m.pat); + self.visit_pat(param.pat); } // The body of the every fn is a root scope. self.cx.parent = self.cx.var_parent; if self.tcx.hir().body_owner_kind(owner_id).is_fn_or_closure() { - self.visit_expr(&body.value) + self.visit_expr(body.value) } else { // Only functions have an outer terminating (drop) scope, while // temporaries in constant initializers may be 'static, but only @@ -822,7 +820,7 @@ impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> { // (i.e., `'static`), which means that after `g` returns, it drops, // and all the associated destruction scope rules apply. self.cx.var_parent = None; - resolve_local(self, None, Some(&body.value)); + resolve_local(self, None, Some(body.value)); } if body.coroutine_kind.is_some() { @@ -849,7 +847,7 @@ impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> { resolve_expr(self, ex); } fn visit_local(&mut self, l: &'tcx Local<'tcx>) { - resolve_local(self, Some(&l.pat), l.init) + resolve_local(self, Some(l.pat), l.init) } } diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index d7b50d127cd..177e4611cc9 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -584,7 +584,7 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable>>( // reflected in a where clause on the GAT itself. for (ty, ty_idx) in &types { // In our example, requires that `Self: 'a` - if ty_known_to_outlive(tcx, item_def_id, param_env, &wf_tys, *ty, *region_a) { + if ty_known_to_outlive(tcx, item_def_id, param_env, wf_tys, *ty, *region_a) { debug!(?ty_idx, ?region_a_idx); debug!("required clause: {ty} must outlive {region_a}"); // Translate into the generic parameters of the GAT. In @@ -623,7 +623,7 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable>>( if matches!(**region_b, ty::ReStatic | ty::ReError(_)) || region_a == region_b { continue; } - if region_known_to_outlive(tcx, item_def_id, param_env, &wf_tys, *region_a, *region_b) { + if region_known_to_outlive(tcx, item_def_id, param_env, wf_tys, *region_a, *region_b) { debug!(?region_a_idx, ?region_b_idx); debug!("required clause: {region_a} must outlive {region_b}"); // Translate into the generic parameters of the GAT. @@ -671,7 +671,7 @@ fn ty_known_to_outlive<'tcx>( ty: Ty<'tcx>, region: ty::Region<'tcx>, ) -> bool { - resolve_regions_with_wf_tys(tcx, id, param_env, &wf_tys, |infcx, region_bound_pairs| { + resolve_regions_with_wf_tys(tcx, id, param_env, wf_tys, |infcx, region_bound_pairs| { let origin = infer::RelateParamBound(DUMMY_SP, ty, None); let outlives = &mut TypeOutlives::new(infcx, tcx, region_bound_pairs, None, param_env); outlives.type_must_outlive(origin, ty, region, ConstraintCategory::BoringNoLocation); @@ -688,7 +688,7 @@ fn region_known_to_outlive<'tcx>( region_a: ty::Region<'tcx>, region_b: ty::Region<'tcx>, ) -> bool { - resolve_regions_with_wf_tys(tcx, id, param_env, &wf_tys, |mut infcx, _| { + resolve_regions_with_wf_tys(tcx, id, param_env, wf_tys, |mut infcx, _| { use rustc_infer::infer::outlives::obligations::TypeOutlivesDelegate; let origin = infer::RelateRegionParamBound(DUMMY_SP); // `region_a: region_b` -> `region_b <= region_a` diff --git a/compiler/rustc_hir_analysis/src/coherence/orphan.rs b/compiler/rustc_hir_analysis/src/coherence/orphan.rs index 8d87cb57b90..7c1086bf4b4 100644 --- a/compiler/rustc_hir_analysis/src/coherence/orphan.rs +++ b/compiler/rustc_hir_analysis/src/coherence/orphan.rs @@ -58,7 +58,7 @@ fn do_orphan_check_impl<'tcx>( tr.path.span, trait_ref, impl_.self_ty.span, - &impl_.generics, + impl_.generics, err, )? } diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 7b5b049d254..60bd7e1bdc1 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -1090,7 +1090,7 @@ fn is_suggestable_infer_ty(ty: &hir::Ty<'_>) -> bool { pub fn get_infer_ret_ty<'hir>(output: &'hir hir::FnRetTy<'hir>) -> Option<&'hir hir::Ty<'hir>> { if let hir::FnRetTy::Return(ty) = output { if is_suggestable_infer_ty(ty) { - return Some(&*ty); + return Some(*ty); } } None @@ -1373,7 +1373,7 @@ fn impl_trait_ref( if let Some(ErrorGuaranteed { .. }) = check_impl_constness( tcx, tcx.is_const_trait_impl_raw(def_id.to_def_id()), - &ast_trait_ref, + ast_trait_ref, ) { // we have a const impl, but for a trait without `#[const_trait]`, so // without the host param. If we continue with the HIR trait ref, we get @@ -1394,7 +1394,7 @@ fn impl_trait_ref( let trait_ref = hir::TraitRef { path: &path, hir_ref_id: ast_trait_ref.hir_ref_id }; icx.astconv().instantiate_mono_trait_ref(&trait_ref, selfty) } else { - icx.astconv().instantiate_mono_trait_ref(&ast_trait_ref, selfty) + icx.astconv().instantiate_mono_trait_ref(ast_trait_ref, selfty) } }) .map(ty::EarlyBinder::bind) diff --git a/compiler/rustc_hir_analysis/src/collect/generics_of.rs b/compiler/rustc_hir_analysis/src/collect/generics_of.rs index 3d60c57b9d5..97f60c98675 100644 --- a/compiler/rustc_hir_analysis/src/collect/generics_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/generics_of.rs @@ -182,7 +182,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { } let no_generics = hir::Generics::empty(); - let ast_generics = node.generics().unwrap_or(&no_generics); + let ast_generics = node.generics().unwrap_or(no_generics); let (opt_self, allow_defaults) = match node { Node::Item(item) => { match item.kind { @@ -458,11 +458,11 @@ fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx>, node: Node<'tcx>) -> Option match &item.kind { - hir::TraitItemKind::Fn(sig, _) => has_late_bound_regions(tcx, &item.generics, sig.decl), + hir::TraitItemKind::Fn(sig, _) => has_late_bound_regions(tcx, item.generics, sig.decl), _ => None, }, Node::ImplItem(item) => match &item.kind { - hir::ImplItemKind::Fn(sig, _) => has_late_bound_regions(tcx, &item.generics, sig.decl), + hir::ImplItemKind::Fn(sig, _) => has_late_bound_regions(tcx, item.generics, sig.decl), _ => None, }, Node::ForeignItem(item) => match item.kind { diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs index 68d040d5846..92c383f3703 100644 --- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs @@ -290,7 +290,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen } hir::WherePredicate::RegionPredicate(region_pred) => { - let r1 = icx.astconv().ast_region_to_region(®ion_pred.lifetime, None); + let r1 = icx.astconv().ast_region_to_region(region_pred.lifetime, None); predicates.extend(region_pred.bounds.iter().map(|bound| { let (r2, span) = match bound { hir::GenericBound::Outlives(lt) => { @@ -714,9 +714,9 @@ pub(super) fn type_param_predicates( let item_hir_id = tcx.hir().local_def_id_to_hir_id(item_def_id); let ast_generics = match tcx.hir().get(item_hir_id) { - Node::TraitItem(item) => &item.generics, + Node::TraitItem(item) => item.generics, - Node::ImplItem(item) => &item.generics, + Node::ImplItem(item) => item.generics, Node::Item(item) => { match item.kind { diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs index 53efc2c6e82..bfabf967ebc 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -565,7 +565,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { let mut bound_vars = FxIndexMap::default(); debug!(?generics.params); for param in generics.params { - let (def_id, reg) = ResolvedArg::early(¶m); + let (def_id, reg) = ResolvedArg::early(param); bound_vars.insert(def_id, reg); } @@ -684,7 +684,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { lifetime: self.map.defs.get(&lifetime_ref.hir_id).cloned(), s: self.scope, }; - self.with(scope, |this| this.visit_ty(&mt.ty)); + self.with(scope, |this| this.visit_ty(mt.ty)); } hir::TyKind::OpaqueDef(item_id, lifetimes, _in_trait) => { // Resolve the lifetimes in the bounds to the lifetime defs in the generics. @@ -775,7 +775,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { } Type(bounds, ty) => { self.visit_early(trait_item.hir_id(), trait_item.generics, |this| { - this.visit_generics(&trait_item.generics); + this.visit_generics(trait_item.generics); for bound in bounds { this.visit_param_bound(bound); } @@ -847,7 +847,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { hir::FnRetTy::DefaultReturn(_) => None, hir::FnRetTy::Return(ty) => Some(ty), }; - self.visit_fn_like_elision(&fd.inputs, output, matches!(fk, intravisit::FnKind::Closure)); + self.visit_fn_like_elision(fd.inputs, output, matches!(fk, intravisit::FnKind::Closure)); intravisit::walk_fn_kind(self, fk); self.visit_nested_body(body_id) } @@ -894,7 +894,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { }; self.with(scope, |this| { walk_list!(this, visit_generic_param, bound_generic_params); - this.visit_ty(&bounded_ty); + this.visit_ty(bounded_ty); walk_list!(this, visit_param_bound, bounds); }) } @@ -1061,7 +1061,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> { { let BoundVarContext { tcx, map, .. } = self; let mut this = BoundVarContext { tcx: *tcx, map, scope: &wrap_scope }; - let span = debug_span!("scope", scope = ?TruncatedScopeDebug(&this.scope)); + let span = debug_span!("scope", scope = ?TruncatedScopeDebug(this.scope)); { let _enter = span.enter(); f(&mut this); diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index 5f82d9f06c6..0148c71dbb5 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -59,7 +59,7 @@ impl PpAnn for &dyn rustc_hir::intravisit::Map<'_> { Nested::TraitItem(id) => state.print_trait_item(self.trait_item(id)), Nested::ImplItem(id) => state.print_impl_item(self.impl_item(id)), Nested::ForeignItem(id) => state.print_foreign_item(self.foreign_item(id)), - Nested::Body(id) => state.print_expr(&self.body(id).value), + Nested::Body(id) => state.print_expr(self.body(id).value), Nested::BodyParamPat(id, i) => state.print_pat(self.body(id).params[i].pat), } } @@ -88,14 +88,14 @@ impl<'a> State<'a> { Node::AnonConst(a) => self.print_anon_const(a), Node::ConstBlock(a) => self.print_inline_const(a), Node::Expr(a) => self.print_expr(a), - Node::ExprField(a) => self.print_expr_field(&a), + Node::ExprField(a) => self.print_expr_field(a), Node::Stmt(a) => self.print_stmt(a), Node::PathSegment(a) => self.print_path_segment(a), Node::Ty(a) => self.print_type(a), Node::TypeBinding(a) => self.print_type_binding(a), Node::TraitRef(a) => self.print_trait_ref(a), Node::Pat(a) => self.print_pat(a), - Node::PatField(a) => self.print_patfield(&a), + Node::PatField(a) => self.print_patfield(a), Node::Arm(a) => self.print_arm(a), Node::Infer(_) => self.word("_"), Node::Block(a) => { @@ -260,7 +260,7 @@ impl<'a> State<'a> { self.word("*"); self.print_mt(mt, true); } - hir::TyKind::Ref(ref lifetime, ref mt) => { + hir::TyKind::Ref(lifetime, ref mt) => { self.word("&"); self.print_opt_lifetime(lifetime); self.print_mt(mt, false); @@ -281,7 +281,7 @@ impl<'a> State<'a> { } hir::TyKind::OpaqueDef(..) => self.word("/*impl Trait*/"), hir::TyKind::Path(ref qpath) => self.print_qpath(qpath, false), - hir::TyKind::TraitObject(bounds, ref lifetime, syntax) => { + hir::TyKind::TraitObject(bounds, lifetime, syntax) => { if syntax == ast::TraitObjectSyntax::Dyn { self.word_space("dyn"); } @@ -517,10 +517,10 @@ impl<'a> State<'a> { self.end(); // need to close a box self.ann.nested(self, Nested::Body(body)); } - hir::ItemKind::Macro(ref macro_def, _) => { + hir::ItemKind::Macro(macro_def, _) => { self.print_mac_def(macro_def, &item.ident, item.span, |_| {}); } - hir::ItemKind::Mod(ref _mod) => { + hir::ItemKind::Mod(_mod) => { self.head("mod"); self.print_ident(item.ident); self.nbsp(); @@ -549,7 +549,7 @@ impl<'a> State<'a> { state.print_type(ty); }); } - hir::ItemKind::OpaqueTy(ref opaque_ty) => { + hir::ItemKind::OpaqueTy(opaque_ty) => { self.print_item_type(item, opaque_ty.generics, |state| { let mut real_bounds = Vec::with_capacity(opaque_ty.bounds.len()); for b in opaque_ty.bounds { @@ -1096,12 +1096,12 @@ impl<'a> State<'a> { self.space(); } self.cbox(INDENT_UNIT); - self.print_outer_attributes(&self.attrs(field.hir_id)); + self.print_outer_attributes(self.attrs(field.hir_id)); if !field.is_shorthand { self.print_ident(field.ident); self.word_space(":"); } - self.print_expr(&field.expr); + self.print_expr(field.expr); self.end() } @@ -1131,7 +1131,7 @@ impl<'a> State<'a> { args: &[hir::Expr<'_>], ) { let base_args = args; - self.print_expr_maybe_paren(&receiver, parser::PREC_POSTFIX); + self.print_expr_maybe_paren(receiver, parser::PREC_POSTFIX); self.word("."); self.print_ident(segment.ident); @@ -1217,7 +1217,7 @@ impl<'a> State<'a> { self.commasep(Consistent, &args, |s, arg| match *arg { AsmArg::Template(ref template) => s.print_string(template, ast::StrStyle::Cooked), AsmArg::Operand(op) => match *op { - hir::InlineAsmOperand::In { reg, ref expr } => { + hir::InlineAsmOperand::In { reg, expr } => { s.word("in"); s.popen(); s.word(format!("{reg}")); @@ -1236,7 +1236,7 @@ impl<'a> State<'a> { None => s.word("_"), } } - hir::InlineAsmOperand::InOut { reg, late, ref expr } => { + hir::InlineAsmOperand::InOut { reg, late, expr } => { s.word(if late { "inlateout" } else { "inout" }); s.popen(); s.word(format!("{reg}")); @@ -1244,7 +1244,7 @@ impl<'a> State<'a> { s.space(); s.print_expr(expr); } - hir::InlineAsmOperand::SplitInOut { reg, late, ref in_expr, ref out_expr } => { + hir::InlineAsmOperand::SplitInOut { reg, late, in_expr, ref out_expr } => { s.word(if late { "inlateout" } else { "inout" }); s.popen(); s.word(format!("{reg}")); @@ -1350,7 +1350,7 @@ impl<'a> State<'a> { hir::ExprKind::AddrOf(k, m, expr) => { self.print_expr_addr_of(k, m, expr); } - hir::ExprKind::Lit(ref lit) => { + hir::ExprKind::Lit(lit) => { self.print_literal(lit); } hir::ExprKind::Cast(expr, ty) => { @@ -1516,7 +1516,7 @@ impl<'a> State<'a> { self.word("asm!"); self.print_inline_asm(asm); } - hir::ExprKind::OffsetOf(container, ref fields) => { + hir::ExprKind::OffsetOf(container, fields) => { self.word("offset_of!("); self.print_type(container); self.word(","); @@ -1764,7 +1764,7 @@ impl<'a> State<'a> { if !empty { self.space(); } - self.commasep_cmnt(Consistent, &fields, |s, f| s.print_patfield(f), |f| f.pat.span); + self.commasep_cmnt(Consistent, fields, |s, f| s.print_patfield(f), |f| f.pat.span); if etc { if !fields.is_empty() { self.word_space(","); @@ -1864,7 +1864,7 @@ impl<'a> State<'a> { self.space(); } self.cbox(INDENT_UNIT); - self.print_outer_attributes(&self.attrs(field.hir_id)); + self.print_outer_attributes(self.attrs(field.hir_id)); if !field.is_shorthand { self.print_ident(field.ident); self.word_nbsp(":"); @@ -2164,7 +2164,7 @@ impl<'a> State<'a> { self.print_bounds(":", bounds); } hir::WherePredicate::RegionPredicate(hir::WhereRegionPredicate { - ref lifetime, + lifetime, bounds, .. }) => { diff --git a/compiler/rustc_hir_typeck/src/_match.rs b/compiler/rustc_hir_typeck/src/_match.rs index 84e986488a6..a29d9c95e5e 100644 --- a/compiler/rustc_hir_typeck/src/_match.rs +++ b/compiler/rustc_hir_typeck/src/_match.rs @@ -42,7 +42,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // #55810: Type check patterns first so we get types for all bindings. let scrut_span = scrut.span.find_ancestor_inside(expr.span).unwrap_or(scrut.span); for arm in arms { - self.check_pat_top(&arm.pat, scrutinee_ty, Some(scrut_span), Some(scrut), None); + self.check_pat_top(arm.pat, scrutinee_ty, Some(scrut_span), Some(scrut), None); } // Now typecheck the blocks. @@ -92,7 +92,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.diverges.set(Diverges::Maybe); - let arm_ty = self.check_expr_with_expectation(&arm.body, expected); + let arm_ty = self.check_expr_with_expectation(arm.body, expected); all_arms_diverge &= self.diverges.get(); let opt_suggest_box_span = prior_arm.and_then(|(_, prior_arm_ty, _)| { @@ -137,7 +137,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { coercion.coerce_inner( self, &cause, - Some(&arm.body), + Some(arm.body), arm_ty, |err| self.suggest_removing_semicolon_for_coerce(err, expr, arm_ty, prior_arm), false, diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 173186e6d9f..d40ac59baa4 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -649,7 +649,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { hir::ExprKind::Path(ref qpath) => { self.typeck_results.borrow().qpath_res(qpath, callee_expr.hir_id) } - hir::ExprKind::Call(ref inner_callee, _) => { + hir::ExprKind::Call(inner_callee, _) => { if let hir::ExprKind::Path(ref inner_qpath) = inner_callee.kind { inner_callee_path = Some(inner_qpath); self.typeck_results.borrow().qpath_res(inner_qpath, inner_callee.hir_id) diff --git a/compiler/rustc_hir_typeck/src/cast.rs b/compiler/rustc_hir_typeck/src/cast.rs index ee23f47c271..00af6d46213 100644 --- a/compiler/rustc_hir_typeck/src/cast.rs +++ b/compiler/rustc_hir_typeck/src/cast.rs @@ -101,7 +101,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Ok(match *t.kind() { ty::Slice(_) | ty::Str => Some(PointerKind::Length), - ty::Dynamic(ref tty, _, ty::Dyn) => Some(PointerKind::VTable(tty.principal_def_id())), + ty::Dynamic(tty, _, ty::Dyn) => Some(PointerKind::VTable(tty.principal_def_id())), ty::Adt(def, args) if def.is_struct() => match def.non_enum_variant().tail_opt() { None => Some(PointerKind::Thin), Some(f) => { @@ -506,7 +506,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { }; SizedUnsizedCast { - sess: &fcx.tcx.sess, + sess: fcx.tcx.sess, span: self.span, expr_ty: self.expr_ty, cast_ty: fcx.ty_to_string(self.cast_ty), diff --git a/compiler/rustc_hir_typeck/src/check.rs b/compiler/rustc_hir_typeck/src/check.rs index 1edc3efbc77..d13ae2c2094 100644 --- a/compiler/rustc_hir_typeck/src/check.rs +++ b/compiler/rustc_hir_typeck/src/check.rs @@ -76,7 +76,7 @@ pub(super) fn check_fn<'a, 'tcx>( fcx.resume_yield_tys = Some((resume_ty, yield_ty)); } - GatherLocalsVisitor::new(&fcx).visit_body(body); + GatherLocalsVisitor::new(fcx).visit_body(body); // C-variadic fns also have a `VaList` input that's not listed in `fn_sig` // (as it's created inside the body itself, not passed in from outside). @@ -94,7 +94,7 @@ pub(super) fn check_fn<'a, 'tcx>( for (idx, (param_ty, param)) in inputs_fn.chain(maybe_va_list).zip(body.params).enumerate() { // Check the pattern. let ty_span = try { inputs_hir?.get(idx)?.span }; - fcx.check_pat_top(¶m.pat, param_ty, ty_span, None, None); + fcx.check_pat_top(param.pat, param_ty, ty_span, None, None); // Check that argument is Sized. if !params_can_be_unsized { @@ -123,7 +123,7 @@ pub(super) fn check_fn<'a, 'tcx>( hir::FnRetTy::Return(ty) => ty.span, }; fcx.require_type_is_sized(declared_ret_ty, return_or_body_span, traits::SizedReturnType); - fcx.check_return_expr(&body.value, false); + fcx.check_return_expr(body.value, false); // We insert the deferred_coroutine_interiors entry after visiting the body. // This ensures that all nested coroutines appear before the entry of this coroutine. @@ -156,7 +156,7 @@ pub(super) fn check_fn<'a, 'tcx>( // really expected to fail, since the coercions would have failed // earlier when trying to find a LUB. let coercion = fcx.ret_coercion.take().unwrap().into_inner(); - let mut actual_return_ty = coercion.complete(&fcx); + let mut actual_return_ty = coercion.complete(fcx); debug!("actual_return_ty = {:?}", actual_return_ty); if let ty::Dynamic(..) = declared_ret_ty.kind() { // We have special-cased the case where the function is declared diff --git a/compiler/rustc_hir_typeck/src/closure.rs b/compiler/rustc_hir_typeck/src/closure.rs index 7807ff6547d..d818bb1dfaa 100644 --- a/compiler/rustc_hir_typeck/src/closure.rs +++ b/compiler/rustc_hir_typeck/src/closure.rs @@ -181,7 +181,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .iter_instantiated_copied(self.tcx, args) .map(|(c, s)| (c.as_predicate(), s)), ), - ty::Dynamic(ref object_type, ..) => { + ty::Dynamic(object_type, ..) => { let sig = object_type.projection_bounds().find_map(|pb| { let pb = pb.with_self_ty(self.tcx, self.tcx.types.trait_object_dummy_self); self.deduce_sig_from_projection(None, pb) @@ -630,7 +630,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // First, convert the types that the user supplied (if any). let supplied_arguments = decl.inputs.iter().map(|a| astconv.ast_ty_to_ty(a)); let supplied_return = match decl.output { - hir::FnRetTy::Return(ref output) => astconv.ast_ty_to_ty(&output), + hir::FnRetTy::Return(ref output) => astconv.ast_ty_to_ty(output), hir::FnRetTy::DefaultReturn(_) => match body.coroutine_kind { // In the case of the async block that we create for a function body, // we expect the return type of the block to match that of the enclosing @@ -819,7 +819,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }); if let hir::FnRetTy::Return(ref output) = decl.output { - astconv.ast_ty_to_ty(&output); + astconv.ast_ty_to_ty(output); } let result = ty::Binder::dummy(self.tcx.mk_fn_sig( diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 6c03bc3b57a..971f10631df 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -85,7 +85,7 @@ struct Coerce<'a, 'tcx> { impl<'a, 'tcx> Deref for Coerce<'a, 'tcx> { type Target = FnCtxt<'a, 'tcx>; fn deref(&self) -> &Self::Target { - &self.fcx + self.fcx } } @@ -158,7 +158,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { if self.next_trait_solver() { if let Ok(res) = &res { for obligation in &res.obligations { - if !self.predicate_may_hold(&obligation) { + if !self.predicate_may_hold(obligation) { return Err(TypeError::Mismatch); } } @@ -1510,7 +1510,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { expression, expression_ty, ), - Expressions::UpFront(ref coercion_sites) => fcx.try_find_coercion_lub( + Expressions::UpFront(coercion_sites) => fcx.try_find_coercion_lub( cause, &coercion_sites[0..self.pushed], self.merged_ty(), @@ -1665,7 +1665,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { if visitor.ret_exprs.len() > 0 && let Some(expr) = expression { - self.note_unreachable_loop_return(&mut err, &expr, &visitor.ret_exprs); + self.note_unreachable_loop_return(&mut err, expr, &visitor.ret_exprs); } let reported = err.emit_unless(unsized_return); @@ -1772,7 +1772,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { if blk_id.is_none() { fcx.suggest_missing_return_type( &mut err, - &fn_decl, + fn_decl, expected, found, can_suggest, @@ -1871,6 +1871,6 @@ impl AsCoercionSite for ! { impl AsCoercionSite for hir::Arm<'_> { fn as_coercion_site(&self) -> &hir::Expr<'_> { - &self.body + self.body } } diff --git a/compiler/rustc_hir_typeck/src/demand.rs b/compiler/rustc_hir_typeck/src/demand.rs index 386e4b4642a..41d88e246af 100644 --- a/compiler/rustc_hir_typeck/src/demand.rs +++ b/compiler/rustc_hir_typeck/src/demand.rs @@ -184,7 +184,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.register_predicates(obligations); None } - Err(e) => Some(self.err_ctxt().report_mismatched_types(&cause, expected, actual, e)), + Err(e) => Some(self.err_ctxt().report_mismatched_types(cause, expected, actual, e)), } } diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 4b7de36e7c7..f74000571ac 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -277,7 +277,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let tcx = self.tcx; match expr.kind { - ExprKind::Lit(ref lit) => self.check_lit(&lit, expected), + ExprKind::Lit(ref lit) => self.check_lit(lit, expected), ExprKind::Binary(op, lhs, rhs) => self.check_binop(expr, op, lhs, rhs, expected), ExprKind::Assign(lhs, rhs, span) => { self.check_expr_assign(expr, expected, lhs, rhs, span) @@ -298,9 +298,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.deferred_asm_checks.borrow_mut().push((asm, expr.hir_id)); self.check_expr_asm(asm) } - ExprKind::OffsetOf(container, ref fields) => { - self.check_offset_of(container, fields, expr) - } + ExprKind::OffsetOf(container, fields) => self.check_offset_of(container, fields, expr), ExprKind::Break(destination, ref expr_opt) => { self.check_expr_break(destination, expr_opt.as_deref(), expr) } @@ -319,17 +317,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.check_expr_loop(body, source, expected, expr) } ExprKind::Match(discrim, arms, match_src) => { - self.check_match(expr, &discrim, arms, expected, match_src) + self.check_match(expr, discrim, arms, expected, match_src) } ExprKind::Closure(closure) => self.check_expr_closure(closure, expr.span, expected), - ExprKind::Block(body, _) => self.check_block_with_expected(&body, expected), - ExprKind::Call(callee, args) => self.check_call(expr, &callee, args, expected), + ExprKind::Block(body, _) => self.check_block_with_expected(body, expected), + ExprKind::Call(callee, args) => self.check_call(expr, callee, args, expected), ExprKind::MethodCall(segment, receiver, args, _) => { self.check_method_call(expr, segment, receiver, args, expected) } ExprKind::Cast(e, t) => self.check_expr_cast(e, t, expr), ExprKind::Type(e, t) => { - let ascribed_ty = self.to_ty_saving_user_provided_ty(&t); + let ascribed_ty = self.to_ty_saving_user_provided_ty(t); let ty = self.check_expr_with_hint(e, ascribed_ty); self.demand_eqtype(e.span, ascribed_ty, ty); ascribed_ty @@ -347,7 +345,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ExprKind::Struct(qpath, fields, ref base_expr) => { self.check_expr_struct(expr, expected, qpath, fields, base_expr) } - ExprKind::Field(base, field) => self.check_field(expr, &base, field, expected), + ExprKind::Field(base, field) => self.check_field(expr, base, field, expected), ExprKind::Index(base, idx, brackets_span) => { self.check_expr_index(base, idx, expr, brackets_span) } @@ -368,7 +366,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { hir::UnOp::Not | hir::UnOp::Neg => expected, hir::UnOp::Deref => NoExpectation, }; - let mut oprnd_t = self.check_expr_with_expectation(&oprnd, expected_inner); + let mut oprnd_t = self.check_expr_with_expectation(oprnd, expected_inner); if !oprnd_t.references_error() { oprnd_t = self.structurally_resolve_type(expr.span, oprnd_t); @@ -436,7 +434,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } }); let ty = - self.check_expr_with_expectation_and_needs(&oprnd, hint, Needs::maybe_mut_place(mutbl)); + self.check_expr_with_expectation_and_needs(oprnd, hint, Needs::maybe_mut_place(mutbl)); let tm = ty::TypeAndMut { ty, mutbl }; match kind { @@ -663,7 +661,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; if let Some(ref mut coerce) = ctxt.coerce { - if let Some(ref e) = expr_opt { + if let Some(e) = expr_opt { coerce.coerce(self, &cause, e, e_ty); } else { assert!(e_ty.is_unit()); @@ -671,12 +669,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { coerce.coerce_forced_unit( self, &cause, - |mut err| { - self.suggest_mismatched_types_on_tail( - &mut err, expr, ty, e_ty, target_id, - ); + |err| { + self.suggest_mismatched_types_on_tail(err, expr, ty, e_ty, target_id); let error = Some(Sorts(ExpectedFound { expected: ty, found: e_ty })); - self.annotate_loop_expected_due_to_inference(&mut err, expr, error); + self.annotate_loop_expected_due_to_inference(err, expr, error); if let Some(val) = ty_kind_suggestion(ty) { err.span_suggestion_verbose( expr.span.shrink_to_hi(), @@ -1136,8 +1132,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // The likely cause of this is `if foo = bar { .. }`. let actual_ty = Ty::new_unit(self.tcx); let mut err = self.demand_suptype_diag(expr.span, expected_ty, actual_ty).unwrap(); - let lhs_ty = self.check_expr(&lhs); - let rhs_ty = self.check_expr(&rhs); + let lhs_ty = self.check_expr(lhs); + let rhs_ty = self.check_expr(rhs); let (applicability, eq) = if self.can_coerce(rhs_ty, lhs_ty) { (Applicability::MachineApplicable, true) } else if let ExprKind::Binary( @@ -1148,7 +1144,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { { // if x == 1 && y == 2 { .. } // + - let actual_lhs_ty = self.check_expr(&rhs_expr); + let actual_lhs_ty = self.check_expr(rhs_expr); (Applicability::MaybeIncorrect, self.can_coerce(rhs_ty, actual_lhs_ty)) } else if let ExprKind::Binary( Spanned { node: hir::BinOpKind::And | hir::BinOpKind::Or, .. }, @@ -1158,7 +1154,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { { // if x == 1 && y == 2 { .. } // + - let actual_rhs_ty = self.check_expr(&lhs_expr); + let actual_rhs_ty = self.check_expr(lhs_expr); (Applicability::MaybeIncorrect, self.can_coerce(actual_rhs_ty, lhs_ty)) } else { (Applicability::MaybeIncorrect, false) @@ -1195,7 +1191,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return Ty::new_error(self.tcx, reported); } - let lhs_ty = self.check_expr_with_needs(&lhs, Needs::MutPlace); + let lhs_ty = self.check_expr_with_needs(lhs, Needs::MutPlace); let suggest_deref_binop = |err: &mut Diagnostic, rhs_ty: Ty<'tcx>| { if let Some(lhs_deref_ty) = self.deref_once_mutably_for_diagnostic(lhs_ty) { @@ -1222,7 +1218,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // This is (basically) inlined `check_expr_coercible_to_type`, but we want // to suggest an additional fixup here in `suggest_deref_binop`. - let rhs_ty = self.check_expr_with_hint(&rhs, lhs_ty); + let rhs_ty = self.check_expr_with_hint(rhs, lhs_ty); if let (_, Some(mut diag)) = self.demand_coerce_diag(rhs, rhs_ty, lhs_ty, Some(lhs), AllowTwoPhase::No) { @@ -1283,7 +1279,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; let (ctxt, ()) = self.with_breakable_ctxt(expr.hir_id, ctxt, || { - self.check_block_no_value(&body); + self.check_block_no_value(body); }); if ctxt.may_break { @@ -1313,7 +1309,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { args: &'tcx [hir::Expr<'tcx>], expected: Expectation<'tcx>, ) -> Ty<'tcx> { - let rcvr_t = self.check_expr(&rcvr); + let rcvr_t = self.check_expr(rcvr); // no need to check for bot/err -- callee does that let rcvr_t = self.structurally_resolve_type(rcvr.span, rcvr_t); let span = segment.ident.span; @@ -1347,7 +1343,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; // Call the generic checker. - self.check_method_argument_types(span, expr, method, &args, DontTupleArguments, expected) + self.check_method_argument_types(span, expr, method, args, DontTupleArguments, expected) } fn check_expr_cast( @@ -1478,7 +1474,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let fcx = FnCtxt::new(self, self.param_env, def_id); crate::GatherLocalsVisitor::new(&fcx).visit_body(body); - let ty = fcx.check_expr_with_expectation(&body.value, expected); + let ty = fcx.check_expr_with_expectation(body.value, expected); fcx.require_type_is_sized(ty, body.value.span, traits::ConstSized); fcx.write_ty(block.hir_id, ty); ty @@ -1507,7 +1503,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let (element_ty, t) = match uty { Some(uty) => { - self.check_expr_coercible_to_type(&element, uty, None); + self.check_expr_coercible_to_type(element, uty, None); (uty, uty) } None => { @@ -1515,7 +1511,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { kind: TypeVariableOriginKind::MiscVariable, span: element.span, }); - let element_ty = self.check_expr_has_type_or_error(&element, ty, |_| {}); + let element_ty = self.check_expr_has_type_or_error(element, ty, |_| {}); (element_ty, ty) } }; @@ -1611,10 +1607,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let elt_ts_iter = elts.iter().enumerate().map(|(i, e)| match flds { Some(fs) if i < fs.len() => { let ety = fs[i]; - self.check_expr_coercible_to_type(&e, ety, None); + self.check_expr_coercible_to_type(e, ety, None); ety } - _ => self.check_expr_with_expectation(&e, NoExpectation), + _ => self.check_expr_with_expectation(e, NoExpectation), }); let tuple = Ty::new_tup_from_iter(self.tcx, elt_ts_iter); if let Err(guar) = tuple.error_reported() { @@ -1740,9 +1736,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Make sure to give a type to the field even if there's // an error, so we can continue type-checking. - let ty = self.check_expr_with_hint(&field.expr, field_type); + let ty = self.check_expr_with_hint(field.expr, field_type); let (_, diag) = - self.demand_coerce_diag(&field.expr, ty, field_type, None, AllowTwoPhase::No); + self.demand_coerce_diag(field.expr, ty, field_type, None, AllowTwoPhase::No); if let Some(mut diag) = diag { if idx == ast_fields.len() - 1 { @@ -1920,10 +1916,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { base_expr: &'tcx Option<&'tcx hir::Expr<'tcx>>, ) { for field in fields { - self.check_expr(&field.expr); + self.check_expr(field.expr); } if let Some(base) = *base_expr { - self.check_expr(&base); + self.check_expr(base); } } @@ -2952,8 +2948,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expr: &'tcx hir::Expr<'tcx>, brackets_span: Span, ) -> Ty<'tcx> { - let base_t = self.check_expr(&base); - let idx_t = self.check_expr(&idx); + let base_t = self.check_expr(base); + let idx_t = self.check_expr(idx); if base_t.references_error() { base_t @@ -2994,7 +2990,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut needs_note = true; // If the index is an integer, we can show the actual // fixed expression: - if let ExprKind::Lit(ref lit) = idx.kind + if let ExprKind::Lit(lit) = idx.kind && let ast::LitKind::Int(i, ast::LitIntType::Unsuffixed) = lit.node && i < types .len() @@ -3161,7 +3157,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) -> Ty<'tcx> { match self.resume_yield_tys { Some((resume_ty, yield_ty)) => { - self.check_expr_coercible_to_type(&value, yield_ty, None); + self.check_expr_coercible_to_type(value, yield_ty, None); resume_ty } @@ -3170,7 +3166,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // information. Hence, we check the source of the yield expression here and check its // value's type against `()` (this check should always hold). None if src.is_await() => { - self.check_expr_coercible_to_type(&value, Ty::new_unit(self.tcx), None); + self.check_expr_coercible_to_type(value, Ty::new_unit(self.tcx), None); Ty::new_unit(self.tcx) } _ => { diff --git a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs index 6be3ad6577b..587638f958a 100644 --- a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs +++ b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs @@ -147,7 +147,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { self.walk_irrefutable_pat(¶m_place, param.pat); } - self.consume_expr(&body.value); + self.consume_expr(body.value); } fn tcx(&self) -> TyCtxt<'tcx> { @@ -237,10 +237,10 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { self.consume_exprs(exprs); } - hir::ExprKind::If(ref cond_expr, ref then_expr, ref opt_else_expr) => { + hir::ExprKind::If(cond_expr, then_expr, ref opt_else_expr) => { self.consume_expr(cond_expr); self.consume_expr(then_expr); - if let Some(ref else_expr) = *opt_else_expr { + if let Some(else_expr) = *opt_else_expr { self.consume_expr(else_expr); } } @@ -249,7 +249,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { self.walk_local(init, pat, None, |t| t.borrow_expr(init, ty::ImmBorrow)) } - hir::ExprKind::Match(ref discr, arms, _) => { + hir::ExprKind::Match(discr, arms, _) => { let discr_place = return_if_err!(self.mc.cat_expr(discr)); return_if_err!(self.maybe_read_scrutinee( discr, @@ -267,7 +267,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { self.consume_exprs(exprs); } - hir::ExprKind::AddrOf(_, m, ref base) => { + hir::ExprKind::AddrOf(_, m, base) => { // &base // make sure that the thing we are pointing out stays valid // for the lifetime `scope_r` of the resulting ptr: @@ -379,7 +379,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { // only the fn body we were given. } - hir::StmtKind::Expr(ref expr) | hir::StmtKind::Semi(ref expr) => { + hir::StmtKind::Expr(expr) | hir::StmtKind::Semi(expr) => { self.consume_expr(expr); } } @@ -505,7 +505,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { )); self.walk_block(els) } - self.walk_irrefutable_pat(&expr_place, &pat); + self.walk_irrefutable_pat(&expr_place, pat); } /// Indicates that the value of `blk` will be consumed, meaning either copied or moved @@ -517,7 +517,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { self.walk_stmt(stmt); } - if let Some(ref tail_expr) = blk.expr { + if let Some(tail_expr) = blk.expr { self.consume_expr(tail_expr); } } @@ -665,8 +665,8 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { self.walk_pat(discr_place, arm.pat, arm.guard.is_some()); match arm.guard { - Some(hir::Guard::If(ref e)) => self.consume_expr(e), - Some(hir::Guard::IfLet(ref l)) => { + Some(hir::Guard::If(e)) => self.consume_expr(e), + Some(hir::Guard::IfLet(l)) => { self.walk_local(l.init, l.pat, None, |t| t.borrow_expr(l.init, ty::ImmBorrow)) } None => {} diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 750ed2c3491..551ea1ee11b 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -505,7 +505,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(in super::super) fn resolve_rvalue_scopes(&self, def_id: DefId) { let scope_tree = self.tcx.region_scope_tree(def_id); - let rvalue_scopes = { rvalue_scopes::resolve_rvalue_scopes(self, &scope_tree, def_id) }; + let rvalue_scopes = { rvalue_scopes::resolve_rvalue_scopes(self, scope_tree, def_id) }; let mut typeck_results = self.inh.typeck_results.borrow_mut(); typeck_results.rvalue_scopes = rvalue_scopes; } @@ -804,7 +804,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { qpath, hir_id, span ); let (ty, qself, item_segment) = match *qpath { - QPath::Resolved(ref opt_qself, ref path) => { + QPath::Resolved(ref opt_qself, path) => { return ( path.res, opt_qself.as_ref().map(|qself| self.to_ty(qself)), @@ -1186,7 +1186,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { tcx, span, def_id, - &generics, + generics, seg, IsMethodCall::No, ); @@ -1278,7 +1278,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // going to infer the arguments for better error messages. if !self.infer_args_for_err.contains(&index) { // Check whether the user has provided generic arguments. - if let Some(ref data) = self.segments[index].args { + if let Some(data) = self.segments[index].args { return (Some(data), self.segments[index].infer_args); } } @@ -1406,7 +1406,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Normalize only after registering type annotations. let args = self.normalize(span, args_raw); - self.add_required_obligations_for_hir(span, def_id, &args, hir_id); + self.add_required_obligations_for_hir(span, def_id, args, hir_id); // Substitute the values for the type parameters into the type of // the referenced item. @@ -1473,7 +1473,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) { let param_env = self.param_env; - let bounds = self.instantiate_bounds(span, def_id, &args); + let bounds = self.instantiate_bounds(span, def_id, args); for obligation in traits::predicates_for_generics( |idx, predicate_span| { diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs index facbeb8badf..e3aca11fd03 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs @@ -495,7 +495,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Whether it succeeded or failed, it likely made some amount of progress. // In the very worst case, it's just the same `expr` we originally passed in. let expr = match self.blame_specific_expr_if_possible_for_obligation_cause_code( - &error.obligation.cause.code(), + error.obligation.cause.code(), expr, ) { Ok(expr) => expr, diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index f31e50fd352..a02073f3025 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -397,7 +397,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { for arg in provided_args.iter().skip(minimum_input_count) { // Make sure we've checked this expr at least once. - let arg_ty = self.check_expr(&arg); + let arg_ty = self.check_expr(arg); // If the function is c-style variadic, we skipped a bunch of arguments // so we need to check those, and write out the types @@ -796,7 +796,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut err = self.err_ctxt().report_and_explain_type_error(trace, *err); self.emit_coerce_suggestions( &mut err, - &provided_args[*provided_idx], + provided_args[*provided_idx], provided_ty, Expectation::rvalue_hint(self, expected_ty) .only_has_type(self) @@ -925,7 +925,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.emit_coerce_suggestions( &mut err, - &provided_args[provided_idx], + provided_args[provided_idx], provided_ty, Expectation::rvalue_hint(self, expected_ty) .only_has_type(self) @@ -1469,7 +1469,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Type check the initializer. if let Some(ref init) = decl.init { - let init_ty = self.check_decl_initializer(decl.hir_id, decl.pat, &init); + let init_ty = self.check_decl_initializer(decl.hir_id, decl.pat, init); self.overwrite_local_ty_if_err(decl.hir_id, decl.pat, init_ty); } @@ -1483,7 +1483,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; // Type check the pattern. Override if necessary to avoid knock-on errors. - self.check_pat_top(&decl.pat, decl_ty, ty_span, origin_expr, Some(decl.origin)); + self.check_pat_top(decl.pat, decl_ty, ty_span, origin_expr, Some(decl.origin)); let pat_ty = self.node_ty(decl.pat.hir_id); self.overwrite_local_ty_if_err(decl.hir_id, decl.pat, pat_ty); @@ -1525,13 +1525,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { hir::StmtKind::Item(_) => {} hir::StmtKind::Expr(ref expr) => { // Check with expected type of `()`. - self.check_expr_has_type_or_error(&expr, Ty::new_unit(self.tcx), |err| { + self.check_expr_has_type_or_error(expr, Ty::new_unit(self.tcx), |err| { if expr.can_have_side_effects() { self.suggest_semicolon_at_end(expr.span, err); } }); } - hir::StmtKind::Semi(ref expr) => { + hir::StmtKind::Semi(expr) => { self.check_expr(expr); } } @@ -1820,12 +1820,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { hir_id: hir::HirId, ) -> (Res, RawTy<'tcx>) { match *qpath { - QPath::Resolved(ref maybe_qself, ref path) => { + QPath::Resolved(ref maybe_qself, path) => { let self_ty = maybe_qself.as_ref().map(|qself| self.to_ty(qself).raw); let ty = self.astconv().res_to_ty(self_ty, path, hir_id, true); (path.res, self.handle_raw_ty(path_span, ty)) } - QPath::TypeRelative(ref qself, ref segment) => { + QPath::TypeRelative(qself, segment) => { let ty = self.to_ty(qself); let result = self @@ -1869,7 +1869,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { for (_, node) in self.tcx.hir().parent_iter(hir_id) { match node { hir::Node::Stmt(stmt) => { - if let hir::StmtKind::Semi(ref expr) = stmt.kind { + if let hir::StmtKind::Semi(expr) = stmt.kind { let expr_ty = self.typeck_results.borrow().expr_ty(expr); let return_ty = fn_sig.output(); if !matches!(expr.kind, hir::ExprKind::Ret(..)) @@ -2038,7 +2038,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.param_env, trait_ref, ); - match SelectionContext::new(&self).select(&obligation) { + match SelectionContext::new(self).select(&obligation) { Ok(Some(traits::ImplSource::UserDefined(impl_source))) => { Some(impl_source.impl_def_id) } diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs index bd653e79913..072df1343ce 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs @@ -143,7 +143,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } pub fn sess(&self) -> &Session { - &self.tcx.sess + self.tcx.sess } /// Creates an `TypeErrCtxt` with a reference to the in-progress @@ -196,7 +196,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { impl<'a, 'tcx> Deref for FnCtxt<'a, 'tcx> { type Target = Inherited<'tcx>; fn deref(&self) -> &Self::Target { - &self.inh + self.inh } } diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index a37a595e4a8..78e755378f5 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -79,16 +79,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return false; } if let Some((fn_id, fn_decl, can_suggest)) = self.get_fn_decl(blk_id) { - pointing_at_return_type = self.suggest_missing_return_type( - err, - &fn_decl, - expected, - found, - can_suggest, - fn_id, - ); + pointing_at_return_type = + self.suggest_missing_return_type(err, fn_decl, expected, found, can_suggest, fn_id); self.suggest_missing_break_or_return_expr( - err, expr, &fn_decl, expected, found, blk_id, fn_id, + err, expr, fn_decl, expected, found, blk_id, fn_id, ); } pointing_at_return_type @@ -2139,7 +2133,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// opt.map(|param| { takes_ref(param) }); /// ``` fn can_use_as_ref(&self, expr: &hir::Expr<'_>) -> Option<(Vec<(Span, String)>, &'static str)> { - let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) = expr.kind else { + let hir::ExprKind::Path(hir::QPath::Resolved(_, path)) = expr.kind else { return None; }; @@ -2295,7 +2289,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; if self.can_coerce(ref_ty, expected) { let mut sugg_sp = sp; - if let hir::ExprKind::MethodCall(ref segment, receiver, args, _) = expr.kind { + if let hir::ExprKind::MethodCall(segment, receiver, args, _) = expr.kind { let clone_trait = self.tcx.require_lang_item(LangItem::Clone, Some(segment.ident.span)); if args.is_empty() @@ -2313,7 +2307,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - if let hir::ExprKind::Unary(hir::UnOp::Deref, ref inner) = expr.kind + if let hir::ExprKind::Unary(hir::UnOp::Deref, inner) = expr.kind && let Some(1) = self.deref_steps(expected, checked_ty) { // We have `*&T`, check if what was expected was `&T`. @@ -2406,11 +2400,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { )); } } - ( - hir::ExprKind::AddrOf(hir::BorrowKind::Ref, _, ref expr), - _, - &ty::Ref(_, checked, _), - ) if self.can_sub(self.param_env, checked, expected) => { + (hir::ExprKind::AddrOf(hir::BorrowKind::Ref, _, expr), _, &ty::Ref(_, checked, _)) + if self.can_sub(self.param_env, checked, expected) => + { let make_sugg = |start: Span, end: BytePos| { // skip `(` for tuples such as `(c) = (&123)`. // make sure we won't suggest like `(c) = 123)` which is incorrect. diff --git a/compiler/rustc_hir_typeck/src/gather_locals.rs b/compiler/rustc_hir_typeck/src/gather_locals.rs index 0ad2c1d9284..0cca779b156 100644 --- a/compiler/rustc_hir_typeck/src/gather_locals.rs +++ b/compiler/rustc_hir_typeck/src/gather_locals.rs @@ -93,7 +93,7 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> { fn declare(&mut self, decl: Declaration<'tcx>) { let local_ty = match decl.ty { Some(ref ty) => { - let o_ty = self.fcx.to_ty(&ty); + let o_ty = self.fcx.to_ty(ty); let c_ty = self.fcx.inh.infcx.canonicalize_user_type_annotation(UserType::Ty(o_ty.raw)); diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index 46dcc455558..66a0f4ed9de 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -243,7 +243,7 @@ fn typeck_with_fallback<'tcx>( // Gather locals in statics (because of block expressions). GatherLocalsVisitor::new(&fcx).visit_body(body); - fcx.check_expr_coercible_to_type(&body.value, expected_type, None); + fcx.check_expr_coercible_to_type(body.value, expected_type, None); fcx.write_ty(id, expected_type); }; diff --git a/compiler/rustc_hir_typeck/src/mem_categorization.rs b/compiler/rustc_hir_typeck/src/mem_categorization.rs index 337d12b2d51..b25830675b2 100644 --- a/compiler/rustc_hir_typeck/src/mem_categorization.rs +++ b/compiler/rustc_hir_typeck/src/mem_categorization.rs @@ -304,7 +304,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { ) -> McResult> { let expr_ty = self.expr_ty(expr)?; match expr.kind { - hir::ExprKind::Unary(hir::UnOp::Deref, ref e_base) => { + hir::ExprKind::Unary(hir::UnOp::Deref, e_base) => { if self.typeck_results.is_method_call(expr) { self.cat_overloaded_place(expr, e_base) } else { @@ -313,7 +313,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { } } - hir::ExprKind::Field(ref base, _) => { + hir::ExprKind::Field(base, _) => { let base = self.cat_expr(base)?; debug!(?base); @@ -332,7 +332,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { )) } - hir::ExprKind::Index(ref base, _, _) => { + hir::ExprKind::Index(base, _, _) => { if self.typeck_results.is_method_call(expr) { // If this is an index implemented by a method call, then it // will include an implicit deref of the result. @@ -351,7 +351,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { self.cat_res(expr.hir_id, expr.span, expr_ty, res) } - hir::ExprKind::Type(ref e, _) => self.cat_expr(e), + hir::ExprKind::Type(e, _) => self.cat_expr(e), hir::ExprKind::AddrOf(..) | hir::ExprKind::Call(..) @@ -728,11 +728,11 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { } } - PatKind::Binding(.., Some(ref subpat)) => { + PatKind::Binding(.., Some(subpat)) => { self.cat_pattern_(place_with_id, subpat, op)?; } - PatKind::Box(ref subpat) | PatKind::Ref(ref subpat, _) => { + PatKind::Box(subpat) | PatKind::Ref(subpat, _) => { // box p1, &p1, &mut p1. we can ignore the mutability of // PatKind::Ref since that information is already contained // in the type. @@ -754,7 +754,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { for before_pat in before { self.cat_pattern_(elt_place.clone(), before_pat, op)?; } - if let Some(ref slice_pat) = *slice { + if let Some(slice_pat) = *slice { let slice_pat_ty = self.pat_ty_adjusted(slice_pat)?; let slice_place = self.cat_projection( pat, diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs index 7c73f6a89cd..e7af7da205c 100644 --- a/compiler/rustc_hir_typeck/src/method/confirm.rs +++ b/compiler/rustc_hir_typeck/src/method/confirm.rs @@ -93,16 +93,16 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { segment: &hir::PathSegment<'_>, ) -> ConfirmResult<'tcx> { // Adjust the self expression the user provided and obtain the adjusted type. - let self_ty = self.adjust_self_ty(unadjusted_self_ty, &pick); + let self_ty = self.adjust_self_ty(unadjusted_self_ty, pick); // Create substitutions for the method's type parameters. - let rcvr_args = self.fresh_receiver_args(self_ty, &pick); - let all_args = self.instantiate_method_args(&pick, segment, rcvr_args); + let rcvr_args = self.fresh_receiver_args(self_ty, pick); + let all_args = self.instantiate_method_args(pick, segment, rcvr_args); debug!("rcvr_args={rcvr_args:?}, all_args={all_args:?}"); // Create the final signature for the method, replacing late-bound regions. - let (method_sig, method_predicates) = self.instantiate_method_sig(&pick, all_args); + let (method_sig, method_predicates) = self.instantiate_method_sig(pick, all_args); // If there is a `Self: Sized` bound and `Self` is a trait object, it is possible that // something which derefs to `Self` actually implements the trait and the caller @@ -129,14 +129,14 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { "confirm: self_ty={:?} method_sig_rcvr={:?} method_sig={:?} method_predicates={:?}", self_ty, method_sig_rcvr, method_sig, method_predicates ); - self.unify_receivers(self_ty, method_sig_rcvr, &pick, all_args); + self.unify_receivers(self_ty, method_sig_rcvr, pick, all_args); let (method_sig, method_predicates) = self.normalize(self.span, (method_sig, method_predicates)); let method_sig = ty::Binder::dummy(method_sig); // Make sure nobody calls `drop()` explicitly. - self.enforce_illegal_method_limitations(&pick); + self.enforce_illegal_method_limitations(pick); // Add any trait/regions obligations specified on the method's type parameters. // We won't add these if we encountered an illegal sized bound, so that we can use diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index d2a72f8f233..9ed18ffe103 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -1135,7 +1135,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { .fcx .probe_instantiate_query_response( self.span, - &self.orig_steps_var_values, + self.orig_steps_var_values, &step.self_ty, ) .unwrap_or_else(|_| { @@ -1509,7 +1509,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { // match as well (or at least may match, sometimes we // don't have enough information to fully evaluate). match probe.kind { - InherentImplCandidate(ref args, ref ref_obligations) => { + InherentImplCandidate(args, ref ref_obligations) => { // `xform_ret_ty` hasn't been normalized yet, only `xform_self_ty`, // see the reasons mentioned in the comments in `assemble_inherent_impl_probe` // for why this is necessary diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index db434636f59..3b96cd96d2e 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -484,7 +484,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.note_internal_mutation_in_method( &mut err, rcvr_expr, - expected.to_option(&self), + expected.to_option(self), rcvr_ty, ); } @@ -509,7 +509,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if static_candidates.len() == 1 { self.suggest_associated_call_syntax( &mut err, - &static_candidates, + static_candidates, rcvr_ty, source, item_name, @@ -969,7 +969,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { "the following trait bounds were not satisfied:\n{bound_list}" )); } - self.suggest_derive(&mut err, &unsatisfied_predicates); + self.suggest_derive(&mut err, unsatisfied_predicates); unsatisfied_bounds = true; } @@ -1170,8 +1170,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { args.map(|args| args.len() + 1), source, no_match_data.out_of_scope_traits.clone(), - &unsatisfied_predicates, - &static_candidates, + unsatisfied_predicates, + static_candidates, unsatisfied_bounds, expected.only_has_type(self), trait_missing_method, @@ -1722,7 +1722,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { for (_, parent) in tcx.hir().parent_iter(expr.hir_id).take(5) { if let Node::Expr(parent_expr) = parent { let lang_item = match parent_expr.kind { - ExprKind::Struct(ref qpath, _, _) => match **qpath { + ExprKind::Struct(qpath, _, _) => match *qpath { QPath::LangItem(LangItem::Range, ..) => Some(LangItem::Range), QPath::LangItem(LangItem::RangeTo, ..) => Some(LangItem::RangeTo), QPath::LangItem(LangItem::RangeToInclusive, ..) => { @@ -1730,7 +1730,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } _ => None, }, - ExprKind::Call(ref func, _) => match func.kind { + ExprKind::Call(func, _) => match func.kind { // `..=` desugars into `::std::ops::RangeInclusive::new(...)`. ExprKind::Path(QPath::LangItem(LangItem::RangeInclusiveNew, ..)) => { Some(LangItem::RangeInclusiveStruct) @@ -1749,7 +1749,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { eps.len() > 0 && eps.last().is_some_and(|ep| ep.span.contains(span)) } // `..=` desugars into `::std::ops::RangeInclusive::new(...)`. - hir::ExprKind::Call(ref func, ..) => func.span.contains(span), + hir::ExprKind::Call(func, ..) => func.span.contains(span), _ => false, }; @@ -1843,7 +1843,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); let concrete_type = if actual.is_integral() { "i32" } else { "f32" }; match expr.kind { - ExprKind::Lit(ref lit) => { + ExprKind::Lit(lit) => { // numeric literal let snippet = tcx .sess @@ -1947,7 +1947,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } let mut visitor = LetVisitor { result: None, ident_name: seg1.ident.name }; - visitor.visit_body(&body); + visitor.visit_body(body); let parent = self.tcx.hir().parent_id(seg1.hir_id); if let Some(Node::Expr(call_expr)) = self.tcx.hir().find(parent) diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index b30f9b82fbb..f11ffabf4d4 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -872,7 +872,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.demand_eqtype_pat(pat.span, expected, pat_ty, pat_info.top_info); // Type-check subpatterns. - if self.check_struct_pat_fields(pat_ty, &pat, variant, fields, has_rest_pat, pat_info) { + if self.check_struct_pat_fields(pat_ty, pat, variant, fields, has_rest_pat, pat_info) { pat_ty } else { Ty::new_misc_error(self.tcx) diff --git a/compiler/rustc_hir_typeck/src/place_op.rs b/compiler/rustc_hir_typeck/src/place_op.rs index 406434e09e6..f8ca3a4f3d7 100644 --- a/compiler/rustc_hir_typeck/src/place_op.rs +++ b/compiler/rustc_hir_typeck/src/place_op.rs @@ -283,9 +283,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Gather up expressions we want to munge. let mut exprs = vec![expr]; - while let hir::ExprKind::Field(ref expr, _) - | hir::ExprKind::Index(ref expr, _, _) - | hir::ExprKind::Unary(hir::UnOp::Deref, ref expr) = exprs.last().unwrap().kind + while let hir::ExprKind::Field(expr, _) + | hir::ExprKind::Index(expr, _, _) + | hir::ExprKind::Unary(hir::UnOp::Deref, expr) = exprs.last().unwrap().kind { exprs.push(expr); } diff --git a/compiler/rustc_incremental/src/assert_dep_graph.rs b/compiler/rustc_incremental/src/assert_dep_graph.rs index 1b160eca92d..3f30b3f2b4c 100644 --- a/compiler/rustc_incremental/src/assert_dep_graph.rs +++ b/compiler/rustc_incremental/src/assert_dep_graph.rs @@ -231,13 +231,13 @@ fn dump_graph(query: &DepGraphQuery) { // Expect one of: "-> target", "source -> target", or "source ->". let edge_filter = EdgeFilter::new(&string).unwrap_or_else(|e| bug!("invalid filter: {}", e)); - let sources = node_set(&query, &edge_filter.source); - let targets = node_set(&query, &edge_filter.target); - filter_nodes(&query, &sources, &targets) + let sources = node_set(query, &edge_filter.source); + let targets = node_set(query, &edge_filter.target); + filter_nodes(query, &sources, &targets) } Err(_) => query.nodes().into_iter().map(|n| n.kind).collect(), }; - let edges = filter_edges(&query, &nodes); + let edges = filter_edges(query, &nodes); { // dump a .txt file with just the edges: diff --git a/compiler/rustc_incremental/src/persist/dirty_clean.rs b/compiler/rustc_incremental/src/persist/dirty_clean.rs index 5dd06c6ca4f..eaf83b7ee5f 100644 --- a/compiler/rustc_incremental/src/persist/dirty_clean.rs +++ b/compiler/rustc_incremental/src/persist/dirty_clean.rs @@ -378,15 +378,15 @@ impl<'tcx> DirtyCleanVisitor<'tcx> { }; self.checked_attrs.insert(attr.id); for label in assertion.clean.items().into_sorted_stable_ord() { - let dep_node = DepNode::from_label_string(self.tcx, &label, def_path_hash).unwrap(); + let dep_node = DepNode::from_label_string(self.tcx, label, def_path_hash).unwrap(); self.assert_clean(item_span, dep_node); } for label in assertion.dirty.items().into_sorted_stable_ord() { - let dep_node = DepNode::from_label_string(self.tcx, &label, def_path_hash).unwrap(); + let dep_node = DepNode::from_label_string(self.tcx, label, def_path_hash).unwrap(); self.assert_dirty(item_span, dep_node); } for label in assertion.loaded_from_disk.items().into_sorted_stable_ord() { - let dep_node = DepNode::from_label_string(self.tcx, &label, def_path_hash).unwrap(); + let dep_node = DepNode::from_label_string(self.tcx, label, def_path_hash).unwrap(); self.assert_loaded_from_disk(item_span, dep_node); } } diff --git a/compiler/rustc_incremental/src/persist/fs.rs b/compiler/rustc_incremental/src/persist/fs.rs index f56fb0d0534..2d809030e58 100644 --- a/compiler/rustc_incremental/src/persist/fs.rs +++ b/compiler/rustc_incremental/src/persist/fs.rs @@ -499,7 +499,7 @@ fn lock_directory( } fn delete_session_dir_lock_file(sess: &Session, lock_file_path: &Path) { - if let Err(err) = safe_remove_file(&lock_file_path) { + if let Err(err) = safe_remove_file(lock_file_path) { sess.emit_warning(errors::DeleteLock { path: lock_file_path, err }); } } @@ -847,10 +847,10 @@ pub(crate) fn garbage_collect_session_directories(sess: &Session) -> io::Result< fn delete_old(sess: &Session, path: &Path) { debug!("garbage_collect_session_directories() - deleting `{}`", path.display()); - if let Err(err) = safe_remove_dir_all(&path) { - sess.emit_warning(errors::SessionGcFailed { path: &path, err }); + if let Err(err) = safe_remove_dir_all(path) { + sess.emit_warning(errors::SessionGcFailed { path: path, err }); } else { - delete_session_dir_lock_file(sess, &lock_file_path(&path)); + delete_session_dir_lock_file(sess, &lock_file_path(path)); } } diff --git a/compiler/rustc_incremental/src/persist/load.rs b/compiler/rustc_incremental/src/persist/load.rs index 6dfc4096910..f2c1d0b83aa 100644 --- a/compiler/rustc_incremental/src/persist/load.rs +++ b/compiler/rustc_incremental/src/persist/load.rs @@ -99,7 +99,7 @@ fn load_dep_graph(sess: &Session) -> LoadResult<(SerializedDepGraph, WorkProduct // Calling `sess.incr_comp_session_dir()` will panic if `sess.opts.incremental.is_none()`. // Fortunately, we just checked that this isn't the case. - let path = dep_graph_path(&sess); + let path = dep_graph_path(sess); let expected_hash = sess.opts.dep_tracking_hash(false); let mut prev_work_products = UnordMap::default(); diff --git a/compiler/rustc_incremental/src/persist/work_product.rs b/compiler/rustc_incremental/src/persist/work_product.rs index fb96bed5a71..1ee3d13922b 100644 --- a/compiler/rustc_incremental/src/persist/work_product.rs +++ b/compiler/rustc_incremental/src/persist/work_product.rs @@ -31,7 +31,7 @@ pub fn copy_cgu_workproduct_to_incr_comp_cache_dir( } Err(err) => { sess.emit_warning(errors::CopyWorkProductToCache { - from: &path, + from: path, to: &path_in_incr_dir, err, }); diff --git a/compiler/rustc_infer/src/infer/canonical/query_response.rs b/compiler/rustc_infer/src/infer/canonical/query_response.rs index d911e28484c..6860d0de179 100644 --- a/compiler/rustc_infer/src/infer/canonical/query_response.rs +++ b/compiler/rustc_infer/src/infer/canonical/query_response.rs @@ -552,7 +552,7 @@ impl<'tcx> InferCtxt<'tcx> { // `query_response.var_values` after applying the substitution // `result_subst`. let substituted_query_response = |index: BoundVar| -> GenericArg<'tcx> { - query_response.substitute_projected(self.tcx, &result_subst, |v| v.var_values[index]) + query_response.substitute_projected(self.tcx, result_subst, |v| v.var_values[index]) }; // Unify the original value for each variable with the value diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index d7669b1a4b5..a2aa99e78e1 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -155,7 +155,7 @@ impl TypeErrCtxt<'_, '_> { impl<'tcx> Deref for TypeErrCtxt<'_, 'tcx> { type Target = InferCtxt<'tcx>; fn deref(&self) -> &InferCtxt<'tcx> { - &self.infcx + self.infcx } } @@ -1019,8 +1019,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { /// ``` fn cmp_type_arg( &self, - mut t1_out: &mut DiagnosticStyledString, - mut t2_out: &mut DiagnosticStyledString, + t1_out: &mut DiagnosticStyledString, + t2_out: &mut DiagnosticStyledString, path: String, sub: &'tcx [ty::GenericArg<'tcx>], other_path: String, @@ -1031,13 +1031,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let sub = self.tcx.mk_args(sub); for (i, ta) in sub.types().enumerate() { if ta == other_ty { - self.highlight_outer(&mut t1_out, &mut t2_out, path, sub, i, other_ty); + self.highlight_outer(t1_out, t2_out, path, sub, i, other_ty); return Some(()); } if let ty::Adt(def, _) = ta.kind() { let path_ = self.tcx.def_path_str(def.did()); if path_ == other_path { - self.highlight_outer(&mut t1_out, &mut t2_out, path, sub, i, other_ty); + self.highlight_outer(t1_out, t2_out, path, sub, i, other_ty); return Some(()); } } diff --git a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs index 4beb51da72c..034b9795bf8 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs @@ -419,7 +419,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { return self.bad_inference_failure_err(failure_span, arg_data, error_code); }; - let mut local_visitor = FindInferSourceVisitor::new(&self, typeck_results, arg); + let mut local_visitor = FindInferSourceVisitor::new(self, typeck_results, arg); if let Some(body_id) = self.tcx.hir().maybe_body_owned_by( self.tcx.typeck_root_def_id(body_def_id.to_def_id()).expect_local(), ) { diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/find_anon_type.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/find_anon_type.rs index 0df417d0950..5687d85d24a 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/find_anon_type.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/find_anon_type.rs @@ -96,7 +96,7 @@ impl<'tcx> Visitor<'tcx> for FindNestedTypeVisitor<'tcx> { } } - hir::TyKind::Ref(ref lifetime, _) => { + hir::TyKind::Ref(lifetime, _) => { // the lifetime of the Ref let hir_id = lifetime.hir_id; match (self.tcx.named_bound_var(hir_id), self.bound_region) { diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs index 6901955af65..df7907e1fd3 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs @@ -81,7 +81,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { for matching_def_id in v.0 { let mut hir_v = super::static_impl_trait::HirTraitObjectVisitor(&mut traits, matching_def_id); - hir_v.visit_ty(&impl_self_ty); + hir_v.visit_ty(impl_self_ty); } if traits.is_empty() { diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs index e2be6cf4280..81154415c1e 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs @@ -78,7 +78,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { has_impl_path, impl_path, }); - if self.find_impl_on_dyn_trait(&mut err, param.param_ty, &ctxt) { + if self.find_impl_on_dyn_trait(&mut err, param.param_ty, ctxt) { let reported = err.emit(); return Some(reported); } else { @@ -204,7 +204,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { && let ObligationCauseCode::UnifyReceiver(ctxt) = cause.code() // Handle case of `impl Foo for dyn Bar { fn qux(&self) {} }` introducing a // `'static` lifetime when called as a method on a binding: `bar.qux()`. - && self.find_impl_on_dyn_trait(&mut err, param.param_ty, &ctxt) + && self.find_impl_on_dyn_trait(&mut err, param.param_ty, ctxt) { override_error_code = Some(ctxt.assoc_item.name); } @@ -530,7 +530,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { for found_did in found_dids { let mut traits = vec![]; let mut hir_v = HirTraitObjectVisitor(&mut traits, *found_did); - hir_v.visit_ty(&self_ty); + hir_v.visit_ty(self_ty); for &span in &traits { let subdiag = DynTraitConstraintSuggestion { span, ident }; subdiag.add_to_diagnostic(err); diff --git a/compiler/rustc_infer/src/infer/error_reporting/note.rs b/compiler/rustc_infer/src/infer/error_reporting/note.rs index 8d3cd23b7fa..781cc192ae5 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/note.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/note.rs @@ -63,7 +63,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { .add_to_diagnostic(err); } infer::CheckAssociatedTypeBounds { ref parent, .. } => { - self.note_region_origin(err, &parent); + self.note_region_origin(err, parent); } infer::AscribeUserTypeProvePredicate(span) => { RegionOriginNote::Plain { diff --git a/compiler/rustc_infer/src/infer/error_reporting/suggest.rs b/compiler/rustc_infer/src/infer/error_reporting/suggest.rs index f0b33d30e2c..aa5fe6d3f56 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/suggest.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/suggest.rs @@ -511,7 +511,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } let mut visitor = IfVisitor { err_span: span, found_if: false, result: false }; - visitor.visit_body(&body); + visitor.visit_body(body); if visitor.result { return Some(TypeErrorAdditionalDiags::AddLetForLetChains { span: span.shrink_to_lo(), @@ -636,10 +636,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { return None; } let last_stmt = blk.stmts.last()?; - let hir::StmtKind::Semi(ref last_expr) = last_stmt.kind else { + let hir::StmtKind::Semi(last_expr) = last_stmt.kind else { return None; }; - let last_expr_ty = self.typeck_results.as_ref()?.expr_ty_opt(*last_expr)?; + let last_expr_ty = self.typeck_results.as_ref()?.expr_ty_opt(last_expr)?; let needs_box = match (last_expr_ty.kind(), expected_ty.kind()) { _ if last_expr_ty.references_error() => return None, _ if self.same_type_modulo_infer(last_expr_ty, expected_ty) => { diff --git a/compiler/rustc_infer/src/infer/opaque_types.rs b/compiler/rustc_infer/src/infer/opaque_types.rs index 7a792d30cc7..4e2cd00613b 100644 --- a/compiler/rustc_infer/src/infer/opaque_types.rs +++ b/compiler/rustc_infer/src/infer/opaque_types.rs @@ -447,7 +447,7 @@ where } match ty.kind() { - ty::Closure(_, ref args) => { + ty::Closure(_, args) => { // Skip lifetime parameters of the enclosing item(s) for upvar in args.as_closure().upvar_tys() { @@ -456,7 +456,7 @@ where args.as_closure().sig_as_fn_ptr_ty().visit_with(self); } - ty::Coroutine(_, ref args, _) => { + ty::Coroutine(_, args, _) => { // Skip lifetime parameters of the enclosing item(s) // Also skip the witness type, because that has no free regions. @@ -468,7 +468,7 @@ where args.as_coroutine().resume_ty().visit_with(self); } - ty::Alias(ty::Opaque, ty::AliasTy { def_id, ref args, .. }) => { + ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => { // Skip lifetime parameters that are not captures. let variances = self.tcx.variances_of(*def_id); @@ -575,7 +575,7 @@ impl<'tcx> InferCtxt<'tcx> { .register(opaque_type_key, OpaqueHiddenType { ty: hidden_ty, span }); if let Some(prev) = prev { obligations.extend( - self.at(&cause, param_env) + self.at(cause, param_env) .eq_exp(DefineOpaqueTypes::Yes, a_is_expected, prev, hidden_ty)? .obligations, ); diff --git a/compiler/rustc_infer/src/infer/outlives/components.rs b/compiler/rustc_infer/src/infer/outlives/components.rs index 806ecf35330..45df22d44e8 100644 --- a/compiler/rustc_infer/src/infer/outlives/components.rs +++ b/compiler/rustc_infer/src/infer/outlives/components.rs @@ -98,12 +98,12 @@ fn compute_components<'tcx>( compute_components(tcx, element, out, visited); } - ty::Closure(_, ref args) => { + ty::Closure(_, args) => { let tupled_ty = args.as_closure().tupled_upvars_ty(); compute_components(tcx, tupled_ty, out, visited); } - ty::Coroutine(_, ref args, _) => { + ty::Coroutine(_, args, _) => { // Same as the closure case let tupled_ty = args.as_coroutine().tupled_upvars_ty(); compute_components(tcx, tupled_ty, out, visited); diff --git a/compiler/rustc_infer/src/infer/outlives/obligations.rs b/compiler/rustc_infer/src/infer/outlives/obligations.rs index 1bc24682b9a..c6cbde4dba9 100644 --- a/compiler/rustc_infer/src/infer/outlives/obligations.rs +++ b/compiler/rustc_infer/src/infer/outlives/obligations.rs @@ -136,7 +136,7 @@ impl<'tcx> InferCtxt<'tcx> { let outlives = &mut TypeOutlives::new( self, self.tcx, - &outlives_env.region_bound_pairs(), + outlives_env.region_bound_pairs(), None, outlives_env.param_env, ); @@ -248,7 +248,7 @@ where } Component::Alias(alias_ty) => self.alias_ty_must_outlive(origin, region, *alias_ty), Component::EscapingAlias(subcomponents) => { - self.components_must_outlive(origin, &subcomponents, region, category); + self.components_must_outlive(origin, subcomponents, region, category); } Component::UnresolvedInferenceVariable(v) => { // ignore this, we presume it will yield an error diff --git a/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs b/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs index b6ff8f2f512..479343c3ec2 100644 --- a/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs +++ b/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs @@ -81,7 +81,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> { return Ok(()); } - let mini_graph = &MiniGraph::new(tcx, &self, only_consider_snapshot); + let mini_graph = &MiniGraph::new(tcx, self, only_consider_snapshot); let mut leak_check = LeakCheck::new(tcx, outer_universe, max_universe, mini_graph, self); leak_check.assign_placeholder_values()?; diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 0baf77c4f7e..ec024dac8dd 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -127,7 +127,7 @@ fn configure_and_expand( let tcx = resolver.tcx(); let sess = tcx.sess; let features = tcx.features(); - let lint_store = unerased_lint_store(&tcx.sess); + let lint_store = unerased_lint_store(tcx.sess); let crate_name = tcx.crate_name(LOCAL_CRATE); let lint_check_node = (&krate, pre_configured_attrs); pre_expansion_lint( @@ -150,7 +150,7 @@ fn configure_and_expand( ) }); - util::check_attr_crate_type(sess, pre_configured_attrs, &mut resolver.lint_buffer()); + util::check_attr_crate_type(sess, pre_configured_attrs, resolver.lint_buffer()); // Expand all macros krate = sess.time("macro_expand_crate", || { @@ -284,16 +284,16 @@ fn early_lint_checks(tcx: TyCtxt<'_>, (): ()) { let mut lint_buffer = resolver.lint_buffer.steal(); if sess.opts.unstable_opts.input_stats { - eprintln!("Post-expansion node count: {}", count_nodes(&krate)); + eprintln!("Post-expansion node count: {}", count_nodes(krate)); } if sess.opts.unstable_opts.hir_stats { - hir_stats::print_ast_stats(&krate, "POST EXPANSION AST STATS", "ast-stats-2"); + hir_stats::print_ast_stats(krate, "POST EXPANSION AST STATS", "ast-stats-2"); } // Needs to go *after* expansion to be able to check the results of macro expansion. sess.time("complete_gated_feature_checking", || { - rustc_ast_passes::feature_gate::check_crate(&krate, sess, tcx.features()); + rustc_ast_passes::feature_gate::check_crate(krate, sess, tcx.features()); }); // Add all buffered lints from the `ParseSess` to the `Session`. @@ -319,7 +319,7 @@ fn early_lint_checks(tcx: TyCtxt<'_>, (): ()) { } }); - let lint_store = unerased_lint_store(&tcx.sess); + let lint_store = unerased_lint_store(tcx.sess); rustc_lint::check_ast_node( sess, tcx.features(), @@ -521,11 +521,11 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P if sess.opts.json_artifact_notifications { sess.parse_sess .span_diagnostic - .emit_artifact_notification(&deps_filename, "dep-info"); + .emit_artifact_notification(deps_filename, "dep-info"); } } Err(error) => { - sess.emit_fatal(errors::ErrorWritingDependencies { path: &deps_filename, error }); + sess.emit_fatal(errors::ErrorWritingDependencies { path: deps_filename, error }); } } } @@ -564,12 +564,12 @@ fn output_filenames(tcx: TyCtxt<'_>, (): ()) -> Arc { generated_output_paths(tcx, &outputs, sess.io.output_file.is_some(), crate_name); // Ensure the source file isn't accidentally overwritten during compilation. - if let Some(ref input_path) = sess.io.input.opt_path() { + if let Some(input_path) = sess.io.input.opt_path() { if sess.opts.will_create_output_file() { if output_contains_path(&output_paths, input_path) { sess.emit_fatal(errors::InputFileWouldBeOverWritten { path: input_path }); } - if let Some(ref dir_path) = output_conflicts_with_dir(&output_paths) { + if let Some(dir_path) = output_conflicts_with_dir(&output_paths) { sess.emit_fatal(errors::GeneratedFileConflictsWithDirectory { input_path, dir_path, diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs index fbf2dbcdae5..3fee2d28981 100644 --- a/compiler/rustc_interface/src/queries.rs +++ b/compiler/rustc_interface/src/queries.rs @@ -102,7 +102,7 @@ impl<'tcx> Queries<'tcx> { } fn session(&self) -> &Session { - &self.compiler.session() + self.compiler.session() } fn codegen_backend(&self) -> &dyn CodegenBackend { diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index b434659f0d5..a1c5cfacc82 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -263,7 +263,7 @@ impl<'tcx> LateLintPass<'tcx> for NonShorthandFieldPatterns { continue; } if let PatKind::Binding(binding_annot, _, ident, None) = fieldpat.pat.kind { - if cx.tcx.find_field_index(ident, &variant) + if cx.tcx.find_field_index(ident, variant) == Some(cx.typeck_results().field_index(fieldpat.hir_id)) { cx.emit_spanned_lint( @@ -633,21 +633,21 @@ impl<'tcx> LateLintPass<'tcx> for MissingCopyImplementations { return; } let (def, ty) = match item.kind { - hir::ItemKind::Struct(_, ref ast_generics) => { + hir::ItemKind::Struct(_, ast_generics) => { if !ast_generics.params.is_empty() { return; } let def = cx.tcx.adt_def(item.owner_id); (def, Ty::new_adt(cx.tcx, def, ty::List::empty())) } - hir::ItemKind::Union(_, ref ast_generics) => { + hir::ItemKind::Union(_, ast_generics) => { if !ast_generics.params.is_empty() { return; } let def = cx.tcx.adt_def(item.owner_id); (def, Ty::new_adt(cx.tcx, def, ty::List::empty())) } - hir::ItemKind::Enum(_, ref ast_generics) => { + hir::ItemKind::Enum(_, ast_generics) => { if !ast_generics.params.is_empty() { return; } @@ -1027,7 +1027,7 @@ impl EarlyLintPass for UnusedDocComment { } fn check_block(&mut self, cx: &EarlyContext<'_>, block: &ast::Block) { - warn_if_doc(cx, block.span, "blocks", &block.attrs()); + warn_if_doc(cx, block.span, "blocks", block.attrs()); } fn check_item(&mut self, cx: &EarlyContext<'_>, item: &ast::Item) { @@ -1117,7 +1117,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidNoMangleItems { } }; match it.kind { - hir::ItemKind::Fn(.., ref generics, _) => { + hir::ItemKind::Fn(.., generics, _) => { if let Some(no_mangle_attr) = attr::find_by_name(attrs, sym::no_mangle) { check_no_mangle_on_generic_fn(no_mangle_attr, None, generics, it.span); } @@ -1444,10 +1444,10 @@ declare_lint_pass!( impl TypeAliasBounds { pub(crate) fn is_type_variable_assoc(qpath: &hir::QPath<'_>) -> bool { match *qpath { - hir::QPath::TypeRelative(ref ty, _) => { + hir::QPath::TypeRelative(ty, _) => { // If this is a type variable, we found a `T::Assoc`. match ty.kind { - hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) => { + hir::TyKind::Path(hir::QPath::Resolved(None, path)) => { matches!(path.res, Res::Def(DefKind::TyParam, _)) } _ => false, @@ -1714,16 +1714,16 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns { } let (parentheses, endpoints) = match &pat.kind { - PatKind::Ref(subpat, _) => (true, matches_ellipsis_pat(&subpat)), + PatKind::Ref(subpat, _) => (true, matches_ellipsis_pat(subpat)), _ => (false, matches_ellipsis_pat(pat)), }; if let Some((start, end, join)) = endpoints { if parentheses { self.node_id = Some(pat.id); - let end = expr_to_string(&end); + let end = expr_to_string(end); let replace = match start { - Some(start) => format!("&({}..={})", expr_to_string(&start), end), + Some(start) => format!("&({}..={})", expr_to_string(start), end), None => format!("&(..={end})"), }; if join.edition() >= Edition::Edition2021 { @@ -2381,7 +2381,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue { /// Determine if this expression is a "dangerous initialization". fn is_dangerous_init(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> Option { - if let hir::ExprKind::Call(ref path_expr, ref args) = expr.kind { + if let hir::ExprKind::Call(path_expr, args) = expr.kind { // Find calls to `mem::{uninitialized,zeroed}` methods. if let hir::ExprKind::Path(ref qpath) = path_expr.kind { let def_id = cx.qpath_res(qpath, path_expr.hir_id).opt_def_id()?; @@ -2398,7 +2398,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue { if cx.tcx.is_diagnostic_item(sym::assume_init, def_id) { // This is a call to *some* method named `assume_init`. // See if the `self` parameter is one of the dangerous constructors. - if let hir::ExprKind::Call(ref path_expr, _) = receiver.kind { + if let hir::ExprKind::Call(path_expr, _) = receiver.kind { if let hir::ExprKind::Path(ref qpath) = path_expr.kind { let def_id = cx.qpath_res(qpath, path_expr.hir_id).opt_def_id()?; match cx.tcx.get_diagnostic_name(def_id) { @@ -2540,7 +2540,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue { return variant_find_init_error( cx, ty, - &first_variant.0, + first_variant.0, args, "field of the only potentially inhabited enum variant", init, @@ -2646,13 +2646,13 @@ impl<'tcx> LateLintPass<'tcx> for DerefNullPtr { /// test if expression is a null ptr fn is_null_ptr(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> bool { match &expr.kind { - rustc_hir::ExprKind::Cast(ref expr, ref ty) => { + rustc_hir::ExprKind::Cast(expr, ty) => { if let rustc_hir::TyKind::Ptr(_) = ty.kind { return is_zero(expr) || is_null_ptr(cx, expr); } } // check for call to `core::ptr::null` or `core::ptr::null_mut` - rustc_hir::ExprKind::Call(ref path, _) => { + rustc_hir::ExprKind::Call(path, _) => { if let rustc_hir::ExprKind::Path(ref qpath) = path.kind { if let Some(def_id) = cx.qpath_res(qpath, path.hir_id).opt_def_id() { return matches!( @@ -2670,7 +2670,7 @@ impl<'tcx> LateLintPass<'tcx> for DerefNullPtr { /// test if expression is the literal `0` fn is_zero(expr: &hir::Expr<'_>) -> bool { match &expr.kind { - rustc_hir::ExprKind::Lit(ref lit) => { + rustc_hir::ExprKind::Lit(lit) => { if let LitKind::Int(a, _) = lit.node { return a == 0; } diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index d500c3b66d6..f427b77d65c 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -385,7 +385,7 @@ impl LintStore { }; } Some(LintGroup { lint_ids, .. }) => { - return CheckLintNameResult::Tool(Ok(&lint_ids)); + return CheckLintNameResult::Tool(Ok(lint_ids)); } }, Some(Id(id)) => return CheckLintNameResult::Tool(Ok(slice::from_ref(id))), @@ -406,12 +406,12 @@ impl LintStore { if let Some(LintAlias { name, silent }) = depr { let LintGroup { lint_ids, .. } = self.lint_groups.get(name).unwrap(); return if *silent { - CheckLintNameResult::Ok(&lint_ids) + CheckLintNameResult::Ok(lint_ids) } else { - CheckLintNameResult::Tool(Err((Some(&lint_ids), (*name).to_string()))) + CheckLintNameResult::Tool(Err((Some(lint_ids), (*name).to_string()))) }; } - CheckLintNameResult::Ok(&lint_ids) + CheckLintNameResult::Ok(lint_ids) } }, Some(Id(id)) => CheckLintNameResult::Ok(slice::from_ref(id)), @@ -458,12 +458,12 @@ impl LintStore { if let Some(LintAlias { name, silent }) = depr { let LintGroup { lint_ids, .. } = self.lint_groups.get(name).unwrap(); return if *silent { - CheckLintNameResult::Tool(Err((Some(&lint_ids), complete_name))) + CheckLintNameResult::Tool(Err((Some(lint_ids), complete_name))) } else { - CheckLintNameResult::Tool(Err((Some(&lint_ids), (*name).to_string()))) + CheckLintNameResult::Tool(Err((Some(lint_ids), (*name).to_string()))) }; } - CheckLintNameResult::Tool(Err((Some(&lint_ids), complete_name))) + CheckLintNameResult::Tool(Err((Some(lint_ids), complete_name))) } }, Some(Id(id)) => { @@ -1051,7 +1051,7 @@ impl<'a> EarlyContext<'a> { impl<'tcx> LintContext for LateContext<'tcx> { /// Gets the overall compiler `Session` object. fn sess(&self) -> &Session { - &self.tcx.sess + self.tcx.sess } #[rustc_lint_diagnostics] @@ -1080,7 +1080,7 @@ impl<'tcx> LintContext for LateContext<'tcx> { impl LintContext for EarlyContext<'_> { /// Gets the overall compiler `Session` object. fn sess(&self) -> &Session { - &self.builder.sess() + self.builder.sess() } #[rustc_lint_diagnostics] @@ -1127,7 +1127,7 @@ impl<'tcx> LateContext<'tcx> { /// bodies (e.g. for paths in `hir::Ty`), without any risk of ICE-ing. pub fn qpath_res(&self, qpath: &hir::QPath<'_>, id: hir::HirId) -> Res { match *qpath { - hir::QPath::Resolved(_, ref path) => path.res, + hir::QPath::Resolved(_, path) => path.res, hir::QPath::TypeRelative(..) | hir::QPath::LangItem(..) => self .maybe_typeck_results() .filter(|typeck_results| typeck_results.hir_owner == id.owner) diff --git a/compiler/rustc_lint/src/early.rs b/compiler/rustc_lint/src/early.rs index d102e3a6c15..36aa959ddc9 100644 --- a/compiler/rustc_lint/src/early.rs +++ b/compiler/rustc_lint/src/early.rs @@ -350,7 +350,7 @@ impl<'a> EarlyCheckNode<'a> for (&'a ast::Crate, &'a [ast::Attribute]) { where 'a: 'b, { - &self.1 + self.1 } fn check<'b, T: EarlyLintPass>(self, cx: &mut EarlyContextAndPass<'b, T>) where diff --git a/compiler/rustc_lint/src/expect.rs b/compiler/rustc_lint/src/expect.rs index 740c90757e6..047a214a8b2 100644 --- a/compiler/rustc_lint/src/expect.rs +++ b/compiler/rustc_lint/src/expect.rs @@ -24,7 +24,7 @@ fn check_expectations(tcx: TyCtxt<'_>, tool_filter: Option) { // This check will always be true, since `lint_expectations` only // holds stable ids if let LintExpectationId::Stable { hir_id, .. } = id { - if !fulfilled_expectations.contains(&id) + if !fulfilled_expectations.contains(id) && tool_filter.map_or(true, |filter| expectation.lint_tool == Some(filter)) { let rationale = expectation.reason.map(|rationale| ExpectationNote { rationale }); diff --git a/compiler/rustc_lint/src/for_loops_over_fallibles.rs b/compiler/rustc_lint/src/for_loops_over_fallibles.rs index c8ec0458ba4..ea922785a95 100644 --- a/compiler/rustc_lint/src/for_loops_over_fallibles.rs +++ b/compiler/rustc_lint/src/for_loops_over_fallibles.rs @@ -137,7 +137,7 @@ fn suggest_question_mark<'tcx>( // Check that the function/closure/constant we are in has a `Result` type. // Otherwise suggesting using `?` may not be a good idea. { - let ty = cx.typeck_results().expr_ty(&cx.tcx.hir().body(body_id).value); + let ty = cx.typeck_results().expr_ty(cx.tcx.hir().body(body_id).value); let ty::Adt(ret_adt, ..) = ty.kind() else { return false }; if !cx.tcx.is_diagnostic_item(sym::Result, ret_adt.did()) { return false; diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index 2d86129c480..823ede1222c 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -196,7 +196,7 @@ impl<'tcx> LateLintPass<'tcx> for TyTyKind { } } else if !ty.span.from_expansion() && path.segments.len() > 1 - && let Some(ty) = is_ty_or_ty_ctxt(cx, &path) + && let Some(ty) = is_ty_or_ty_ctxt(cx, path) { cx.emit_spanned_lint( USAGE_OF_QUALIFIED_TY, diff --git a/compiler/rustc_lint/src/late.rs b/compiler/rustc_lint/src/late.rs index 10c4c0dc79f..551fe23f9f1 100644 --- a/compiler/rustc_lint/src/late.rs +++ b/compiler/rustc_lint/src/late.rs @@ -279,7 +279,7 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) { let generics = self.context.generics.take(); - self.context.generics = Some(&trait_item.generics); + self.context.generics = Some(trait_item.generics); self.with_lint_attrs(trait_item.hir_id(), |cx| { cx.with_param_env(trait_item.owner_id, |cx| { lint_callback!(cx, check_trait_item, trait_item); @@ -291,7 +291,7 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem<'tcx>) { let generics = self.context.generics.take(); - self.context.generics = Some(&impl_item.generics); + self.context.generics = Some(impl_item.generics); self.with_lint_attrs(impl_item.hir_id(), |cx| { cx.with_param_env(impl_item.owner_id, |cx| { lint_callback!(cx, check_impl_item, impl_item); @@ -355,7 +355,7 @@ pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx> + 'tcx>( enclosing_body: None, cached_typeck_results: Cell::new(None), param_env: ty::ParamEnv::empty(), - effective_visibilities: &tcx.effective_visibilities(()), + effective_visibilities: tcx.effective_visibilities(()), last_node_with_lint_attrs: tcx.hir().local_def_id_to_hir_id(module_def_id), generics: None, only_module: true, @@ -364,7 +364,7 @@ pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx> + 'tcx>( // Note: `passes` is often empty. In that case, it's faster to run // `builtin_lints` directly rather than bundling it up into the // `RuntimeCombinedLateLintPass`. - let mut passes: Vec<_> = unerased_lint_store(&tcx.sess) + let mut passes: Vec<_> = unerased_lint_store(tcx.sess) .late_module_passes .iter() .map(|mk_pass| (mk_pass)(tcx)) @@ -405,7 +405,7 @@ fn late_lint_mod_inner<'tcx, T: LateLintPass<'tcx>>( fn late_lint_crate<'tcx>(tcx: TyCtxt<'tcx>) { // Note: `passes` is often empty. let mut passes: Vec<_> = - unerased_lint_store(&tcx.sess).late_passes.iter().map(|mk_pass| (mk_pass)(tcx)).collect(); + unerased_lint_store(tcx.sess).late_passes.iter().map(|mk_pass| (mk_pass)(tcx)).collect(); if passes.is_empty() { return; @@ -416,7 +416,7 @@ fn late_lint_crate<'tcx>(tcx: TyCtxt<'tcx>) { enclosing_body: None, cached_typeck_results: Cell::new(None), param_env: ty::ParamEnv::empty(), - effective_visibilities: &tcx.effective_visibilities(()), + effective_visibilities: tcx.effective_visibilities(()), last_node_with_lint_attrs: hir::CRATE_HIR_ID, generics: None, only_module: false, diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index ee5fa87e45d..1281cc9f920 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -123,7 +123,7 @@ impl LintLevelSets { } fn lint_expectations(tcx: TyCtxt<'_>, (): ()) -> Vec<(LintExpectationId, LintExpectation)> { - let store = unerased_lint_store(&tcx.sess); + let store = unerased_lint_store(tcx.sess); let mut builder = LintLevelsBuilder { sess: tcx.sess, @@ -138,7 +138,7 @@ fn lint_expectations(tcx: TyCtxt<'_>, (): ()) -> Vec<(LintExpectationId, LintExp }, warn_about_weird_lints: false, store, - registered_tools: &tcx.registered_tools(()), + registered_tools: tcx.registered_tools(()), }; builder.add_command_line(); @@ -152,7 +152,7 @@ fn lint_expectations(tcx: TyCtxt<'_>, (): ()) -> Vec<(LintExpectationId, LintExp #[instrument(level = "trace", skip(tcx), ret)] fn shallow_lint_levels_on(tcx: TyCtxt<'_>, owner: hir::OwnerId) -> ShallowLintLevelMap { - let store = unerased_lint_store(&tcx.sess); + let store = unerased_lint_store(tcx.sess); let attrs = tcx.hir_attrs(owner); let mut levels = LintLevelsBuilder { @@ -167,7 +167,7 @@ fn shallow_lint_levels_on(tcx: TyCtxt<'_>, owner: hir::OwnerId) -> ShallowLintLe }, warn_about_weird_lints: false, store, - registered_tools: &tcx.registered_tools(()), + registered_tools: tcx.registered_tools(()), }; if owner == hir::CRATE_OWNER_ID { @@ -605,7 +605,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { let orig_level = level; let lint_flag_val = Symbol::intern(lint_name); - let Ok(ids) = self.store.find_lints(&lint_name) else { + let Ok(ids) = self.store.find_lints(lint_name) else { // errors already handled above continue; }; @@ -629,7 +629,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { /// (e.g. if a forbid was already inserted on the same scope), then emits a /// diagnostic with no change to `specs`. fn insert_spec(&mut self, id: LintId, (mut level, src): LevelAndSource) { - let (old_level, old_src) = self.provider.get_lint_level(id.lint, &self.sess); + let (old_level, old_src) = self.provider.get_lint_level(id.lint, self.sess); if let Level::Expect(id) = &mut level && let LintExpectationId::Stable { .. } = id { @@ -929,12 +929,12 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { DeprecatedLintName { name, suggestion: sp, - replace: &new_lint_name, + replace: new_lint_name, }, ); let src = LintLevelSource::Node { - name: Symbol::intern(&new_lint_name), + name: Symbol::intern(new_lint_name), span: sp, reason, }; diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 829ac6903de..c4d54c95e22 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -250,7 +250,7 @@ impl<'a> DecorateLint<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> { diag.span_label(self.label, fluent::lint_label); rustc_session::parse::add_feature_diagnostics( diag, - &self.parse_sess, + self.parse_sess, sym::async_fn_track_caller, ); diag diff --git a/compiler/rustc_lint/src/non_ascii_idents.rs b/compiler/rustc_lint/src/non_ascii_idents.rs index 62bb8c2c67d..4f92fcd71c6 100644 --- a/compiler/rustc_lint/src/non_ascii_idents.rs +++ b/compiler/rustc_lint/src/non_ascii_idents.rs @@ -204,7 +204,7 @@ impl EarlyLintPass for NonAsciiIdents { // Get the skeleton as a `Symbol`. skeleton_buf.clear(); - skeleton_buf.extend(skeleton(&symbol_str)); + skeleton_buf.extend(skeleton(symbol_str)); let skeleton_sym = if *symbol_str == *skeleton_buf { symbol } else { diff --git a/compiler/rustc_lint/src/nonstandard_style.rs b/compiler/rustc_lint/src/nonstandard_style.rs index 66dc726df89..d6ed0250efc 100644 --- a/compiler/rustc_lint/src/nonstandard_style.rs +++ b/compiler/rustc_lint/src/nonstandard_style.rs @@ -334,7 +334,7 @@ impl<'tcx> LateLintPass<'tcx> for NonSnakeCase { let crate_ident = if let Some(name) = &cx.tcx.sess.opts.crate_name { Some(Ident::from_str(name)) } else { - attr::find_by_name(&cx.tcx.hir().attrs(hir::CRATE_HIR_ID), sym::crate_name) + attr::find_by_name(cx.tcx.hir().attrs(hir::CRATE_HIR_ID), sym::crate_name) .and_then(|attr| attr.meta()) .and_then(|meta| { meta.name_value_literal().and_then(|lit| { @@ -473,7 +473,7 @@ impl NonUpperCaseGlobals { fn check_upper_case(cx: &LateContext<'_>, sort: &str, ident: &Ident) { let name = ident.name.as_str(); if name.chars().any(|c| c.is_lowercase()) { - let uc = NonSnakeCase::to_snake_case(&name).to_uppercase(); + let uc = NonSnakeCase::to_snake_case(name).to_uppercase(); // We cannot provide meaningful suggestions // if the characters are in the category of "Lowercase Letter". let sub = if *name != uc { @@ -520,7 +520,7 @@ impl<'tcx> LateLintPass<'tcx> for NonUpperCaseGlobals { fn check_pat(&mut self, cx: &LateContext<'_>, p: &hir::Pat<'_>) { // Lint for constants that look like binding identifiers (#7526) - if let PatKind::Path(hir::QPath::Resolved(None, ref path)) = p.kind { + if let PatKind::Path(hir::QPath::Resolved(None, path)) = p.kind { if let Res::Def(DefKind::Const, _) = path.res { if path.segments.len() == 1 { NonUpperCaseGlobals::check_upper_case( diff --git a/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs b/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs index c24846ca939..44b23b8bdc0 100644 --- a/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs +++ b/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs @@ -113,7 +113,7 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound { for (assoc_pred, assoc_pred_span) in cx .tcx .explicit_item_bounds(proj.projection_ty.def_id) - .iter_instantiated_copied(cx.tcx, &proj.projection_ty.args) + .iter_instantiated_copied(cx.tcx, proj.projection_ty.args) { let assoc_pred = assoc_pred.fold_with(proj_replacer); let Ok(assoc_pred) = traits::fully_normalize( diff --git a/compiler/rustc_lint/src/pass_by_value.rs b/compiler/rustc_lint/src/pass_by_value.rs index cad2cd7fa4c..fce750c9b55 100644 --- a/compiler/rustc_lint/src/pass_by_value.rs +++ b/compiler/rustc_lint/src/pass_by_value.rs @@ -28,7 +28,7 @@ impl<'tcx> LateLintPass<'tcx> for PassByValue { return; } } - if let Some(t) = path_for_pass_by_value(cx, &inner_ty) { + if let Some(t) = path_for_pass_by_value(cx, inner_ty) { cx.emit_spanned_lint( PASS_BY_VALUE, ty.span, diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index 706c8c7add5..bae63ae1716 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -623,7 +623,7 @@ fn lint_nan<'tcx>( impl<'tcx> LateLintPass<'tcx> for TypeLimits { fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx hir::Expr<'tcx>) { match e.kind { - hir::ExprKind::Unary(hir::UnOp::Neg, ref expr) => { + hir::ExprKind::Unary(hir::UnOp::Neg, expr) => { // Propagate negation, if the negation itself isn't negated if self.negated_expr_id != Some(e.hir_id) { self.negated_expr_id = Some(expr.hir_id); @@ -632,14 +632,14 @@ impl<'tcx> LateLintPass<'tcx> for TypeLimits { } hir::ExprKind::Binary(binop, ref l, ref r) => { if is_comparison(binop) { - if !check_limits(cx, binop, &l, &r) { + if !check_limits(cx, binop, l, r) { cx.emit_spanned_lint(UNUSED_COMPARISONS, e.span, UnusedComparisons); } else { lint_nan(cx, e, binop, l, r); } } } - hir::ExprKind::Lit(ref lit) => lint_literal(cx, self, e, lit), + hir::ExprKind::Lit(lit) => lint_literal(cx, self, e, lit), _ => {} }; @@ -685,7 +685,7 @@ impl<'tcx> LateLintPass<'tcx> for TypeLimits { ty::Int(int_ty) => { let (min, max) = int_ty_range(int_ty); let lit_val: i128 = match lit.kind { - hir::ExprKind::Lit(ref li) => match li.node { + hir::ExprKind::Lit(li) => match li.node { ast::LitKind::Int( v, ast::LitIntType::Signed(_) | ast::LitIntType::Unsuffixed, @@ -699,7 +699,7 @@ impl<'tcx> LateLintPass<'tcx> for TypeLimits { ty::Uint(uint_ty) => { let (min, max): (u128, u128) = uint_ty_range(uint_ty); let lit_val: u128 = match lit.kind { - hir::ExprKind::Lit(ref li) => match li.node { + hir::ExprKind::Lit(li) => match li.node { ast::LitKind::Int(v, _) => v, _ => return true, }, @@ -1015,7 +1015,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { // We can't completely trust `repr(C)` markings, so make sure the fields are actually safe. let mut all_phantom = !variant.fields.is_empty(); for field in &variant.fields { - all_phantom &= match self.check_field_type_for_ffi(cache, &field, args) { + all_phantom &= match self.check_field_type_for_ffi(cache, field, args) { FfiSafe => false, // `()` fields are FFI-safe! FfiUnsafe { ty, .. } if ty.is_unit() => false, @@ -1399,7 +1399,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { } } - if let hir::FnRetTy::Return(ref ret_hir) = decl.output { + if let hir::FnRetTy::Return(ret_hir) = decl.output { for (fn_ptr_ty, span) in self.find_fn_ptr_ty_with_external_abi(ret_hir, sig.output()) { self.check_type_for_ffi_and_report_errors(span, fn_ptr_ty, false, true); } @@ -1415,7 +1415,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { self.check_type_for_ffi_and_report_errors(input_hir.span, *input_ty, false, false); } - if let hir::FnRetTy::Return(ref ret_hir) = decl.output { + if let hir::FnRetTy::Return(ret_hir) = decl.output { self.check_type_for_ffi_and_report_errors(ret_hir.span, sig.output(), false, true); } } @@ -1487,13 +1487,13 @@ impl<'tcx> LateLintPass<'tcx> for ImproperCTypesDeclarations { let abi = cx.tcx.hir().get_foreign_abi(it.hir_id()); match it.kind { - hir::ForeignItemKind::Fn(ref decl, _, _) if !vis.is_internal_abi(abi) => { + hir::ForeignItemKind::Fn(decl, _, _) if !vis.is_internal_abi(abi) => { vis.check_foreign_fn(it.owner_id.def_id, decl); } - hir::ForeignItemKind::Static(ref ty, _) if !vis.is_internal_abi(abi) => { + hir::ForeignItemKind::Static(ty, _) if !vis.is_internal_abi(abi) => { vis.check_foreign_static(it.owner_id, ty.span); } - hir::ForeignItemKind::Fn(ref decl, _, _) => vis.check_fn(it.owner_id.def_id, decl), + hir::ForeignItemKind::Fn(decl, _, _) => vis.check_fn(it.owner_id.def_id, decl), hir::ForeignItemKind::Static(..) | hir::ForeignItemKind::Type => (), } } @@ -1705,7 +1705,7 @@ impl InvalidAtomicOrdering { sym::AtomicI64, sym::AtomicI128, ]; - if let ExprKind::MethodCall(ref method_path, _, args, _) = &expr.kind + if let ExprKind::MethodCall(method_path, _, args, _) = &expr.kind && recognized_names.contains(&method_path.ident.name) && let Some(m_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) && let Some(impl_did) = cx.tcx.impl_of_method(m_def_id) @@ -1766,7 +1766,7 @@ impl InvalidAtomicOrdering { } fn check_memory_fence(cx: &LateContext<'_>, expr: &Expr<'_>) { - if let ExprKind::Call(ref func, ref args) = expr.kind + if let ExprKind::Call(func, args) = expr.kind && let ExprKind::Path(ref func_qpath) = func.kind && let Some(def_id) = cx.qpath_res(func_qpath, func.hir_id).opt_def_id() && matches!(cx.tcx.get_diagnostic_name(def_id), Some(sym::fence | sym::compiler_fence)) diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index 0ae91ac28a7..b4535c72d6c 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -111,7 +111,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { } if let hir::ExprKind::Match(await_expr, _arms, hir::MatchSource::AwaitDesugar) = expr.kind - && let ty = cx.typeck_results().expr_ty(&await_expr) + && let ty = cx.typeck_results().expr_ty(await_expr) && let ty::Alias(ty::Opaque, ty::AliasTy { def_id: future_def_id, .. }) = ty.kind() && cx.tcx.ty_is_opaque_future(ty) && let async_fn_def_id = cx.tcx.parent(*future_def_id) @@ -132,9 +132,9 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { return; } - let ty = cx.typeck_results().expr_ty(&expr); + let ty = cx.typeck_results().expr_ty(expr); - let must_use_result = is_ty_must_use(cx, ty, &expr, expr.span); + let must_use_result = is_ty_must_use(cx, ty, expr, expr.span); let type_lint_emitted_or_suppressed = match must_use_result { Some(path) => { emit_must_use_untranslated(cx, &path, "", "", 1, false, expr_is_from_block); @@ -211,7 +211,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { expr_is_from_block: bool, ) -> bool { let maybe_def_id = match expr.kind { - hir::ExprKind::Call(ref callee, _) => { + hir::ExprKind::Call(callee, _) => { match callee.kind { hir::ExprKind::Path(ref qpath) => { match cx.qpath_res(qpath, callee.hir_id) { @@ -692,7 +692,7 @@ trait UnusedDelimLint { innermost = match &innermost.kind { ExprKind::AddrOf(_, _, expr) => expr, _ => { - if parser::contains_exterior_struct_lit(&innermost) { + if parser::contains_exterior_struct_lit(innermost) { return true; } else { break; @@ -721,7 +721,7 @@ trait UnusedDelimLint { return matches!(rhs.kind, ExprKind::Block(..)); } - _ => return parser::contains_exterior_struct_lit(&inner), + _ => return parser::contains_exterior_struct_lit(inner), } } } @@ -896,7 +896,7 @@ trait UnusedDelimLint { }; self.check_unused_delims_expr( cx, - &value, + value, ctx, followed_by_block, left_pos, @@ -919,7 +919,7 @@ trait UnusedDelimLint { StmtKind::Expr(ref expr) => { self.check_unused_delims_expr( cx, - &expr, + expr, UnusedDelimsCtx::BlockRetValue, false, None, diff --git a/compiler/rustc_metadata/src/creader.rs b/compiler/rustc_metadata/src/creader.rs index 14bbe65d5f1..169b56d40fa 100644 --- a/compiler/rustc_metadata/src/creader.rs +++ b/compiler/rustc_metadata/src/creader.rs @@ -427,7 +427,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> { let crate_metadata = CrateMetadata::new( self.sess, - &self.cstore, + self.cstore, metadata, crate_root, raw_proc_macros, @@ -515,7 +515,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> { Err(err) => { let missing_core = self.maybe_resolve_crate(sym::core, CrateDepKind::Explicit, None).is_err(); - err.report(&self.sess, span, missing_core); + err.report(self.sess, span, missing_core); None } } @@ -987,7 +987,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> { self.report_unused_deps(krate); - info!("{:?}", CrateDump(&self.cstore)); + info!("{:?}", CrateDump(self.cstore)); } pub fn process_extern_crate( diff --git a/compiler/rustc_metadata/src/fs.rs b/compiler/rustc_metadata/src/fs.rs index 7eb2a347db2..4b451253f2b 100644 --- a/compiler/rustc_metadata/src/fs.rs +++ b/compiler/rustc_metadata/src/fs.rs @@ -94,7 +94,7 @@ pub fn encode_and_write_metadata(tcx: TyCtxt<'_>) -> (EncodedMetadata, bool) { tcx.sess .parse_sess .span_diagnostic - .emit_artifact_notification(&out_filename.as_path(), "metadata"); + .emit_artifact_notification(out_filename.as_path(), "metadata"); } (filename, None) } else { diff --git a/compiler/rustc_metadata/src/locator.rs b/compiler/rustc_metadata/src/locator.rs index 3a99ddc1b7a..2b5773320b4 100644 --- a/compiler/rustc_metadata/src/locator.rs +++ b/compiler/rustc_metadata/src/locator.rs @@ -980,7 +980,7 @@ impl CrateError { for CrateMismatch { path, .. } in mismatches { sess.emit_err(errors::CrateLocationUnknownType { span, - path: &path, + path: path, crate_name, }); sess.emit_err(errors::LibFilenameForm { diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index 909a977ccc9..0250c92dd78 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -394,7 +394,7 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) { native_library: |tcx, id| { tcx.native_libraries(id.krate) .iter() - .filter(|lib| native_libs::relevant_lib(&tcx.sess, lib)) + .filter(|lib| native_libs::relevant_lib(tcx.sess, lib)) .find(|lib| { let Some(fm_id) = lib.foreign_module else { return false; diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 19c5e8e5d59..d6964a241bf 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -160,7 +160,7 @@ impl<'a, 'tcx> Encodable> for ExpnIndex { impl<'a, 'tcx> Encodable> for SyntaxContext { fn encode(&self, s: &mut EncodeContext<'a, 'tcx>) { - rustc_span::hygiene::raw_encode_syntax_context(*self, &s.hygiene_ctxt, s); + rustc_span::hygiene::raw_encode_syntax_context(*self, s.hygiene_ctxt, s); } } @@ -660,7 +660,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { // Encode exported symbols info. This is prefetched in `encode_metadata` so we encode // this as late as possible to give the prefetching as much time as possible to complete. let exported_symbols = stat!("exported-symbols", || { - self.encode_exported_symbols(&tcx.exported_symbols(LOCAL_CRATE)) + self.encode_exported_symbols(tcx.exported_symbols(LOCAL_CRATE)) }); // Encode the hygiene data. @@ -694,15 +694,15 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { has_global_allocator: tcx.has_global_allocator(LOCAL_CRATE), has_alloc_error_handler: tcx.has_alloc_error_handler(LOCAL_CRATE), has_panic_handler: tcx.has_panic_handler(LOCAL_CRATE), - has_default_lib_allocator: attr::contains_name(&attrs, sym::default_lib_allocator), + has_default_lib_allocator: attr::contains_name(attrs, sym::default_lib_allocator), proc_macro_data, debugger_visualizers, - compiler_builtins: attr::contains_name(&attrs, sym::compiler_builtins), - needs_allocator: attr::contains_name(&attrs, sym::needs_allocator), - needs_panic_runtime: attr::contains_name(&attrs, sym::needs_panic_runtime), - no_builtins: attr::contains_name(&attrs, sym::no_builtins), - panic_runtime: attr::contains_name(&attrs, sym::panic_runtime), - profiler_runtime: attr::contains_name(&attrs, sym::profiler_runtime), + compiler_builtins: attr::contains_name(attrs, sym::compiler_builtins), + needs_allocator: attr::contains_name(attrs, sym::needs_allocator), + needs_panic_runtime: attr::contains_name(attrs, sym::needs_panic_runtime), + no_builtins: attr::contains_name(attrs, sym::no_builtins), + panic_runtime: attr::contains_name(attrs, sym::panic_runtime), + profiler_runtime: attr::contains_name(attrs, sym::profiler_runtime), symbol_mangling_version: tcx.sess.opts.get_symbol_mangling_version(), crate_deps, @@ -1728,9 +1728,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { fn encode_info_for_macro(&mut self, def_id: LocalDefId) { let tcx = self.tcx; - let hir::ItemKind::Macro(ref macro_def, _) = tcx.hir().expect_item(def_id).kind else { - bug!() - }; + let hir::ItemKind::Macro(macro_def, _) = tcx.hir().expect_item(def_id).kind else { bug!() }; self.tables.is_macro_rules.set(def_id.local_def_index, macro_def.macro_rules); record!(self.tables.macro_definition[def_id.to_def_id()] <- &*macro_def.body); } diff --git a/compiler/rustc_metadata/src/rmeta/table.rs b/compiler/rustc_metadata/src/rmeta/table.rs index 027994c40ab..af076f3d4c7 100644 --- a/compiler/rustc_metadata/src/rmeta/table.rs +++ b/compiler/rustc_metadata/src/rmeta/table.rs @@ -382,8 +382,8 @@ impl LazyArray { } fn from_bytes_impl(position: &[u8; 8], meta: &[u8; 8]) -> Option> { - let position = NonZeroUsize::new(u64::from_bytes(&position) as usize)?; - let len = u64::from_bytes(&meta) as usize; + let position = NonZeroUsize::new(u64::from_bytes(position) as usize)?; + let len = u64::from_bytes(meta) as usize; Some(LazyArray::from_position_and_num_elems(position, len)) } } diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index 58c0c6bab49..9d8168382d2 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -531,9 +531,7 @@ impl<'hir> Map<'hir> { pub fn get_module(self, module: LocalModDefId) -> (&'hir Mod<'hir>, Span, HirId) { let hir_id = HirId::make_owner(module.to_local_def_id()); match self.tcx.hir_owner(hir_id.owner).map(|o| o.node) { - Some(OwnerNode::Item(&Item { span, kind: ItemKind::Mod(ref m), .. })) => { - (m, span, hir_id) - } + Some(OwnerNode::Item(&Item { span, kind: ItemKind::Mod(m), .. })) => (m, span, hir_id), Some(OwnerNode::Crate(item)) => (item, item.spans.inner_span, hir_id), node => panic!("not a module: {node:?}"), } @@ -1278,7 +1276,7 @@ fn hir_id_to_string(map: Map<'_>, id: HirId) -> String { ItemKind::ForeignMod { .. } => "foreign mod", ItemKind::GlobalAsm(..) => "global asm", ItemKind::TyAlias(..) => "ty", - ItemKind::OpaqueTy(ref opaque) => { + ItemKind::OpaqueTy(opaque) => { if opaque.in_trait { "opaque type in trait" } else { @@ -1314,10 +1312,10 @@ fn hir_id_to_string(map: Map<'_>, id: HirId) -> String { format!("{id} ({kind} `{}` in {})", ti.ident, path_str(ti.owner_id.def_id)) } - Some(Node::Variant(ref variant)) => { + Some(Node::Variant(variant)) => { format!("{id} (variant `{}` in {})", variant.ident, path_str(variant.def_id)) } - Some(Node::Field(ref field)) => { + Some(Node::Field(field)) => { format!("{id} (field `{}` in {})", field.ident, path_str(field.def_id)) } Some(Node::AnonConst(_)) => node_str("const"), @@ -1341,7 +1339,7 @@ fn hir_id_to_string(map: Map<'_>, id: HirId) -> String { ctor.ctor_def_id().map_or("".into(), |def_id| path_str(def_id)), ), Some(Node::Lifetime(_)) => node_str("lifetime"), - Some(Node::GenericParam(ref param)) => { + Some(Node::GenericParam(param)) => { format!("{id} (generic_param {})", path_str(param.def_id)) } Some(Node::Crate(..)) => String::from("(root_crate)"), diff --git a/compiler/rustc_middle/src/middle/region.rs b/compiler/rustc_middle/src/middle/region.rs index b76d1d6e141..9d55295fb66 100644 --- a/compiler/rustc_middle/src/middle/region.rs +++ b/compiler/rustc_middle/src/middle/region.rs @@ -178,7 +178,7 @@ impl Scope { }; let span = tcx.hir().span(hir_id); if let ScopeData::Remainder(first_statement_index) = self.data { - if let Node::Block(ref blk) = tcx.hir().get(hir_id) { + if let Node::Block(blk) = tcx.hir().get(hir_id) { // Want span for scope starting after the // indexed statement and ending at end of // `blk`; reuse span of `blk` and shift `lo` diff --git a/compiler/rustc_middle/src/mir/consts.rs b/compiler/rustc_middle/src/mir/consts.rs index a9d09709e84..84a9ab4013b 100644 --- a/compiler/rustc_middle/src/mir/consts.rs +++ b/compiler/rustc_middle/src/mir/consts.rs @@ -592,7 +592,7 @@ impl<'tcx> TyCtxt<'tcx> { let caller = self.sess.source_map().lookup_char_pos(topmost.lo()); self.const_caller_location( rustc_span::symbol::Symbol::intern( - &caller.file.name.for_codegen(&self.sess).to_string_lossy(), + &caller.file.name.for_codegen(self.sess).to_string_lossy(), ), caller.line as u32, caller.col_display as u32 + 1, diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 874c997c23b..d4778cdccf3 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -973,7 +973,7 @@ pub enum LocalInfo<'tcx> { impl<'tcx> LocalDecl<'tcx> { pub fn local_info(&self) -> &LocalInfo<'tcx> { - &self.local_info.as_ref().assert_crate_local() + self.local_info.as_ref().assert_crate_local() } /// Returns `true` only if local is a binding that can itself be diff --git a/compiler/rustc_middle/src/mir/spanview.rs b/compiler/rustc_middle/src/mir/spanview.rs index 38538a0b316..46e5c74c73c 100644 --- a/compiler/rustc_middle/src/mir/spanview.rs +++ b/compiler/rustc_middle/src/mir/spanview.rs @@ -369,7 +369,7 @@ where debug_indent, span, viewable.span ); from_pos = span.hi(); - make_html_snippet(tcx, span, Some(&viewable)) + make_html_snippet(tcx, span, Some(viewable)) } else { None }; @@ -439,7 +439,7 @@ where tcx, from_pos, to_pos, - &remaining_viewables, + remaining_viewables, subalt, layer + 1, w, @@ -472,7 +472,7 @@ where "{}After overlaps, writing (end span?) {:?} of viewable.span {:?}", debug_indent, span, viewable.span ); - if let Some(ref html_snippet) = make_html_snippet(tcx, span, Some(&viewable)) { + if let Some(ref html_snippet) = make_html_snippet(tcx, span, Some(viewable)) { from_pos = span.hi(); write_span(html_snippet, &viewable.tooltip, alt, layer, w)?; } diff --git a/compiler/rustc_middle/src/mir/statement.rs b/compiler/rustc_middle/src/mir/statement.rs index 3471d620ee6..be35a54be58 100644 --- a/compiler/rustc_middle/src/mir/statement.rs +++ b/compiler/rustc_middle/src/mir/statement.rs @@ -159,7 +159,7 @@ impl<'tcx> Place<'tcx> { #[inline] pub fn as_ref(&self) -> PlaceRef<'tcx> { - PlaceRef { local: self.local, projection: &self.projection } + PlaceRef { local: self.local, projection: self.projection } } /// Iterate over the projections in evaluation order, i.e., the first element is the base with diff --git a/compiler/rustc_middle/src/mir/tcx.rs b/compiler/rustc_middle/src/mir/tcx.rs index 6ab2da23a8a..557c4d0f564 100644 --- a/compiler/rustc_middle/src/mir/tcx.rs +++ b/compiler/rustc_middle/src/mir/tcx.rs @@ -40,7 +40,7 @@ impl<'tcx> PlaceTy<'tcx> { None => adt_def.non_enum_variant(), Some(variant_index) => { assert!(adt_def.is_enum()); - &adt_def.variant(variant_index) + adt_def.variant(variant_index) } }; let field_def = &variant_def.fields[f]; @@ -143,7 +143,7 @@ impl<'tcx> Place<'tcx> { where D: HasLocalDecls<'tcx>, { - Place::ty_from(self.local, &self.projection, local_decls, tcx) + Place::ty_from(self.local, self.projection, local_decls, tcx) } } @@ -152,7 +152,7 @@ impl<'tcx> PlaceRef<'tcx> { where D: HasLocalDecls<'tcx>, { - Place::ty_from(self.local, &self.projection, local_decls, tcx) + Place::ty_from(self.local, self.projection, local_decls, tcx) } } diff --git a/compiler/rustc_middle/src/query/on_disk_cache.rs b/compiler/rustc_middle/src/query/on_disk_cache.rs index 280f5d0a84c..ee6567f6cc4 100644 --- a/compiler/rustc_middle/src/query/on_disk_cache.rs +++ b/compiler/rustc_middle/src/query/on_disk_cache.rs @@ -246,7 +246,7 @@ impl<'sess> OnDiskCache<'sess> { let index = SourceFileIndex(index as u32); let file_ptr: *const SourceFile = &**file as *const _; file_to_file_index.insert(file_ptr, index); - let source_file_id = EncodedSourceFileId::new(tcx, &file); + let source_file_id = EncodedSourceFileId::new(tcx, file); file_index_to_stable_id.insert(index, source_file_id); } @@ -482,13 +482,8 @@ pub struct CacheDecoder<'a, 'tcx> { impl<'a, 'tcx> CacheDecoder<'a, 'tcx> { #[inline] fn file_index_to_file(&self, index: SourceFileIndex) -> Lrc { - let CacheDecoder { - tcx, - ref file_index_to_file, - ref file_index_to_stable_id, - ref source_map, - .. - } = *self; + let CacheDecoder { tcx, file_index_to_file, file_index_to_stable_id, source_map, .. } = + *self; file_index_to_file .borrow_mut() diff --git a/compiler/rustc_middle/src/thir/visit.rs b/compiler/rustc_middle/src/thir/visit.rs index 8feefb4c03c..62c3ceeab8a 100644 --- a/compiler/rustc_middle/src/thir/visit.rs +++ b/compiler/rustc_middle/src/thir/visit.rs @@ -226,7 +226,7 @@ pub fn walk_pat<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, pat: &Pat<' ty: _, is_primary: _, name: _, - } => visitor.visit_pat(&subpattern), + } => visitor.visit_pat(subpattern), Binding { .. } | Wild | Error(_) => {} Variant { subpatterns, adt_def: _, args: _, variant_index: _ } | Leaf { subpatterns } => { for subpattern in subpatterns { @@ -249,7 +249,7 @@ pub fn walk_pat<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, pat: &Pat<' } Or { pats } => { for pat in pats.iter() { - visitor.visit_pat(&pat); + visitor.visit_pat(pat); } } }; diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index 6cd75e08727..c1bb03e99da 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -686,7 +686,7 @@ impl<'tcx, N> ImplSource<'tcx, N> { pub fn borrow_nested_obligations(&self) -> &[N] { match self { ImplSource::UserDefined(i) => &i.nested, - ImplSource::Param(n) | ImplSource::Builtin(_, n) => &n, + ImplSource::Param(n) | ImplSource::Builtin(_, n) => n, } } diff --git a/compiler/rustc_middle/src/ty/adt.rs b/compiler/rustc_middle/src/ty/adt.rs index f50969dd967..7650389415c 100644 --- a/compiler/rustc_middle/src/ty/adt.rs +++ b/compiler/rustc_middle/src/ty/adt.rs @@ -99,7 +99,7 @@ pub struct AdtDefData { impl PartialOrd for AdtDefData { fn partial_cmp(&self, other: &AdtDefData) -> Option { - Some(self.cmp(&other)) + Some(self.cmp(other)) } } @@ -375,7 +375,7 @@ impl<'tcx> AdtDef<'tcx> { /// Asserts this is a struct or union and returns its unique variant. pub fn non_enum_variant(self) -> &'tcx VariantDef { assert!(self.is_struct() || self.is_union()); - &self.variant(FIRST_VARIANT) + self.variant(FIRST_VARIANT) } #[inline] diff --git a/compiler/rustc_middle/src/ty/codec.rs b/compiler/rustc_middle/src/ty/codec.rs index 8b67e39667b..81cf41889d4 100644 --- a/compiler/rustc_middle/src/ty/codec.rs +++ b/compiler/rustc_middle/src/ty/codec.rs @@ -297,7 +297,7 @@ impl<'tcx, D: TyDecoder>> Decodable for AllocId { impl<'tcx, D: TyDecoder>> Decodable for ty::SymbolName<'tcx> { fn decode(decoder: &mut D) -> Self { - ty::SymbolName::new(decoder.interner(), &decoder.read_str()) + ty::SymbolName::new(decoder.interner(), decoder.read_str()) } } diff --git a/compiler/rustc_middle/src/ty/consts.rs b/compiler/rustc_middle/src/ty/consts.rs index af5ffc20d48..c46ab992359 100644 --- a/compiler/rustc_middle/src/ty/consts.rs +++ b/compiler/rustc_middle/src/ty/consts.rs @@ -183,11 +183,9 @@ impl<'tcx> Const<'tcx> { }; let lit_input = match expr.kind { - hir::ExprKind::Lit(ref lit) => Some(LitToConstInput { lit: &lit.node, ty, neg: false }), - hir::ExprKind::Unary(hir::UnOp::Neg, ref expr) => match expr.kind { - hir::ExprKind::Lit(ref lit) => { - Some(LitToConstInput { lit: &lit.node, ty, neg: true }) - } + hir::ExprKind::Lit(lit) => Some(LitToConstInput { lit: &lit.node, ty, neg: false }), + hir::ExprKind::Unary(hir::UnOp::Neg, expr) => match expr.kind { + hir::ExprKind::Lit(lit) => Some(LitToConstInput { lit: &lit.node, ty, neg: true }), _ => None, }, _ => None, diff --git a/compiler/rustc_middle/src/ty/error.rs b/compiler/rustc_middle/src/ty/error.rs index b26f98769c1..469593fe663 100644 --- a/compiler/rustc_middle/src/ty/error.rs +++ b/compiler/rustc_middle/src/ty/error.rs @@ -235,7 +235,7 @@ impl<'tcx> Ty<'tcx> { _ => "fn item".into(), }, ty::FnPtr(_) => "fn pointer".into(), - ty::Dynamic(ref inner, ..) if let Some(principal) = inner.principal() => { + ty::Dynamic(inner, ..) if let Some(principal) = inner.principal() => { format!("`dyn {}`", tcx.def_path_str(principal.def_id())).into() } ty::Dynamic(..) => "trait object".into(), @@ -281,7 +281,7 @@ impl<'tcx> Ty<'tcx> { | ty::Float(_) | ty::Str | ty::Never => "type".into(), - ty::Tuple(ref tys) if tys.is_empty() => "unit type".into(), + ty::Tuple(tys) if tys.is_empty() => "unit type".into(), ty::Adt(def, _) => def.descr().into(), ty::Foreign(_) => "extern type".into(), ty::Array(..) => "array".into(), diff --git a/compiler/rustc_middle/src/ty/generic_args.rs b/compiler/rustc_middle/src/ty/generic_args.rs index 8fd08c724d2..0c658fa1c80 100644 --- a/compiler/rustc_middle/src/ty/generic_args.rs +++ b/compiler/rustc_middle/src/ty/generic_args.rs @@ -86,7 +86,7 @@ impl<'tcx> Ord for GenericArg<'tcx> { impl<'tcx> PartialOrd for GenericArg<'tcx> { fn partial_cmp(&self, other: &GenericArg<'tcx>) -> Option { - Some(self.cmp(&other)) + Some(self.cmp(other)) } } diff --git a/compiler/rustc_middle/src/ty/generics.rs b/compiler/rustc_middle/src/ty/generics.rs index 4a6e3cfacd3..8316f9c3058 100644 --- a/compiler/rustc_middle/src/ty/generics.rs +++ b/compiler/rustc_middle/src/ty/generics.rs @@ -354,7 +354,7 @@ impl<'tcx> Generics { args: &'tcx [ty::GenericArg<'tcx>], ) -> &'tcx [ty::GenericArg<'tcx>] { let own = &args[self.parent_count..][..self.params.len()]; - if self.has_self && self.parent.is_none() { &own[1..] } else { &own } + if self.has_self && self.parent.is_none() { &own[1..] } else { own } } } diff --git a/compiler/rustc_middle/src/ty/impls_ty.rs b/compiler/rustc_middle/src/ty/impls_ty.rs index b03874a90e8..59c0639fea2 100644 --- a/compiler/rustc_middle/src/ty/impls_ty.rs +++ b/compiler/rustc_middle/src/ty/impls_ty.rs @@ -29,7 +29,7 @@ where } let mut hasher = StableHasher::new(); - (&self[..]).hash_stable(hcx, &mut hasher); + self[..].hash_stable(hcx, &mut hasher); let hash: Fingerprint = hasher.finish(); cache.borrow_mut().insert(key, hash); diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index aca6acd783b..4d8ac19dbe2 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -899,13 +899,13 @@ where ty::Str => TyMaybeWithLayout::Ty(tcx.types.u8), // Tuples, coroutines and closures. - ty::Closure(_, ref args) => field_ty_or_layout( + ty::Closure(_, args) => field_ty_or_layout( TyAndLayout { ty: args.as_closure().tupled_upvars_ty(), ..this }, cx, i, ), - ty::Coroutine(def_id, ref args, _) => match this.variants { + ty::Coroutine(def_id, args, _) => match this.variants { Variants::Single { index } => TyMaybeWithLayout::Ty( args.as_coroutine() .state_tys(def_id, tcx) diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 2436daf62cf..f240a99c8ff 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -1376,7 +1376,7 @@ impl<'tcx> InstantiatedPredicates<'tcx> { } pub fn iter(&self) -> <&Self as IntoIterator>::IntoIter { - (&self).into_iter() + self.into_iter() } } @@ -2020,7 +2020,7 @@ impl<'tcx> TyCtxt<'tcx> { } for attr in self.get_attrs(did, sym::repr) { - for r in attr::parse_repr_attr(&self.sess, attr) { + for r in attr::parse_repr_attr(self.sess, attr) { flags.insert(match r { attr::ReprRust => ReprFlags::empty(), attr::ReprC => ReprFlags::IS_C, @@ -2286,7 +2286,7 @@ impl<'tcx> TyCtxt<'tcx> { where 'tcx: 'attr, { - let filter_fn = move |a: &&ast::Attribute| a.path_matches(&attr); + let filter_fn = move |a: &&ast::Attribute| a.path_matches(attr); if let Some(did) = did.as_local() { self.hir().attrs(self.hir().local_def_id_to_hir_id(did)).iter().filter(filter_fn) } else { @@ -2498,7 +2498,7 @@ impl<'tcx> TyCtxt<'tcx> { pub fn is_impl_trait_defn(tcx: TyCtxt<'_>, def_id: DefId) -> Option { let def_id = def_id.as_local()?; if let Node::Item(item) = tcx.hir().get_by_def_id(def_id) { - if let hir::ItemKind::OpaqueTy(ref opaque_ty) = item.kind { + if let hir::ItemKind::OpaqueTy(opaque_ty) = item.kind { return match opaque_ty.origin { hir::OpaqueTyOrigin::FnReturn(parent) | hir::OpaqueTyOrigin::AsyncFn(parent) => { Some(parent) diff --git a/compiler/rustc_middle/src/ty/print/mod.rs b/compiler/rustc_middle/src/ty/print/mod.rs index 6bbc8f70f51..64ae11df5b5 100644 --- a/compiler/rustc_middle/src/ty/print/mod.rs +++ b/compiler/rustc_middle/src/ty/print/mod.rs @@ -250,7 +250,7 @@ fn characteristic_def_id_of_type_cached<'a>( ty::Ref(_, ty, _) => characteristic_def_id_of_type_cached(ty, visited), - ty::Tuple(ref tys) => tys.iter().find_map(|ty| { + ty::Tuple(tys) => tys.iter().find_map(|ty| { if visited.insert(ty) { return characteristic_def_id_of_type_cached(ty, visited); } diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index d478677c367..a58362950ff 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -322,7 +322,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { && let Some(symbol) = self.tcx().trimmed_def_paths(()).get(&def_id) { // If `Assoc` is unique, we don't want to talk about `Trait::Assoc`. - self.write_str(get_local_name(&self, *symbol, def_id, key).as_str())?; + self.write_str(get_local_name(self, *symbol, def_id, key).as_str())?; return Ok(true); } if let Some(symbol) = key.get_opt_name() { @@ -332,7 +332,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { && let Some(symbol) = parent_key.get_opt_name() { // Trait - self.write_str(get_local_name(&self, symbol, parent, parent_key).as_str())?; + self.write_str(get_local_name(self, symbol, parent, parent_key).as_str())?; self.write_str("::")?; } else if let DefKind::Variant = kind && let Some(parent) = self.tcx().opt_parent(def_id) @@ -343,7 +343,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { // For associated items and variants, we want the "full" path, namely, include // the parent type in the path. For example, `Iterator::Item`. - self.write_str(get_local_name(&self, symbol, parent, parent_key).as_str())?; + self.write_str(get_local_name(self, symbol, parent, parent_key).as_str())?; self.write_str("::")?; } else if let DefKind::Struct | DefKind::Union @@ -358,7 +358,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { // If not covered above, like for example items out of `impl` blocks, fallback. return Ok(false); } - self.write_str(get_local_name(&self, symbol, def_id, key).as_str())?; + self.write_str(get_local_name(self, symbol, def_id, key).as_str())?; return Ok(true); } Ok(false) @@ -660,7 +660,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { p!(print(ty::TypeAndMut { ty, mutbl })) } ty::Never => p!("!"), - ty::Tuple(ref tys) => { + ty::Tuple(tys) => { p!("(", comma_sep(tys.iter())); if tys.len() == 1 { p!(","); @@ -2399,7 +2399,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> { let possible_names = ('a'..='z').rev().map(|s| Symbol::intern(&format!("'{s}"))); let mut available_names = possible_names - .filter(|name| !self.used_region_names.contains(&name)) + .filter(|name| !self.used_region_names.contains(name)) .collect::>(); debug!(?available_names); let num_available = available_names.len(); @@ -2445,7 +2445,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> { br: ty::BoundRegion| { let (name, kind) = match br.kind { ty::BrAnon | ty::BrEnv => { - let name = next_name(&self); + let name = next_name(self); if let Some(lt_idx) = lifetime_idx { if lt_idx > binder_level_idx { @@ -2461,7 +2461,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> { (name, ty::BrNamed(CRATE_DEF_ID.to_def_id(), name)) } ty::BrNamed(def_id, kw::UnderscoreLifetime | kw::Empty) => { - let name = next_name(&self); + let name = next_name(self); if let Some(lt_idx) = lifetime_idx { if lt_idx > binder_level_idx { diff --git a/compiler/rustc_middle/src/ty/relate.rs b/compiler/rustc_middle/src/ty/relate.rs index 27e9be37fbf..d7d9afc30e7 100644 --- a/compiler/rustc_middle/src/ty/relate.rs +++ b/compiler/rustc_middle/src/ty/relate.rs @@ -482,7 +482,7 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>( // the (anonymous) type of the same closure expression. So // all of their regions should be equated. let args = relate_args_invariantly(relation, a_args, b_args)?; - Ok(Ty::new_closure(tcx, a_id, &args)) + Ok(Ty::new_closure(tcx, a_id, args)) } (&ty::RawPtr(a_mt), &ty::RawPtr(b_mt)) => { diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index ea0e179c00d..ff333b3f09a 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -1590,7 +1590,7 @@ impl<'tcx> Deref for Region<'tcx> { #[inline] fn deref(&self) -> &RegionKind<'tcx> { - &self.0.0 + self.0.0 } } @@ -2114,7 +2114,7 @@ impl<'tcx> Ty<'tcx> { #[inline] pub fn new_tup(tcx: TyCtxt<'tcx>, ts: &[Ty<'tcx>]) -> Ty<'tcx> { - if ts.is_empty() { tcx.types.unit } else { Ty::new(tcx, Tuple(tcx.mk_type_list(&ts))) } + if ts.is_empty() { tcx.types.unit } else { Ty::new(tcx, Tuple(tcx.mk_type_list(ts))) } } pub fn new_tup_from_iter(tcx: TyCtxt<'tcx>, iter: I) -> T::Output @@ -2270,7 +2270,7 @@ impl<'tcx> Ty<'tcx> { impl<'tcx> Ty<'tcx> { #[inline(always)] pub fn kind(self) -> &'tcx TyKind<'tcx> { - &self.0.0 + self.0.0 } #[inline(always)] @@ -2281,7 +2281,7 @@ impl<'tcx> Ty<'tcx> { #[inline] pub fn is_unit(self) -> bool { match self.kind() { - Tuple(ref tys) => tys.is_empty(), + Tuple(tys) => tys.is_empty(), _ => false, } } diff --git a/compiler/rustc_middle/src/ty/typeck_results.rs b/compiler/rustc_middle/src/ty/typeck_results.rs index 914ff1fabd1..0331546cdd9 100644 --- a/compiler/rustc_middle/src/ty/typeck_results.rs +++ b/compiler/rustc_middle/src/ty/typeck_results.rs @@ -241,7 +241,7 @@ impl<'tcx> TypeckResults<'tcx> { /// Returns the final resolution of a `QPath` in an `Expr` or `Pat` node. pub fn qpath_res(&self, qpath: &hir::QPath<'_>, id: hir::HirId) -> Res { match *qpath { - hir::QPath::Resolved(_, ref path) => path.res, + hir::QPath::Resolved(_, path) => path.res, hir::QPath::TypeRelative(..) | hir::QPath::LangItem(..) => self .type_dependent_def(id) .map_or(Res::Err, |(kind, def_id)| Res::Def(kind, def_id)), diff --git a/compiler/rustc_mir_build/src/build/block.rs b/compiler/rustc_mir_build/src/build/block.rs index ab4cd24881f..58295b39755 100644 --- a/compiler/rustc_mir_build/src/build/block.rs +++ b/compiler/rustc_mir_build/src/build/block.rs @@ -31,7 +31,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { destination, block, span, - &stmts, + stmts, expr, safety_mode, region_scope, @@ -42,7 +42,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { destination, block, span, - &stmts, + stmts, expr, safety_mode, region_scope, @@ -312,7 +312,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { None, Some((None, initializer_span)), ); - this.expr_into_pattern(block, &pattern, init) + this.expr_into_pattern(block, pattern, init) // irrefutable pattern }) }, diff --git a/compiler/rustc_mir_build/src/build/custom/mod.rs b/compiler/rustc_mir_build/src/build/custom/mod.rs index d302d538ad4..8c68a58d406 100644 --- a/compiler/rustc_mir_build/src/build/custom/mod.rs +++ b/compiler/rustc_mir_build/src/build/custom/mod.rs @@ -88,7 +88,7 @@ pub(super) fn build_custom_mir<'tcx>( }; let res: PResult<_> = try { - pctxt.parse_args(¶ms)?; + pctxt.parse_args(params)?; pctxt.parse_body(expr)?; }; if let Err(err) = res { diff --git a/compiler/rustc_mir_build/src/build/expr/as_place.rs b/compiler/rustc_mir_build/src/build/expr/as_place.rs index 7e9191a37d3..43e8348903e 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_place.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_place.rs @@ -175,7 +175,7 @@ fn to_upvars_resolved_place_builder<'tcx>( projection: &[PlaceElem<'tcx>], ) -> Option> { let Some((capture_index, capture)) = - find_capture_matching_projections(&cx.upvars, var_hir_id, &projection) + find_capture_matching_projections(&cx.upvars, var_hir_id, projection) else { let closure_span = cx.tcx.def_span(closure_def_id); if !enable_precise_capture(closure_span) { @@ -683,7 +683,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { Ty::new_imm_ref(tcx, tcx.lifetimes.re_erased, fake_borrow_deref_ty); let fake_borrow_temp = self.local_decls.push(LocalDecl::new(fake_borrow_ty, expr_span)); - let projection = tcx.mk_place_elems(&base_place.projection); + let projection = tcx.mk_place_elems(base_place.projection); self.cfg.push_assign( block, source_info, diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs index 304870274ac..83686667a4a 100644 --- a/compiler/rustc_mir_build/src/build/matches/mod.rs +++ b/compiler/rustc_mir_build/src/build/matches/mod.rs @@ -212,7 +212,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let scrutinee_place = unpack!(block = self.lower_scrutinee(block, scrutinee, scrutinee_span,)); - let mut arm_candidates = self.create_match_candidates(&scrutinee_place, &arms); + let mut arm_candidates = self.create_match_candidates(&scrutinee_place, arms); let match_has_guard = arm_candidates.iter().any(|(_, candidate)| candidate.has_guard); let mut candidates = @@ -424,7 +424,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { this.source_scope = source_scope; } - this.expr_into_dest(destination, arm_block, &&this.thir[arm.body]) + this.expr_into_dest(destination, arm_block, &this.thir[arm.body]) }) }) .collect(); @@ -505,7 +505,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let binding_end = self.bind_and_guard_matched_candidate( leaf_candidate, parent_bindings, - &fake_borrow_temps, + fake_borrow_temps, scrutinee_span, arm_match_scope, schedule_drops, @@ -613,7 +613,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { _ => { let place_builder = unpack!(block = self.lower_scrutinee(block, initializer, initializer.span)); - self.place_into_pattern(block, &irrefutable_pat, place_builder, true) + self.place_into_pattern(block, irrefutable_pat, place_builder, true) } } } @@ -625,7 +625,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { initializer: PlaceBuilder<'tcx>, set_match_place: bool, ) -> BlockAnd<()> { - let mut candidate = Candidate::new(initializer.clone(), &irrefutable_pat, false, self); + let mut candidate = Candidate::new(initializer.clone(), irrefutable_pat, false, self); let fake_borrow_temps = self.lower_match_tree( block, irrefutable_pat.span, @@ -700,7 +700,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { opt_match_place: Option<(Option<&Place<'tcx>>, Span)>, ) -> Option { self.visit_primary_bindings( - &pattern, + pattern, UserTypeProjections::none(), &mut |this, mutability, name, mode, var, span, ty, user_ty| { if visibility_scope.is_none() { @@ -1843,7 +1843,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let expr_span = expr.span; let expr_place_builder = unpack!(block = self.lower_scrutinee(block, expr, expr_span)); let wildcard = Pat::wildcard_from_ty(pat.ty); - let mut guard_candidate = Candidate::new(expr_place_builder.clone(), &pat, false, self); + let mut guard_candidate = Candidate::new(expr_place_builder.clone(), pat, false, self); let mut otherwise_candidate = Candidate::new(expr_place_builder.clone(), &wildcard, false, self); let fake_borrow_temps = self.lower_match_tree( diff --git a/compiler/rustc_mir_build/src/build/matches/simplify.rs b/compiler/rustc_mir_build/src/build/matches/simplify.rs index 6a40c8d840b..8a6cb26242a 100644 --- a/compiler/rustc_mir_build/src/build/matches/simplify.rs +++ b/compiler/rustc_mir_build/src/build/matches/simplify.rs @@ -69,7 +69,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { { existing_bindings.extend_from_slice(&new_bindings); mem::swap(&mut candidate.bindings, &mut existing_bindings); - candidate.subcandidates = self.create_or_subcandidates(candidate, &place, pats); + candidate.subcandidates = self.create_or_subcandidates(candidate, place, pats); return true; } diff --git a/compiler/rustc_mir_build/src/build/matches/test.rs b/compiler/rustc_mir_build/src/build/matches/test.rs index bdd4f2011eb..6bd60972c8b 100644 --- a/compiler/rustc_mir_build/src/build/matches/test.rs +++ b/compiler/rustc_mir_build/src/build/matches/test.rs @@ -736,7 +736,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // These are all binary tests. // // FIXME(#29623) we can be more clever here - let pattern_test = self.test(&match_pair); + let pattern_test = self.test(match_pair); if pattern_test.kind == test.kind { self.candidate_without_match_pair(match_pair_index, candidate); Some(0) diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs index 886d805454d..3d2396f33fc 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/build/mod.rs @@ -938,12 +938,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { scope = self.declare_bindings( scope, expr.span, - &pat, + pat, None, Some((Some(&place), span)), ); let place_builder = PlaceBuilder::from(local); - unpack!(block = self.place_into_pattern(block, &pat, place_builder, false)); + unpack!(block = self.place_into_pattern(block, pat, place_builder, false)); } } self.source_scope = original_source_scope; @@ -954,7 +954,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { self.source_scope = source_scope; } - self.expr_into_dest(Place::return_place(), block, &expr) + self.expr_into_dest(Place::return_place(), block, expr) } fn set_correct_source_scope_for_arg( diff --git a/compiler/rustc_mir_build/src/build/scope.rs b/compiler/rustc_mir_build/src/build/scope.rs index b3d3863b5db..d6ca873e992 100644 --- a/compiler/rustc_mir_build/src/build/scope.rs +++ b/compiler/rustc_mir_build/src/build/scope.rs @@ -995,7 +995,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } if scope.region_scope == region_scope { - let region_scope_span = region_scope.span(self.tcx, &self.region_scope_tree); + let region_scope_span = region_scope.span(self.tcx, self.region_scope_tree); // Attribute scope exit drops to scope's closing brace. let scope_end = self.tcx.sess.source_map().end_point(region_scope_span); diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs index fcb56360782..103b0d8e26a 100644 --- a/compiler/rustc_mir_build/src/check_unsafety.rs +++ b/compiler/rustc_mir_build/src/check_unsafety.rs @@ -200,7 +200,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for LayoutConstrainedPlaceVisitor<'a, 'tcx> { impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> { fn thir(&self) -> &'a Thir<'tcx> { - &self.thir + self.thir } fn visit_block(&mut self, block: &Block) { diff --git a/compiler/rustc_mir_build/src/thir/cx/block.rs b/compiler/rustc_mir_build/src/thir/cx/block.rs index a46ad6423a0..527eadb277e 100644 --- a/compiler/rustc_mir_build/src/thir/cx/block.rs +++ b/compiler/rustc_mir_build/src/thir/cx/block.rs @@ -51,7 +51,7 @@ impl<'tcx> Cx<'tcx> { let hir_id = stmt.hir_id; let opt_dxn_ext = self.region_scope_tree.opt_destruction_scope(hir_id.local_id); match stmt.kind { - hir::StmtKind::Expr(ref expr) | hir::StmtKind::Semi(ref expr) => { + hir::StmtKind::Expr(expr) | hir::StmtKind::Semi(expr) => { let stmt = Stmt { kind: StmtKind::Expr { scope: region::Scope { @@ -68,7 +68,7 @@ impl<'tcx> Cx<'tcx> { // ignore for purposes of the MIR None } - hir::StmtKind::Local(ref local) => { + hir::StmtKind::Local(local) => { let remainder_scope = region::Scope { id: block_id, data: region::ScopeData::Remainder(region::FirstStatementIndex::new( diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index 50f57b28a98..6541b4f6a3e 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -261,7 +261,7 @@ impl<'tcx> Cx<'tcx> { let kind = match expr.kind { // Here comes the interesting stuff: - hir::ExprKind::MethodCall(segment, receiver, ref args, fn_span) => { + hir::ExprKind::MethodCall(segment, receiver, args, fn_span) => { // Rewrite a.b(c) into UFCS form like Trait::b(a, c) let expr = self.method_callee(expr, segment.ident.span, None); info!("Using method span: {:?}", expr.span); @@ -278,7 +278,7 @@ impl<'tcx> Cx<'tcx> { } } - hir::ExprKind::Call(ref fun, ref args) => { + hir::ExprKind::Call(fun, ref args) => { if self.typeck_results().is_method_call(expr) { // The callee is something implementing Fn, FnMut, or FnOnce. // Find the actual method implementation being called and @@ -346,7 +346,7 @@ impl<'tcx> Cx<'tcx> { && let Some(adt_def) = expr_ty.ty_adt_def() { match qpath { - hir::QPath::Resolved(_, ref path) => match path.res { + hir::QPath::Resolved(_, path) => match path.res { Res::Def(DefKind::Ctor(_, CtorKind::Fn), ctor_id) => { Some((adt_def, adt_def.variant_index_with_ctor_id(ctor_id))) } @@ -407,21 +407,21 @@ impl<'tcx> Cx<'tcx> { } } - hir::ExprKind::AddrOf(hir::BorrowKind::Ref, mutbl, ref arg) => { + hir::ExprKind::AddrOf(hir::BorrowKind::Ref, mutbl, arg) => { ExprKind::Borrow { borrow_kind: mutbl.to_borrow_kind(), arg: self.mirror_expr(arg) } } - hir::ExprKind::AddrOf(hir::BorrowKind::Raw, mutability, ref arg) => { + hir::ExprKind::AddrOf(hir::BorrowKind::Raw, mutability, arg) => { ExprKind::AddressOf { mutability, arg: self.mirror_expr(arg) } } - hir::ExprKind::Block(ref blk, _) => ExprKind::Block { block: self.mirror_block(blk) }, + hir::ExprKind::Block(blk, _) => ExprKind::Block { block: self.mirror_block(blk) }, - hir::ExprKind::Assign(ref lhs, ref rhs, _) => { + hir::ExprKind::Assign(lhs, rhs, _) => { ExprKind::Assign { lhs: self.mirror_expr(lhs), rhs: self.mirror_expr(rhs) } } - hir::ExprKind::AssignOp(op, ref lhs, ref rhs) => { + hir::ExprKind::AssignOp(op, lhs, rhs) => { if self.typeck_results().is_method_call(expr) { let lhs = self.mirror_expr(lhs); let rhs = self.mirror_expr(rhs); @@ -435,9 +435,9 @@ impl<'tcx> Cx<'tcx> { } } - hir::ExprKind::Lit(ref lit) => ExprKind::Literal { lit, neg: false }, + hir::ExprKind::Lit(lit) => ExprKind::Literal { lit, neg: false }, - hir::ExprKind::Binary(op, ref lhs, ref rhs) => { + hir::ExprKind::Binary(op, lhs, rhs) => { if self.typeck_results().is_method_call(expr) { let lhs = self.mirror_expr(lhs); let rhs = self.mirror_expr(rhs); @@ -466,7 +466,7 @@ impl<'tcx> Cx<'tcx> { } } - hir::ExprKind::Index(ref lhs, ref index, brackets_span) => { + hir::ExprKind::Index(lhs, index, brackets_span) => { if self.typeck_results().is_method_call(expr) { let lhs = self.mirror_expr(lhs); let index = self.mirror_expr(index); @@ -482,7 +482,7 @@ impl<'tcx> Cx<'tcx> { } } - hir::ExprKind::Unary(hir::UnOp::Deref, ref arg) => { + hir::ExprKind::Unary(hir::UnOp::Deref, arg) => { if self.typeck_results().is_method_call(expr) { let arg = self.mirror_expr(arg); self.overloaded_place(expr, expr_ty, None, Box::new([arg]), expr.span) @@ -491,7 +491,7 @@ impl<'tcx> Cx<'tcx> { } } - hir::ExprKind::Unary(hir::UnOp::Not, ref arg) => { + hir::ExprKind::Unary(hir::UnOp::Not, arg) => { if self.typeck_results().is_method_call(expr) { let arg = self.mirror_expr(arg); self.overloaded_operator(expr, Box::new([arg])) @@ -500,18 +500,18 @@ impl<'tcx> Cx<'tcx> { } } - hir::ExprKind::Unary(hir::UnOp::Neg, ref arg) => { + hir::ExprKind::Unary(hir::UnOp::Neg, arg) => { if self.typeck_results().is_method_call(expr) { let arg = self.mirror_expr(arg); self.overloaded_operator(expr, Box::new([arg])) - } else if let hir::ExprKind::Lit(ref lit) = arg.kind { + } else if let hir::ExprKind::Lit(lit) = arg.kind { ExprKind::Literal { lit, neg: true } } else { ExprKind::Unary { op: UnOp::Neg, arg: self.mirror_expr(arg) } } } - hir::ExprKind::Struct(ref qpath, ref fields, ref base) => match expr_ty.kind() { + hir::ExprKind::Struct(qpath, fields, ref base) => match expr_ty.kind() { ty::Adt(adt, args) => match adt.adt_kind() { AdtKind::Struct | AdtKind::Union => { let user_provided_types = self.typeck_results().user_provided_types(); @@ -614,13 +614,13 @@ impl<'tcx> Cx<'tcx> { self.convert_path_expr(expr, res) } - hir::ExprKind::InlineAsm(ref asm) => ExprKind::InlineAsm(Box::new(InlineAsmExpr { + hir::ExprKind::InlineAsm(asm) => ExprKind::InlineAsm(Box::new(InlineAsmExpr { template: asm.template, operands: asm .operands .iter() .map(|(op, _op_sp)| match *op { - hir::InlineAsmOperand::In { reg, ref expr } => { + hir::InlineAsmOperand::In { reg, expr } => { InlineAsmOperand::In { reg, expr: self.mirror_expr(expr) } } hir::InlineAsmOperand::Out { reg, late, ref expr } => { @@ -630,20 +630,17 @@ impl<'tcx> Cx<'tcx> { expr: expr.map(|expr| self.mirror_expr(expr)), } } - hir::InlineAsmOperand::InOut { reg, late, ref expr } => { + hir::InlineAsmOperand::InOut { reg, late, expr } => { InlineAsmOperand::InOut { reg, late, expr: self.mirror_expr(expr) } } - hir::InlineAsmOperand::SplitInOut { - reg, - late, - ref in_expr, - ref out_expr, - } => InlineAsmOperand::SplitInOut { - reg, - late, - in_expr: self.mirror_expr(in_expr), - out_expr: out_expr.map(|expr| self.mirror_expr(expr)), - }, + hir::InlineAsmOperand::SplitInOut { reg, late, in_expr, ref out_expr } => { + InlineAsmOperand::SplitInOut { + reg, + late, + in_expr: self.mirror_expr(in_expr), + out_expr: out_expr.map(|expr| self.mirror_expr(expr)), + } + } hir::InlineAsmOperand::Const { ref anon_const } => { let value = mir::Const::from_anon_const(tcx, anon_const.def_id, self.param_env); @@ -686,7 +683,7 @@ impl<'tcx> Cx<'tcx> { ExprKind::ConstBlock { did, args } } // Now comes the rote stuff: - hir::ExprKind::Repeat(ref v, _) => { + hir::ExprKind::Repeat(v, _) => { let ty = self.typeck_results().expr_ty(expr); let ty::Array(_, count) = ty.kind() else { span_bug!(expr.span, "unexpected repeat expr ty: {:?}", ty); @@ -722,12 +719,12 @@ impl<'tcx> Cx<'tcx> { then: self.mirror_expr(then), else_opt: else_opt.map(|el| self.mirror_expr(el)), }, - hir::ExprKind::Match(ref discr, ref arms, _) => ExprKind::Match { + hir::ExprKind::Match(discr, arms, _) => ExprKind::Match { scrutinee: self.mirror_expr(discr), scrutinee_hir_id: discr.hir_id, arms: arms.iter().map(|a| self.convert_arm(a)).collect(), }, - hir::ExprKind::Loop(ref body, ..) => { + hir::ExprKind::Loop(body, ..) => { let block_ty = self.typeck_results().node_type(body.hir_id); let temp_lifetime = self .rvalue_scopes @@ -741,12 +738,12 @@ impl<'tcx> Cx<'tcx> { }); ExprKind::Loop { body } } - hir::ExprKind::Field(ref source, ..) => ExprKind::Field { + hir::ExprKind::Field(source, ..) => ExprKind::Field { lhs: self.mirror_expr(source), variant_index: FIRST_VARIANT, name: self.typeck_results.field_index(expr.hir_id), }, - hir::ExprKind::Cast(ref source, ref cast_ty) => { + hir::ExprKind::Cast(source, cast_ty) => { // Check for a user-given type annotation on this `cast` let user_provided_types = self.typeck_results.user_provided_types(); let user_ty = user_provided_types.get(cast_ty.hir_id); @@ -756,7 +753,7 @@ impl<'tcx> Cx<'tcx> { expr, cast_ty.hir_id, user_ty, ); - let cast = self.mirror_expr_cast(*source, temp_lifetime, expr.span); + let cast = self.mirror_expr_cast(source, temp_lifetime, expr.span); if let Some(user_ty) = user_ty { // NOTE: Creating a new Expr and wrapping a Cast inside of it may be @@ -777,7 +774,7 @@ impl<'tcx> Cx<'tcx> { cast } } - hir::ExprKind::Type(ref source, ref ty) => { + hir::ExprKind::Type(source, ty) => { let user_provided_types = self.typeck_results.user_provided_types(); let user_ty = user_provided_types.get(ty.hir_id).copied().map(Box::new); debug!("make_mirror_unadjusted: (type) user_ty={:?}", user_ty); @@ -788,15 +785,11 @@ impl<'tcx> Cx<'tcx> { ExprKind::ValueTypeAscription { source: mirrored, user_ty } } } - hir::ExprKind::DropTemps(ref source) => { - ExprKind::Use { source: self.mirror_expr(source) } - } - hir::ExprKind::Array(ref fields) => { - ExprKind::Array { fields: self.mirror_exprs(fields) } - } - hir::ExprKind::Tup(ref fields) => ExprKind::Tuple { fields: self.mirror_exprs(fields) }, + hir::ExprKind::DropTemps(source) => ExprKind::Use { source: self.mirror_expr(source) }, + hir::ExprKind::Array(fields) => ExprKind::Array { fields: self.mirror_exprs(fields) }, + hir::ExprKind::Tup(fields) => ExprKind::Tuple { fields: self.mirror_exprs(fields) }, - hir::ExprKind::Yield(ref v, _) => ExprKind::Yield { value: self.mirror_expr(v) }, + hir::ExprKind::Yield(v, _) => ExprKind::Yield { value: self.mirror_expr(v) }, hir::ExprKind::Err(_) => unreachable!(), }; @@ -870,10 +863,10 @@ impl<'tcx> Cx<'tcx> { fn convert_arm(&mut self, arm: &'tcx hir::Arm<'tcx>) -> ArmId { let arm = Arm { - pattern: self.pattern_from_hir(&arm.pat), + pattern: self.pattern_from_hir(arm.pat), guard: arm.guard.as_ref().map(|g| match g { - hir::Guard::If(ref e) => Guard::If(self.mirror_expr(e)), - hir::Guard::IfLet(ref l) => { + hir::Guard::If(e) => Guard::If(self.mirror_expr(e)), + hir::Guard::IfLet(l) => { Guard::IfLet(self.pattern_from_hir(l.pat), self.mirror_expr(l.init)) } }), diff --git a/compiler/rustc_mir_build/src/thir/cx/mod.rs b/compiler/rustc_mir_build/src/thir/cx/mod.rs index 261bd30b94a..0427f66db28 100644 --- a/compiler/rustc_mir_build/src/thir/cx/mod.rs +++ b/compiler/rustc_mir_build/src/thir/cx/mod.rs @@ -27,10 +27,10 @@ pub(crate) fn thir_body( if let Some(reported) = cx.typeck_results.tainted_by_errors { return Err(reported); } - let expr = cx.mirror_expr(&body.value); + let expr = cx.mirror_expr(body.value); let owner_id = hir.local_def_id_to_hir_id(owner_def); - if let Some(ref fn_decl) = hir.fn_decl_by_hir_id(owner_id) { + if let Some(fn_decl) = hir.fn_decl_by_hir_id(owner_id) { let closure_env_param = cx.closure_env_param(owner_def, owner_id); let explicit_params = cx.explicit_params(owner_id, fn_decl, body); cx.thir.params = closure_env_param.into_iter().chain(explicit_params).collect(); diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index 8c3d09c19a1..4cc3bbfcf43 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -298,7 +298,7 @@ impl<'thir, 'p, 'tcx> MatchVisitor<'thir, 'p, 'tcx> { tcx: self.tcx, param_env: self.param_env, module: self.tcx.parent_module(self.lint_level).to_def_id(), - pattern_arena: &self.pattern_arena, + pattern_arena: self.pattern_arena, match_span, refutable, } diff --git a/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs index 0c7c2c6f9b4..479f6c0a3ca 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs @@ -74,7 +74,7 @@ fn expand_or_pat<'p, 'tcx>(pat: &'p Pat<'tcx>) -> Vec<&'p Pat<'tcx>> { fn expand<'p, 'tcx>(pat: &'p Pat<'tcx>, vec: &mut Vec<&'p Pat<'tcx>>) { if let PatKind::Or { pats } = &pat.kind { for pat in pats.iter() { - expand(&pat, vec); + expand(pat, vec); } } else { vec.push(pat) @@ -1099,7 +1099,7 @@ impl ConstructorSet { for variant in visible_variants { let ctor = Variant(*variant); - if seen_set.contains(&variant) { + if seen_set.contains(variant) { present.push(ctor); } else { missing.push(ctor); @@ -1108,7 +1108,7 @@ impl ConstructorSet { for variant in hidden_variants { let ctor = Variant(*variant); - if seen_set.contains(&variant) { + if seen_set.contains(variant) { present.push(ctor); } else { skipped_a_hidden_variant = true; diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs index 0811ab6a0a6..d80497fd45f 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs @@ -266,16 +266,16 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { return self.lower_path(qpath, pat.hir_id, pat.span); } - hir::PatKind::Ref(ref subpattern, _) | hir::PatKind::Box(ref subpattern) => { + hir::PatKind::Ref(subpattern, _) | hir::PatKind::Box(subpattern) => { PatKind::Deref { subpattern: self.lower_pattern(subpattern) } } - hir::PatKind::Slice(ref prefix, ref slice, ref suffix) => { + hir::PatKind::Slice(prefix, ref slice, suffix) => { self.slice_or_array_pattern(pat.span, ty, prefix, slice, suffix) } - hir::PatKind::Tuple(ref pats, ddpos) => { - let ty::Tuple(ref tys) = ty.kind() else { + hir::PatKind::Tuple(pats, ddpos) => { + let ty::Tuple(tys) = ty.kind() else { span_bug!(pat.span, "unexpected type for tuple pattern: {:?}", ty); }; let subpatterns = self.lower_tuple_subpats(pats, tys.len(), ddpos); @@ -325,7 +325,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { } } - hir::PatKind::TupleStruct(ref qpath, ref pats, ddpos) => { + hir::PatKind::TupleStruct(ref qpath, pats, ddpos) => { let res = self.typeck_results.qpath_res(qpath, pat.hir_id); let ty::Adt(adt_def, _) = ty.kind() else { span_bug!(pat.span, "tuple struct pattern not applied to an ADT {:?}", ty); @@ -335,20 +335,20 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { self.lower_variant_or_leaf(res, pat.hir_id, pat.span, ty, subpatterns) } - hir::PatKind::Struct(ref qpath, ref fields, _) => { + hir::PatKind::Struct(ref qpath, fields, _) => { let res = self.typeck_results.qpath_res(qpath, pat.hir_id); let subpatterns = fields .iter() .map(|field| FieldPat { field: self.typeck_results.field_index(field.hir_id), - pattern: self.lower_pattern(&field.pat), + pattern: self.lower_pattern(field.pat), }) .collect(); self.lower_variant_or_leaf(res, pat.hir_id, pat.span, ty, subpatterns) } - hir::PatKind::Or(ref pats) => PatKind::Or { pats: self.lower_patterns(pats) }, + hir::PatKind::Or(pats) => PatKind::Or { pats: self.lower_patterns(pats) }, }; Box::new(Pat { span, ty, kind }) diff --git a/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs b/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs index da7b6587a72..461c44a169c 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs @@ -648,7 +648,7 @@ impl<'tcx> Usefulness<'tcx> { } else { witnesses .into_iter() - .map(|witness| witness.apply_constructor(pcx, &ctor)) + .map(|witness| witness.apply_constructor(pcx, ctor)) .collect() }; WithWitnesses(new_witnesses) @@ -934,7 +934,7 @@ impl<'p, 'tcx> PatternColumn<'p, 'tcx> { let relevant_patterns = self.patterns.iter().filter(|pat| ctor.is_covered_by(pcx, pat.ctor())); for pat in relevant_patterns { - let specialized = pat.specialize(pcx, &ctor); + let specialized = pat.specialize(pcx, ctor); for (subpat, column) in specialized.iter().zip(&mut specialized_columns) { if subpat.is_or_pat() { column.patterns.extend(subpat.flatten_or_pat()) diff --git a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs index 25ba67a63ec..958fa0d17cd 100644 --- a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs +++ b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs @@ -481,12 +481,8 @@ where ) -> (BasicBlock, Unwind) { let (succ, unwind) = self.drop_ladder_bottom(); if !adt.is_enum() { - let fields = self.move_paths_for_fields( - self.place, - self.path, - &adt.variant(FIRST_VARIANT), - args, - ); + let fields = + self.move_paths_for_fields(self.place, self.path, adt.variant(FIRST_VARIANT), args); self.drop_ladder(fields, succ, unwind) } else { self.open_drop_for_multivariant(adt, args, succ, unwind) @@ -518,7 +514,7 @@ where self.place, ProjectionElem::Downcast(Some(variant.name), variant_index), ); - let fields = self.move_paths_for_fields(base_place, variant_path, &variant, args); + let fields = self.move_paths_for_fields(base_place, variant_path, variant, args); values.push(discr.val); if let Unwind::To(unwind) = unwind { // We can't use the half-ladder from the original @@ -859,14 +855,14 @@ where fn open_drop(&mut self) -> BasicBlock { let ty = self.place_ty(self.place); match ty.kind() { - ty::Closure(_, args) => self.open_drop_for_tuple(&args.as_closure().upvar_tys()), + ty::Closure(_, args) => self.open_drop_for_tuple(args.as_closure().upvar_tys()), // Note that `elaborate_drops` only drops the upvars of a coroutine, // and this is ok because `open_drop` here can only be reached // within that own coroutine's resume function. // This should only happen for the self argument on the resume function. // It effectively only contains upvars until the coroutine transformation runs. // See librustc_body/transform/coroutine.rs for more details. - ty::Coroutine(_, args, _) => self.open_drop_for_tuple(&args.as_coroutine().upvar_tys()), + ty::Coroutine(_, args, _) => self.open_drop_for_tuple(args.as_coroutine().upvar_tys()), ty::Tuple(fields) => self.open_drop_for_tuple(fields), ty::Adt(def, args) => self.open_drop_for_adt(*def, args), ty::Dynamic(..) => self.complete_drop(self.succ, self.unwind), diff --git a/compiler/rustc_mir_dataflow/src/framework/direction.rs b/compiler/rustc_mir_dataflow/src/framework/direction.rs index 70451edd500..04c9f7a016c 100644 --- a/compiler/rustc_mir_dataflow/src/framework/direction.rs +++ b/compiler/rustc_mir_dataflow/src/framework/direction.rs @@ -196,7 +196,7 @@ impl Direction for Backward { { results.reset_to_block_entry(state, block); - vis.visit_block_end(results, &state, block_data, block); + vis.visit_block_end(results, state, block_data, block); // Terminator let loc = Location { block, statement_index: block_data.statements.len() }; diff --git a/compiler/rustc_mir_dataflow/src/framework/engine.rs b/compiler/rustc_mir_dataflow/src/framework/engine.rs index a29962d7717..204e854235f 100644 --- a/compiler/rustc_mir_dataflow/src/framework/engine.rs +++ b/compiler/rustc_mir_dataflow/src/framework/engine.rs @@ -295,7 +295,7 @@ where let mut results = Results { analysis, entry_sets, _marker: PhantomData }; if tcx.sess.opts.unstable_opts.dump_mir_dataflow { - let res = write_graphviz_results(tcx, &body, &mut results, pass_name); + let res = write_graphviz_results(tcx, body, &mut results, pass_name); if let Err(e) = res { error!("Failed to write graphviz dataflow results: {}", e); } diff --git a/compiler/rustc_mir_dataflow/src/framework/lattice.rs b/compiler/rustc_mir_dataflow/src/framework/lattice.rs index 3b89598d289..1c2b475a43c 100644 --- a/compiler/rustc_mir_dataflow/src/framework/lattice.rs +++ b/compiler/rustc_mir_dataflow/src/framework/lattice.rs @@ -342,7 +342,7 @@ impl Clone for MaybeReachable { fn clone_from(&mut self, source: &Self) { match (&mut *self, source) { (MaybeReachable::Reachable(x), MaybeReachable::Reachable(y)) => { - x.clone_from(&y); + x.clone_from(y); } _ => *self = source.clone(), } diff --git a/compiler/rustc_mir_dataflow/src/impls/initialized.rs b/compiler/rustc_mir_dataflow/src/impls/initialized.rs index c968e7aea8f..61be100d70e 100644 --- a/compiler/rustc_mir_dataflow/src/impls/initialized.rs +++ b/compiler/rustc_mir_dataflow/src/impls/initialized.rs @@ -409,7 +409,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> { } let enum_ = discr.place().and_then(|discr| { - switch_on_enum_discriminant(self.tcx, &self.body, &self.body[block], discr) + switch_on_enum_discriminant(self.tcx, self.body, &self.body[block], discr) }); let Some((enum_place, enum_def)) = enum_ else { @@ -540,7 +540,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> { } let enum_ = discr.place().and_then(|discr| { - switch_on_enum_discriminant(self.tcx, &self.body, &self.body[block], discr) + switch_on_enum_discriminant(self.tcx, self.body, &self.body[block], discr) }); let Some((enum_place, enum_def)) = enum_ else { diff --git a/compiler/rustc_mir_dataflow/src/rustc_peek.rs b/compiler/rustc_mir_dataflow/src/rustc_peek.rs index d3dce641ba1..f9468c8e8cc 100644 --- a/compiler/rustc_mir_dataflow/src/rustc_peek.rs +++ b/compiler/rustc_mir_dataflow/src/rustc_peek.rs @@ -34,7 +34,7 @@ impl<'tcx> MirPass<'tcx> for SanityCheck { } let param_env = tcx.param_env(def_id); - let move_data = MoveData::gather_moves(&body, tcx, param_env, |_| true); + let move_data = MoveData::gather_moves(body, tcx, param_env, |_| true); let mdpe = MoveDataParamEnv { move_data, param_env }; if has_rustc_mir_with(tcx, def_id, sym::rustc_peek_maybe_init).is_some() { diff --git a/compiler/rustc_mir_transform/src/check_const_item_mutation.rs b/compiler/rustc_mir_transform/src/check_const_item_mutation.rs index 61bf530f11c..3195cd3622d 100644 --- a/compiler/rustc_mir_transform/src/check_const_item_mutation.rs +++ b/compiler/rustc_mir_transform/src/check_const_item_mutation.rs @@ -13,7 +13,7 @@ pub struct CheckConstItemMutation; impl<'tcx> MirLint<'tcx> for CheckConstItemMutation { fn run_lint(&self, tcx: TyCtxt<'tcx>, body: &Body<'tcx>) { let mut checker = ConstMutationChecker { body, tcx, target_local: None }; - checker.visit_body(&body); + checker.visit_body(body); } } @@ -98,7 +98,7 @@ impl<'tcx> Visitor<'tcx> for ConstMutationChecker<'_, 'tcx> { if !lhs.projection.is_empty() { if let Some(def_id) = self.is_const_item_without_destructor(lhs.local) && let Some((lint_root, span, item)) = - self.should_lint_const_item_usage(&lhs, def_id, loc) + self.should_lint_const_item_usage(lhs, def_id, loc) { self.tcx.emit_spanned_lint( CONST_ITEM_MUTATION, @@ -132,12 +132,7 @@ impl<'tcx> Visitor<'tcx> for ConstMutationChecker<'_, 'tcx> { // the `self` parameter of a method call (as the terminator of our current // BasicBlock). If so, we emit a more specific lint. let method_did = self.target_local.and_then(|target_local| { - rustc_middle::util::find_self_call( - self.tcx, - &self.body, - target_local, - loc.block, - ) + rustc_middle::util::find_self_call(self.tcx, self.body, target_local, loc.block) }); let lint_loc = if method_did.is_some() { self.body.terminator_loc(loc.block) } else { loc }; diff --git a/compiler/rustc_mir_transform/src/check_packed_ref.rs b/compiler/rustc_mir_transform/src/check_packed_ref.rs index 9ee0a704071..77bcba50a3c 100644 --- a/compiler/rustc_mir_transform/src/check_packed_ref.rs +++ b/compiler/rustc_mir_transform/src/check_packed_ref.rs @@ -12,7 +12,7 @@ impl<'tcx> MirLint<'tcx> for CheckPackedRef { let param_env = tcx.param_env(body.source.def_id()); let source_info = SourceInfo::outermost(body.span); let mut checker = PackedRefChecker { body, tcx, param_env, source_info }; - checker.visit_body(&body); + checker.visit_body(body); } } diff --git a/compiler/rustc_mir_transform/src/check_unsafety.rs b/compiler/rustc_mir_transform/src/check_unsafety.rs index 8872f9a97d7..cfcd5acb9e9 100644 --- a/compiler/rustc_mir_transform/src/check_unsafety.rs +++ b/compiler/rustc_mir_transform/src/check_unsafety.rs @@ -494,7 +494,7 @@ fn unsafety_check_result(tcx: TyCtxt<'_>, def: LocalDefId) -> &UnsafetyCheckResu let param_env = tcx.param_env(def); let mut checker = UnsafetyChecker::new(body, def, tcx, param_env); - checker.visit_body(&body); + checker.visit_body(body); let unused_unsafes = (!tcx.is_typeck_child(def.to_def_id())) .then(|| check_unused_unsafe(tcx, def, &checker.used_unsafe_blocks)); diff --git a/compiler/rustc_mir_transform/src/const_prop.rs b/compiler/rustc_mir_transform/src/const_prop.rs index 0adbb078105..42d33f4f517 100644 --- a/compiler/rustc_mir_transform/src/const_prop.rs +++ b/compiler/rustc_mir_transform/src/const_prop.rs @@ -606,7 +606,7 @@ impl CanConstProp { for arg in body.args_iter() { cpv.found_assignment.insert(arg); } - cpv.visit_body(&body); + cpv.visit_body(body); cpv.can_const_prop } } diff --git a/compiler/rustc_mir_transform/src/const_prop_lint.rs b/compiler/rustc_mir_transform/src/const_prop_lint.rs index a23ba9c4aa9..da315bb86ac 100644 --- a/compiler/rustc_mir_transform/src/const_prop_lint.rs +++ b/compiler/rustc_mir_transform/src/const_prop_lint.rs @@ -453,7 +453,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { cond: &Operand<'tcx>, location: Location, ) -> Option { - let value = &self.eval_operand(&cond, location)?; + let value = &self.eval_operand(cond, location)?; trace!("assertion on {:?} should be {:?}", value, expected); let expected = Scalar::from_bool(expected); @@ -626,7 +626,7 @@ impl<'tcx> Visitor<'tcx> for ConstPropagator<'_, 'tcx> { self.check_assertion(*expected, msg, cond, location); } TerminatorKind::SwitchInt { ref discr, ref targets } => { - if let Some(ref value) = self.eval_operand(&discr, location) + if let Some(ref value) = self.eval_operand(discr, location) && let Some(value_const) = self.use_ecx(location, |this| this.ecx.read_scalar(value)) && let Ok(constant) = value_const.try_to_int() diff --git a/compiler/rustc_mir_transform/src/copy_prop.rs b/compiler/rustc_mir_transform/src/copy_prop.rs index f5db7ce97eb..74009496e75 100644 --- a/compiler/rustc_mir_transform/src/copy_prop.rs +++ b/compiler/rustc_mir_transform/src/copy_prop.rs @@ -50,7 +50,7 @@ fn propagate_ssa<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { Replacer { tcx, - copy_classes: &ssa.copy_classes(), + copy_classes: ssa.copy_classes(), fully_moved, borrowed_locals, storage_to_remove, @@ -124,7 +124,7 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> { } fn visit_place(&mut self, place: &mut Place<'tcx>, ctxt: PlaceContext, loc: Location) { - if let Some(new_projection) = self.process_projection(&place.projection, loc) { + if let Some(new_projection) = self.process_projection(place.projection, loc) { place.projection = self.tcx().mk_place_elems(&new_projection); } diff --git a/compiler/rustc_mir_transform/src/coroutine.rs b/compiler/rustc_mir_transform/src/coroutine.rs index dfafd859830..aa4d8ddad56 100644 --- a/compiler/rustc_mir_transform/src/coroutine.rs +++ b/compiler/rustc_mir_transform/src/coroutine.rs @@ -651,7 +651,7 @@ fn locals_live_across_suspend_points<'tcx>( always_live_locals: &BitSet, movable: bool, ) -> LivenessInfo { - let body_ref: &Body<'_> = &body; + let body_ref: &Body<'_> = body; // Calculate when MIR locals have live storage. This gives us an upper bound of their // lifetimes. @@ -742,7 +742,7 @@ fn locals_live_across_suspend_points<'tcx>( // saving. let live_locals_at_suspension_points = live_locals_at_suspension_points .iter() - .map(|live_here| saved_locals.renumber_bitset(&live_here)) + .map(|live_here| saved_locals.renumber_bitset(live_here)) .collect(); let storage_conflicts = compute_storage_conflicts( @@ -778,7 +778,7 @@ impl CoroutineSavedLocals { /// Transforms a `BitSet` that contains only locals saved across yield points to the /// equivalent `BitSet`. fn renumber_bitset(&self, input: &BitSet) -> BitSet { - assert!(self.superset(&input), "{:?} not a superset of {:?}", self.0, input); + assert!(self.superset(input), "{:?} not a superset of {:?}", self.0, input); let mut out = BitSet::new_empty(self.count()); for (saved_local, local) in self.iter_enumerated() { if input.contains(local) { @@ -829,7 +829,7 @@ fn compute_storage_conflicts<'mir, 'tcx>( // Compute the storage conflicts for all eligible locals. let mut visitor = StorageConflictVisitor { body, - saved_locals: &saved_locals, + saved_locals: saved_locals, local_conflicts: BitMatrix::from_row_n(&ineligible_locals, body.local_decls.len()), }; @@ -1128,7 +1128,7 @@ fn create_coroutine_drop_shim<'tcx>( // The returned state and the poisoned state fall through to the default // case which is just to return - insert_switch(&mut body, cases, &transform, TerminatorKind::Return); + insert_switch(&mut body, cases, transform, TerminatorKind::Return); for block in body.basic_blocks_mut() { let kind = &mut block.terminator_mut().kind; @@ -1465,7 +1465,7 @@ pub(crate) fn mir_coroutine_witnesses<'tcx>( // The witness simply contains all locals live across suspend points. - let always_live_locals = always_storage_live_locals(&body); + let always_live_locals = always_storage_live_locals(body); let liveness_info = locals_live_across_suspend_points(tcx, body, &always_live_locals, movable); // Extract locals which are live across suspension point into `layout` @@ -1473,7 +1473,7 @@ pub(crate) fn mir_coroutine_witnesses<'tcx>( // `storage_liveness` tells us which locals have live storage at suspension points let (_, coroutine_layout, _) = compute_layout(liveness_info, body); - check_suspend_tys(tcx, &coroutine_layout, &body); + check_suspend_tys(tcx, &coroutine_layout, body); Some(coroutine_layout) } @@ -1564,7 +1564,7 @@ impl<'tcx> MirPass<'tcx> for StateTransform { }, ); - let always_live_locals = always_storage_live_locals(&body); + let always_live_locals = always_storage_live_locals(body); let liveness_info = locals_live_across_suspend_points(tcx, body, &always_live_locals, movable); diff --git a/compiler/rustc_mir_transform/src/coverage/counters.rs b/compiler/rustc_mir_transform/src/coverage/counters.rs index 1bc3c25c653..1e11d8d09b6 100644 --- a/compiler/rustc_mir_transform/src/coverage/counters.rs +++ b/compiler/rustc_mir_transform/src/coverage/counters.rs @@ -222,7 +222,7 @@ impl<'a> MakeBcbCounters<'a> { // all `BasicCoverageBlock` nodes in the loop are visited before visiting any node outside // the loop. The `traversal` state includes a `context_stack`, providing a way to know if // the current BCB is in one or more nested loops or not. - let mut traversal = TraverseCoverageGraphWithLoops::new(&self.basic_coverage_blocks); + let mut traversal = TraverseCoverageGraphWithLoops::new(self.basic_coverage_blocks); while let Some(bcb) = traversal.next() { if bcb_has_coverage_spans(bcb) { debug!("{:?} has at least one coverage span. Get or make its counter", bcb); @@ -425,7 +425,7 @@ impl<'a> MakeBcbCounters<'a> { traversal: &TraverseCoverageGraphWithLoops<'_>, branches: &[BcbBranch], ) -> BcbBranch { - let good_reloop_branch = self.find_good_reloop_branch(traversal, &branches); + let good_reloop_branch = self.find_good_reloop_branch(traversal, branches); if let Some(reloop_branch) = good_reloop_branch { assert!(self.branch_has_no_counter(&reloop_branch)); debug!("Selecting reloop branch {reloop_branch:?} to get an expression"); @@ -508,7 +508,7 @@ impl<'a> MakeBcbCounters<'a> { fn bcb_branches(&self, from_bcb: BasicCoverageBlock) -> Vec { self.bcb_successors(from_bcb) .iter() - .map(|&to_bcb| BcbBranch::from_to(from_bcb, to_bcb, &self.basic_coverage_blocks)) + .map(|&to_bcb| BcbBranch::from_to(from_bcb, to_bcb, self.basic_coverage_blocks)) .collect::>() } diff --git a/compiler/rustc_mir_transform/src/coverage/graph.rs b/compiler/rustc_mir_transform/src/coverage/graph.rs index 6bab62aa854..7defc9ec148 100644 --- a/compiler/rustc_mir_transform/src/coverage/graph.rs +++ b/compiler/rustc_mir_transform/src/coverage/graph.rs @@ -38,7 +38,7 @@ impl CoverageGraph { } let bcb_data = &bcbs[bcb]; let mut bcb_successors = Vec::new(); - for successor in bcb_filtered_successors(&mir_body, bcb_data.last_bb()) + for successor in bcb_filtered_successors(mir_body, bcb_data.last_bb()) .filter_map(|successor_bb| bb_to_bcb[successor_bb]) { if !seen[successor] { diff --git a/compiler/rustc_mir_transform/src/coverage/mod.rs b/compiler/rustc_mir_transform/src/coverage/mod.rs index 97e4468a0e8..796150f9315 100644 --- a/compiler/rustc_mir_transform/src/coverage/mod.rs +++ b/compiler/rustc_mir_transform/src/coverage/mod.rs @@ -142,7 +142,7 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> { //////////////////////////////////////////////////// // Compute coverage spans from the `CoverageGraph`. let coverage_spans = CoverageSpans::generate_coverage_spans( - &self.mir_body, + self.mir_body, fn_sig_span, body_span, &self.basic_coverage_blocks, @@ -240,7 +240,7 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> { ); // Inject a counter into the newly-created BB. - inject_statement(self.mir_body, self.make_mir_coverage_kind(&counter_kind), new_bb); + inject_statement(self.mir_body, self.make_mir_coverage_kind(counter_kind), new_bb); } mappings diff --git a/compiler/rustc_mir_transform/src/ctfe_limit.rs b/compiler/rustc_mir_transform/src/ctfe_limit.rs index bf5722b3d00..dcc960e1e02 100644 --- a/compiler/rustc_mir_transform/src/ctfe_limit.rs +++ b/compiler/rustc_mir_transform/src/ctfe_limit.rs @@ -20,7 +20,7 @@ impl<'tcx> MirPass<'tcx> for CtfeLimit { .filter_map(|(node, node_data)| { if matches!(node_data.terminator().kind, TerminatorKind::Call { .. }) // Back edges in a CFG indicate loops - || has_back_edge(&doms, node, &node_data) + || has_back_edge(doms, node, node_data) { Some(node) } else { diff --git a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs index bb2a90a06da..21b92e6d77c 100644 --- a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs +++ b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs @@ -362,7 +362,7 @@ impl<'a, 'tcx> ConstAnalysis<'a, 'tcx> { && let Ok(rhs_layout) = self.tcx.layout_of(self.param_env.and(rhs_ty)) { let op = ImmTy::from_scalar(pointer, rhs_layout).into(); - self.assign_constant(state, place, op, &rhs.projection); + self.assign_constant(state, place, op, rhs.projection); } } Operand::Constant(box constant) => { diff --git a/compiler/rustc_mir_transform/src/elaborate_drops.rs b/compiler/rustc_mir_transform/src/elaborate_drops.rs index 59156b2427c..d4e40a1b57c 100644 --- a/compiler/rustc_mir_transform/src/elaborate_drops.rs +++ b/compiler/rustc_mir_transform/src/elaborate_drops.rs @@ -57,7 +57,7 @@ impl<'tcx> MirPass<'tcx> for ElaborateDrops { // For types that do not need dropping, the behaviour is trivial. So we only need to track // init/uninit for types that do need dropping. let move_data = - MoveData::gather_moves(&body, tcx, param_env, |ty| ty.needs_drop(tcx, param_env)); + MoveData::gather_moves(body, tcx, param_env, |ty| ty.needs_drop(tcx, param_env)); let elaborate_patch = { let env = MoveDataParamEnv { move_data, param_env }; @@ -67,7 +67,7 @@ impl<'tcx> MirPass<'tcx> for ElaborateDrops { .pass_name("elaborate_drops") .iterate_to_fixpoint() .into_results_cursor(body); - let dead_unwinds = compute_dead_unwinds(&body, &mut inits); + let dead_unwinds = compute_dead_unwinds(body, &mut inits); let uninits = MaybeUninitializedPlaces::new(tcx, body, &env) .mark_inactive_variants_as_uninit() diff --git a/compiler/rustc_mir_transform/src/function_item_references.rs b/compiler/rustc_mir_transform/src/function_item_references.rs index a42eacbf22b..340bb1948eb 100644 --- a/compiler/rustc_mir_transform/src/function_item_references.rs +++ b/compiler/rustc_mir_transform/src/function_item_references.rs @@ -14,7 +14,7 @@ pub struct FunctionItemReferences; impl<'tcx> MirLint<'tcx> for FunctionItemReferences { fn run_lint(&self, tcx: TyCtxt<'tcx>, body: &Body<'tcx>) { let mut checker = FunctionItemRefChecker { tcx, body }; - checker.visit_body(&body); + checker.visit_body(body); } } @@ -47,12 +47,12 @@ impl<'tcx> Visitor<'tcx> for FunctionItemRefChecker<'_, 'tcx> { for inner_ty in arg_ty.walk().filter_map(|arg| arg.as_type()) { if let Some((fn_id, fn_args)) = FunctionItemRefChecker::is_fn_ref(inner_ty) { - let span = self.nth_arg_span(&args, 0); + let span = self.nth_arg_span(args, 0); self.emit_lint(fn_id, fn_args, source_info, span); } } } else { - self.check_bound_args(def_id, args_ref, &args, source_info); + self.check_bound_args(def_id, args_ref, args, source_info); } } } diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index 7b5697bc949..8fa26713184 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -280,7 +280,7 @@ impl<'tcx> Inliner<'tcx> { } let old_blocks = caller_body.basic_blocks.next_index(); - self.inline_call(caller_body, &callsite, callee_body); + self.inline_call(caller_body, callsite, callee_body); let new_blocks = old_blocks..caller_body.basic_blocks.next_index(); Ok(new_blocks) diff --git a/compiler/rustc_mir_transform/src/instsimplify.rs b/compiler/rustc_mir_transform/src/instsimplify.rs index fbcd6e75ad4..7a844b01707 100644 --- a/compiler/rustc_mir_transform/src/instsimplify.rs +++ b/compiler/rustc_mir_transform/src/instsimplify.rs @@ -35,12 +35,9 @@ impl<'tcx> MirPass<'tcx> for InstSimplify { } } - ctx.simplify_primitive_clone( - &mut block.terminator.as_mut().unwrap(), - &mut block.statements, - ); + ctx.simplify_primitive_clone(block.terminator.as_mut().unwrap(), &mut block.statements); ctx.simplify_intrinsic_assert( - &mut block.terminator.as_mut().unwrap(), + block.terminator.as_mut().unwrap(), &mut block.statements, ); simplify_duplicate_switch_targets(block.terminator.as_mut().unwrap()); diff --git a/compiler/rustc_mir_transform/src/jump_threading.rs b/compiler/rustc_mir_transform/src/jump_threading.rs index 22300ad24be..5754dd08164 100644 --- a/compiler/rustc_mir_transform/src/jump_threading.rs +++ b/compiler/rustc_mir_transform/src/jump_threading.rs @@ -95,7 +95,7 @@ impl<'tcx> MirPass<'tcx> for JumpThreading { let cost = CostChecker::new(tcx, param_env, None, body); - let mut state = State::new(ConditionSet::default(), &finder.map); + let mut state = State::new(ConditionSet::default(), finder.map); let conds = if let Some((value, then, else_)) = targets.as_static_if() { let Some(value) = ScalarInt::try_from_uint(value, discr_layout.size) else { @@ -112,7 +112,7 @@ impl<'tcx> MirPass<'tcx> for JumpThreading { })) }; let conds = ConditionSet(conds); - state.insert_value_idx(discr, conds, &finder.map); + state.insert_value_idx(discr, conds, finder.map); finder.find_opportunity(bb, state, cost, 0); } diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index bf5f0ca7cbd..a3a10b138c7 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -481,14 +481,14 @@ pub fn run_analysis_to_runtime_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<' assert!(body.phase == MirPhase::Analysis(AnalysisPhase::PostCleanup)); // Do a little drop elaboration before const-checking if `const_precise_live_drops` is enabled. - if check_consts::post_drop_elaboration::checking_enabled(&ConstCx::new(tcx, &body)) { + if check_consts::post_drop_elaboration::checking_enabled(&ConstCx::new(tcx, body)) { pm::run_passes( tcx, body, &[&remove_uninit_drops::RemoveUninitDrops, &simplify::SimplifyCfg::RemoveFalseEdges], None, ); - check_consts::post_drop_elaboration::check_live_drops(tcx, &body); // FIXME: make this a MIR lint + check_consts::post_drop_elaboration::check_live_drops(tcx, body); // FIXME: make this a MIR lint } debug!("runtime_mir_lowering({:?})", did); diff --git a/compiler/rustc_mir_transform/src/pass_manager.rs b/compiler/rustc_mir_transform/src/pass_manager.rs index a8aba29adcd..c4eca18ff27 100644 --- a/compiler/rustc_mir_transform/src/pass_manager.rs +++ b/compiler/rustc_mir_transform/src/pass_manager.rs @@ -99,7 +99,7 @@ where ); *polarity }); - overridden.unwrap_or_else(|| pass.is_enabled(&tcx.sess)) + overridden.unwrap_or_else(|| pass.is_enabled(tcx.sess)) } fn run_passes_inner<'tcx>( @@ -126,7 +126,7 @@ fn run_passes_inner<'tcx>( let dump_enabled = pass.is_mir_dump_enabled(); if dump_enabled { - dump_mir_for_pass(tcx, body, &name, false); + dump_mir_for_pass(tcx, body, name, false); } if validate { validate_body(tcx, body, format!("before pass {name}")); @@ -142,7 +142,7 @@ fn run_passes_inner<'tcx>( } if dump_enabled { - dump_mir_for_pass(tcx, body, &name, true); + dump_mir_for_pass(tcx, body, name, true); } if validate { validate_body(tcx, body, format!("after pass {name}")); diff --git a/compiler/rustc_mir_transform/src/remove_uninit_drops.rs b/compiler/rustc_mir_transform/src/remove_uninit_drops.rs index 87fee2410ec..548879e2e39 100644 --- a/compiler/rustc_mir_transform/src/remove_uninit_drops.rs +++ b/compiler/rustc_mir_transform/src/remove_uninit_drops.rs @@ -25,7 +25,7 @@ impl<'tcx> MirPass<'tcx> for RemoveUninitDrops { fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { let param_env = tcx.param_env(body.source.def_id()); let move_data = - MoveData::gather_moves(&body, tcx, param_env, |ty| ty.needs_drop(tcx, param_env)); + MoveData::gather_moves(body, tcx, param_env, |ty| ty.needs_drop(tcx, param_env)); let mdpe = MoveDataParamEnv { move_data, param_env }; let mut maybe_inits = MaybeInitializedPlaces::new(tcx, body, &mdpe) diff --git a/compiler/rustc_mir_transform/src/simplify.rs b/compiler/rustc_mir_transform/src/simplify.rs index 0a1c011147a..97d398fe5c9 100644 --- a/compiler/rustc_mir_transform/src/simplify.rs +++ b/compiler/rustc_mir_transform/src/simplify.rs @@ -74,7 +74,7 @@ pub fn simplify_cfg<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { impl<'tcx> MirPass<'tcx> for SimplifyCfg { fn name(&self) -> &'static str { - &self.name() + self.name() } fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { diff --git a/compiler/rustc_mir_transform/src/sroa.rs b/compiler/rustc_mir_transform/src/sroa.rs index 7de4ca66794..a4ca2b91e82 100644 --- a/compiler/rustc_mir_transform/src/sroa.rs +++ b/compiler/rustc_mir_transform/src/sroa.rs @@ -167,7 +167,7 @@ impl<'tcx> ReplacementMap<'tcx> { }; let fields = self.fragments[place.local].as_ref()?; let (_, new_local) = fields[f]?; - Some(Place { local: new_local, projection: tcx.mk_place_elems(&rest) }) + Some(Place { local: new_local, projection: tcx.mk_place_elems(rest) }) } fn place_fragments( diff --git a/compiler/rustc_mir_transform/src/uninhabited_enum_branching.rs b/compiler/rustc_mir_transform/src/uninhabited_enum_branching.rs index 98f67e18a8d..e68d37f4c70 100644 --- a/compiler/rustc_mir_transform/src/uninhabited_enum_branching.rs +++ b/compiler/rustc_mir_transform/src/uninhabited_enum_branching.rs @@ -86,7 +86,7 @@ impl<'tcx> MirPass<'tcx> for UninhabitedEnumBranching { continue; } - let Some(discriminant_ty) = get_switched_on_type(&bb_data, tcx, body) else { continue }; + let Some(discriminant_ty) = get_switched_on_type(bb_data, tcx, body) else { continue }; let layout = tcx.layout_of( tcx.param_env_reveal_all_normalized(body.source.def_id()).and(discriminant_ty), diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 65bdcf10762..b882a038711 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -740,7 +740,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> { ) => { let fn_ty = operand.ty(self.body, self.tcx); let fn_ty = self.monomorphize(fn_ty); - visit_fn_use(self.tcx, fn_ty, false, span, &mut self.output); + visit_fn_use(self.tcx, fn_ty, false, span, self.output); } mir::Rvalue::Cast( mir::CastKind::PointerCoercion(PointerCoercion::ClosureFnPointer(_)), @@ -816,7 +816,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> { let callee_ty = func.ty(self.body, tcx); let callee_ty = self.monomorphize(callee_ty); self.check_fn_args_move_size(callee_ty, args, location); - visit_fn_use(self.tcx, callee_ty, true, source, &mut self.output) + visit_fn_use(self.tcx, callee_ty, true, source, self.output) } mir::TerminatorKind::Drop { ref place, .. } => { let ty = place.ty(self.body, self.tcx).ty; @@ -828,7 +828,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> { match *op { mir::InlineAsmOperand::SymFn { ref value } => { let fn_ty = self.monomorphize(value.const_.ty()); - visit_fn_use(self.tcx, fn_ty, false, source, &mut self.output); + visit_fn_use(self.tcx, fn_ty, false, source, self.output); } mir::InlineAsmOperand::SymStatic { def_id } => { let instance = Instance::mono(self.tcx, def_id); @@ -1118,7 +1118,7 @@ fn create_mono_items_for_vtable_methods<'tcx>( ) { assert!(!trait_ty.has_escaping_bound_vars() && !impl_ty.has_escaping_bound_vars()); - if let ty::Dynamic(ref trait_ty, ..) = trait_ty.kind() { + if let ty::Dynamic(trait_ty, ..) = trait_ty.kind() { if let Some(principal) = trait_ty.principal() { let poly_trait_ref = principal.with_self_ty(tcx, impl_ty); assert!(!poly_trait_ref.has_escaping_bound_vars()); @@ -1191,7 +1191,7 @@ impl<'v> RootCollector<'_, 'v> { // but even just declaring them must collect the items they refer to if let Ok(val) = self.tcx.const_eval_poly(id.owner_id.to_def_id()) { - collect_const_value(self.tcx, val, &mut self.output); + collect_const_value(self.tcx, val, self.output); } } DefKind::Impl { .. } => { @@ -1422,14 +1422,14 @@ fn collect_used_items<'tcx>( // and abort compilation if any of them errors. MirUsedCollector { tcx, - body: &body, + body: body, output, instance, move_size_spans: vec![], visiting_call_terminator: false, skip_move_check_fns: None, } - .visit_body(&body); + .visit_body(body); } #[instrument(skip(tcx, output), level = "debug")] diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index 4009e289240..c2b307910e4 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -436,12 +436,12 @@ fn merge_codegen_units<'tcx>( for cgu in codegen_units.iter_mut() { if let Some(new_cgu_name) = new_cgu_names.get(&cgu.name()) { if cx.tcx.sess.opts.unstable_opts.human_readable_cgu_names { - cgu.set_name(Symbol::intern(&new_cgu_name)); + cgu.set_name(Symbol::intern(new_cgu_name)); } else { // If we don't require CGU names to be human-readable, // we use a fixed length hash of the composite CGU name // instead. - let new_cgu_name = CodegenUnit::mangle_name(&new_cgu_name); + let new_cgu_name = CodegenUnit::mangle_name(new_cgu_name); cgu.set_name(Symbol::intern(&new_cgu_name)); } } @@ -1140,7 +1140,7 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Co // Output monomorphization stats per def_id if let SwitchWithOptPath::Enabled(ref path) = tcx.sess.opts.unstable_opts.dump_mono_stats { if let Err(err) = - dump_mono_items_stats(tcx, &codegen_units, path, tcx.crate_name(LOCAL_CRATE)) + dump_mono_items_stats(tcx, codegen_units, path, tcx.crate_name(LOCAL_CRATE)) { tcx.sess.emit_fatal(CouldntDumpMonoStats { error: err.to_string() }); } diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index f2eed5c9be5..6e0765f74fe 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -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"), diff --git a/compiler/rustc_parse/src/lexer/tokentrees.rs b/compiler/rustc_parse/src/lexer/tokentrees.rs index db795ce9f72..e646f5dfd85 100644 --- a/compiler/rustc_parse/src/lexer/tokentrees.rs +++ b/compiler/rustc_parse/src/lexer/tokentrees.rs @@ -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"); diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 57bc865a0ee..ecb840f067e 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -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 { "" }, }); diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index d8e99d34016..79567eb3898 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -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 }) diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index d124ea571ab..23886b1208b 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -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. diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index 5cec3f5762d..15491cac56a 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -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) } diff --git a/compiler/rustc_parse/src/validate_attr.rs b/compiler/rustc_parse/src/validate_attr.rs index e6c46fc2528..cbe75b3dab6 100644 --- a/compiler/rustc_parse/src/validate_attr.rs +++ b/compiler/rustc_parse/src/validate_attr.rs @@ -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) diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index c5767fd902f..4910d63010c 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -130,59 +130,59 @@ impl CheckAttrVisitor<'_> { &mut specified_inline, &mut doc_aliases, ), - sym::no_link => self.check_no_link(hir_id, &attr, span, target), - sym::export_name => self.check_export_name(hir_id, &attr, span, target), + sym::no_link => self.check_no_link(hir_id, attr, span, target), + sym::export_name => self.check_export_name(hir_id, attr, span, target), sym::rustc_layout_scalar_valid_range_start | sym::rustc_layout_scalar_valid_range_end => { - self.check_rustc_layout_scalar_valid_range(&attr, span, target) + self.check_rustc_layout_scalar_valid_range(attr, span, target) } sym::allow_internal_unstable => { - self.check_allow_internal_unstable(hir_id, &attr, span, target, &attrs) + self.check_allow_internal_unstable(hir_id, attr, span, target, attrs) } - sym::debugger_visualizer => self.check_debugger_visualizer(&attr, target), + sym::debugger_visualizer => self.check_debugger_visualizer(attr, target), sym::rustc_allow_const_fn_unstable => { - self.check_rustc_allow_const_fn_unstable(hir_id, &attr, span, target) + self.check_rustc_allow_const_fn_unstable(hir_id, attr, span, target) } sym::rustc_std_internal_symbol => { - self.check_rustc_std_internal_symbol(&attr, span, target) + self.check_rustc_std_internal_symbol(attr, span, target) } sym::naked => self.check_naked(hir_id, attr, span, target), sym::rustc_never_returns_null_ptr => { self.check_applied_to_fn_or_method(hir_id, attr, span, target) } sym::rustc_legacy_const_generics => { - self.check_rustc_legacy_const_generics(hir_id, &attr, span, target, item) + self.check_rustc_legacy_const_generics(hir_id, attr, span, target, item) } sym::rustc_lint_query_instability => { - self.check_rustc_lint_query_instability(hir_id, &attr, span, target) + self.check_rustc_lint_query_instability(hir_id, attr, span, target) } sym::rustc_lint_diagnostics => { - self.check_rustc_lint_diagnostics(hir_id, &attr, span, target) + self.check_rustc_lint_diagnostics(hir_id, attr, span, target) } - sym::rustc_lint_opt_ty => self.check_rustc_lint_opt_ty(&attr, span, target), + sym::rustc_lint_opt_ty => self.check_rustc_lint_opt_ty(attr, span, target), sym::rustc_lint_opt_deny_field_access => { - self.check_rustc_lint_opt_deny_field_access(&attr, span, target) + self.check_rustc_lint_opt_deny_field_access(attr, span, target) } sym::rustc_clean | sym::rustc_dirty | sym::rustc_if_this_changed - | sym::rustc_then_this_would_need => self.check_rustc_dirty_clean(&attr), + | sym::rustc_then_this_would_need => self.check_rustc_dirty_clean(attr), sym::rustc_coinductive | sym::rustc_must_implement_one_of | sym::rustc_deny_explicit_impl - | sym::const_trait => self.check_must_be_applied_to_trait(&attr, span, target), + | sym::const_trait => self.check_must_be_applied_to_trait(attr, span, target), sym::cmse_nonsecure_entry => { self.check_cmse_nonsecure_entry(hir_id, attr, span, target) } sym::collapse_debuginfo => self.check_collapse_debuginfo(attr, span, target), - sym::must_not_suspend => self.check_must_not_suspend(&attr, span, target), - sym::must_use => self.check_must_use(hir_id, &attr, target), - sym::rustc_pass_by_value => self.check_pass_by_value(&attr, span, target), + sym::must_not_suspend => self.check_must_not_suspend(attr, span, target), + sym::must_use => self.check_must_use(hir_id, attr, target), + sym::rustc_pass_by_value => self.check_pass_by_value(attr, span, target), sym::rustc_allow_incoherent_impl => { - self.check_allow_incoherent_impl(&attr, span, target) + self.check_allow_incoherent_impl(attr, span, target) } sym::rustc_has_incoherent_inherent_impls => { - self.check_has_incoherent_inherent_impls(&attr, span, target) + self.check_has_incoherent_inherent_impls(attr, span, target) } sym::ffi_pure => self.check_ffi_pure(attr.span, attrs, target), sym::ffi_const => self.check_ffi_const(attr.span, target), @@ -192,9 +192,9 @@ impl CheckAttrVisitor<'_> { | sym::unstable | sym::stable | sym::rustc_allowed_through_unstable_modules - | sym::rustc_promotable => self.check_stability_promotable(&attr, span, target), - sym::link_ordinal => self.check_link_ordinal(&attr, span, target), - sym::rustc_confusables => self.check_confusables(&attr, target), + | sym::rustc_promotable => self.check_stability_promotable(attr, span, target), + sym::link_ordinal => self.check_link_ordinal(attr, span, target), + sym::rustc_confusables => self.check_confusables(attr, target), sym::rustc_safe_intrinsic => { self.check_rustc_safe_intrinsic(hir_id, attr, span, target) } @@ -824,7 +824,7 @@ impl CheckAttrVisitor<'_> { hir::Node::Item(item) => Some(&item.kind), _ => None, }) { - Some(ItemKind::Mod(ref module)) => { + Some(ItemKind::Mod(module)) => { if !module.item_ids.is_empty() { self.tcx.sess.emit_err(errors::DocKeywordEmptyMod { span: meta.span() }); return false; @@ -850,7 +850,7 @@ impl CheckAttrVisitor<'_> { hir::Node::Item(item) => Some(&item.kind), _ => None, }) { - Some(ItemKind::Impl(ref i)) => { + Some(ItemKind::Impl(i)) => { let is_valid = matches!(&i.self_ty.kind, hir::TyKind::Tup([_])) || if let hir::TyKind::BareFn(bare_fn_ty) = &i.self_ty.kind { bare_fn_ty.decl.inputs.len() == 1 @@ -2395,7 +2395,7 @@ impl<'tcx> Visitor<'tcx> for CheckAttrVisitor<'tcx> { // Historically we've run more checks on non-exported than exported macros, // so this lets us continue to run them while maintaining backwards compatibility. // In the long run, the checks should be harmonized. - if let ItemKind::Macro(ref macro_def, _) = item.kind { + if let ItemKind::Macro(macro_def, _) = item.kind { let def_id = item.owner_id.to_def_id(); if macro_def.macro_rules && !self.tcx.has_attr(def_id, sym::macro_export) { check_non_exported_macro_for_invalid_attrs(self.tcx, item); @@ -2443,7 +2443,7 @@ impl<'tcx> Visitor<'tcx> for CheckAttrVisitor<'tcx> { fn visit_stmt(&mut self, stmt: &'tcx hir::Stmt<'tcx>) { // When checking statements ignore expressions, they will be checked later. - if let hir::StmtKind::Local(ref l) = stmt.kind { + if let hir::StmtKind::Local(l) = stmt.kind { self.check_attributes(l.hir_id, stmt.span, Target::Statement, None); } intravisit::walk_stmt(self, stmt) diff --git a/compiler/rustc_passes/src/check_const.rs b/compiler/rustc_passes/src/check_const.rs index 7188c177feb..22b80a60d42 100644 --- a/compiler/rustc_passes/src/check_const.rs +++ b/compiler/rustc_passes/src/check_const.rs @@ -111,7 +111,7 @@ impl<'tcx> CheckConstVisitor<'tcx> { // However, we cannot allow stable `const fn`s to use unstable features without an explicit // opt-in via `rustc_allow_const_fn_unstable`. let attrs = tcx.hir().attrs(tcx.hir().local_def_id_to_hir_id(def_id)); - attr::rustc_allow_const_fn_unstable(&tcx.sess, attrs).any(|name| name == feature_gate) + attr::rustc_allow_const_fn_unstable(tcx.sess, attrs).any(|name| name == feature_gate) }; match required_gates { diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index 6b2b842543a..b4ebc2db3d6 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -373,10 +373,10 @@ impl<'tcx> MarkSymbolVisitor<'tcx> { self.repr_has_repr_c = def.repr().c(); self.repr_has_repr_simd = def.repr().simd(); - intravisit::walk_item(self, &item) + intravisit::walk_item(self, item) } hir::ItemKind::ForeignMod { .. } => {} - _ => intravisit::walk_item(self, &item), + _ => intravisit::walk_item(self, item), }, Node::TraitItem(trait_item) => { intravisit::walk_trait_item(self, trait_item); @@ -403,7 +403,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> { intravisit::walk_impl_item(self, impl_item); } Node::ForeignItem(foreign_item) => { - intravisit::walk_foreign_item(self, &foreign_item); + intravisit::walk_foreign_item(self, foreign_item); } _ => {} } @@ -459,9 +459,9 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> { self.lookup_and_handle_method(expr.hir_id); } hir::ExprKind::Field(ref lhs, ..) => { - self.handle_field_access(&lhs, expr.hir_id); + self.handle_field_access(lhs, expr.hir_id); } - hir::ExprKind::Struct(ref qpath, ref fields, _) => { + hir::ExprKind::Struct(qpath, fields, _) => { let res = self.typeck_results().qpath_res(qpath, expr.hir_id); self.handle_res(res); if let ty::Adt(adt, _) = self.typeck_results().expr_ty(expr).kind() { @@ -493,7 +493,7 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> { fn visit_pat(&mut self, pat: &'tcx hir::Pat<'tcx>) { self.in_pat = true; match pat.kind { - PatKind::Struct(ref path, ref fields, _) => { + PatKind::Struct(ref path, fields, _) => { let res = self.typeck_results().qpath_res(path, pat.hir_id); self.handle_field_pattern_match(pat, res, fields); } @@ -501,7 +501,7 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> { let res = self.typeck_results().qpath_res(qpath, pat.hir_id); self.handle_res(res); } - PatKind::TupleStruct(ref qpath, ref fields, dotdot) => { + PatKind::TupleStruct(ref qpath, fields, dotdot) => { let res = self.typeck_results().qpath_res(qpath, pat.hir_id); self.handle_tuple_field_pattern_match(pat, res, fields, dotdot); } @@ -1011,7 +1011,7 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalModDefId) { let def_id = field.did.expect_local(); let hir_id = tcx.hir().local_def_id_to_hir_id(def_id); if let ShouldWarnAboutField::Yes(is_pos) = - visitor.should_warn_about_field(&field) + visitor.should_warn_about_field(field) { let level = tcx .lint_level_at_node( diff --git a/compiler/rustc_passes/src/entry.rs b/compiler/rustc_passes/src/entry.rs index 51a64b3855f..2629b281756 100644 --- a/compiler/rustc_passes/src/entry.rs +++ b/compiler/rustc_passes/src/entry.rs @@ -38,7 +38,7 @@ fn entry_fn(tcx: TyCtxt<'_>, (): ()) -> Option<(DefId, EntryFnType)> { } // If the user wants no main function at all, then stop here. - if attr::contains_name(&tcx.hir().attrs(CRATE_HIR_ID), sym::no_main) { + if attr::contains_name(tcx.hir().attrs(CRATE_HIR_ID), sym::no_main) { return None; } diff --git a/compiler/rustc_passes/src/lang_items.rs b/compiler/rustc_passes/src/lang_items.rs index 2aec4ea7ef1..f78157f89ae 100644 --- a/compiler/rustc_passes/src/lang_items.rs +++ b/compiler/rustc_passes/src/lang_items.rs @@ -43,7 +43,7 @@ impl<'tcx> LanguageItemCollector<'tcx> { fn check_for_lang(&mut self, actual_target: Target, def_id: LocalDefId) { let attrs = self.tcx.hir().attrs(self.tcx.hir().local_def_id_to_hir_id(def_id)); - if let Some((name, span)) = extract(&attrs) { + if let Some((name, span)) = extract(attrs) { match LangItem::from_name(name) { // Known lang item with attribute on correct target. Some(lang_item) if actual_target == lang_item.target() => { diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs index b73fb984c0e..a0ba4e481f6 100644 --- a/compiler/rustc_passes/src/liveness.rs +++ b/compiler/rustc_passes/src/liveness.rs @@ -170,7 +170,7 @@ fn check_liveness(tcx: TyCtxt<'_>, def_id: LocalDefId) { // compute liveness let mut lsets = Liveness::new(&mut maps, def_id); - let entry_ln = lsets.compute(&body, hir_id); + let entry_ln = lsets.compute(body, hir_id); lsets.log_liveness(entry_ln, body_id.hir_id); // check for various error conditions @@ -366,7 +366,7 @@ impl<'tcx> IrMaps<'tcx> { impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> { fn visit_local(&mut self, local: &'tcx hir::Local<'tcx>) { - self.add_from_pat(&local.pat); + self.add_from_pat(local.pat); if local.els.is_some() { self.add_live_node_for_node(local.hir_id, ExprNode(local.span, local.hir_id)); } @@ -374,8 +374,8 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> { } fn visit_arm(&mut self, arm: &'tcx hir::Arm<'tcx>) { - self.add_from_pat(&arm.pat); - if let Some(hir::Guard::IfLet(ref let_expr)) = arm.guard { + self.add_from_pat(arm.pat); + if let Some(hir::Guard::IfLet(let_expr)) = arm.guard { self.add_from_pat(let_expr.pat); } intravisit::walk_arm(self, arm); @@ -400,7 +400,7 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> { fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) { match expr.kind { // live nodes required for uses or definitions of variables: - hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { + hir::ExprKind::Path(hir::QPath::Resolved(_, path)) => { debug!("expr {}: path that leads to {:?}", expr.hir_id, path.res); if let Res::Local(_var_hir_id) = path.res { self.add_live_node_for_node(expr.hir_id, ExprNode(expr.span, expr.hir_id)); @@ -736,7 +736,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { } } - let succ = self.propagate_through_expr(&body.value, self.exit_ln); + let succ = self.propagate_through_expr(body.value, self.exit_ln); if self.closure_min_captures.is_none() { // Either not a closure, or closure without any captured variables. @@ -776,7 +776,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { if !self.merge_from_succ(self.exit_ln, self.closure_ln) { break; } - assert_eq!(succ, self.propagate_through_expr(&body.value, self.exit_ln)); + assert_eq!(succ, self.propagate_through_expr(body.value, self.exit_ln)); } succ @@ -792,7 +792,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { fn propagate_through_stmt(&mut self, stmt: &hir::Stmt<'_>, succ: LiveNode) -> LiveNode { match stmt.kind { - hir::StmtKind::Local(ref local) => { + hir::StmtKind::Local(local) => { // Note: we mark the variable as defined regardless of whether // there is an initializer. Initially I had thought to only mark // the live variable as defined if it was initialized, and then we @@ -830,7 +830,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { self.init_from_succ(ln, succ); self.merge_from_succ(ln, else_ln); let succ = self.propagate_through_expr(init, ln); - self.define_bindings_in_pat(&local.pat, succ) + self.define_bindings_in_pat(local.pat, succ) } else { span_bug!( stmt.span, @@ -839,18 +839,18 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { } } else { let succ = self.propagate_through_opt_expr(local.init, succ); - self.define_bindings_in_pat(&local.pat, succ) + self.define_bindings_in_pat(local.pat, succ) } } hir::StmtKind::Item(..) => succ, hir::StmtKind::Expr(ref expr) | hir::StmtKind::Semi(ref expr) => { - self.propagate_through_expr(&expr, succ) + self.propagate_through_expr(expr, succ) } } } fn propagate_through_exprs(&mut self, exprs: &[Expr<'_>], succ: LiveNode) -> LiveNode { - exprs.iter().rev().fold(succ, |succ, expr| self.propagate_through_expr(&expr, succ)) + exprs.iter().rev().fold(succ, |succ, expr| self.propagate_through_expr(expr, succ)) } fn propagate_through_opt_expr( @@ -866,11 +866,11 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { match expr.kind { // Interesting cases with control flow or which gen/kill - hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { + hir::ExprKind::Path(hir::QPath::Resolved(_, path)) => { self.access_path(expr.hir_id, path, succ, ACC_READ | ACC_USE) } - hir::ExprKind::Field(ref e, _) => self.propagate_through_expr(&e, succ), + hir::ExprKind::Field(ref e, _) => self.propagate_through_expr(e, succ), hir::ExprKind::Closure { .. } => { debug!("{:?} is an ExprKind::Closure", expr); @@ -899,9 +899,9 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { // Note that labels have been resolved, so we don't need to look // at the label ident - hir::ExprKind::Loop(ref blk, ..) => self.propagate_through_loop(expr, &blk, succ), + hir::ExprKind::Loop(ref blk, ..) => self.propagate_through_loop(expr, blk, succ), - hir::ExprKind::Yield(ref e, ..) => { + hir::ExprKind::Yield(e, ..) => { let yield_ln = self.live_node(expr.hir_id, expr.span); self.init_from_succ(yield_ln, succ); self.merge_from_succ(yield_ln, self.exit_ln); @@ -923,11 +923,11 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { // ( succ ) // let else_ln = self.propagate_through_opt_expr(else_opt.as_deref(), succ); - let then_ln = self.propagate_through_expr(&then, succ); + let then_ln = self.propagate_through_expr(then, succ); let ln = self.live_node(expr.hir_id, expr.span); self.init_from_succ(ln, else_ln); self.merge_from_succ(ln, then_ln); - self.propagate_through_expr(&cond, ln) + self.propagate_through_expr(cond, ln) } hir::ExprKind::Match(ref e, arms, _) => { @@ -948,7 +948,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { let ln = self.live_node(expr.hir_id, expr.span); self.init_empty(ln, succ); for arm in arms { - let body_succ = self.propagate_through_expr(&arm.body, succ); + let body_succ = self.propagate_through_expr(arm.body, succ); let guard_succ = arm.guard.as_ref().map_or(body_succ, |g| match g { hir::Guard::If(e) => self.propagate_through_expr(e, body_succ), @@ -957,10 +957,10 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { self.propagate_through_expr(let_expr.init, let_bind) } }); - let arm_succ = self.define_bindings_in_pat(&arm.pat, guard_succ); + let arm_succ = self.define_bindings_in_pat(arm.pat, guard_succ); self.merge_from_succ(ln, arm_succ); } - self.propagate_through_expr(&e, ln) + self.propagate_through_expr(e, ln) } hir::ExprKind::Ret(ref o_e) => { @@ -968,7 +968,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { self.propagate_through_opt_expr(o_e.as_deref(), self.exit_ln) } - hir::ExprKind::Become(ref e) => { + hir::ExprKind::Become(e) => { // Ignore succ and subst exit_ln. self.propagate_through_expr(e, self.exit_ln) } @@ -1007,63 +1007,63 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { hir::ExprKind::Assign(ref l, ref r, _) => { // see comment on places in // propagate_through_place_components() - let succ = self.write_place(&l, succ, ACC_WRITE); - let succ = self.propagate_through_place_components(&l, succ); - self.propagate_through_expr(&r, succ) + let succ = self.write_place(l, succ, ACC_WRITE); + let succ = self.propagate_through_place_components(l, succ); + self.propagate_through_expr(r, succ) } hir::ExprKind::AssignOp(_, ref l, ref r) => { // an overloaded assign op is like a method call if self.typeck_results.is_method_call(expr) { - let succ = self.propagate_through_expr(&l, succ); - self.propagate_through_expr(&r, succ) + let succ = self.propagate_through_expr(l, succ); + self.propagate_through_expr(r, succ) } else { // see comment on places in // propagate_through_place_components() - let succ = self.write_place(&l, succ, ACC_WRITE | ACC_READ); - let succ = self.propagate_through_expr(&r, succ); - self.propagate_through_place_components(&l, succ) + let succ = self.write_place(l, succ, ACC_WRITE | ACC_READ); + let succ = self.propagate_through_expr(r, succ); + self.propagate_through_place_components(l, succ) } } // Uninteresting cases: just propagate in rev exec order - hir::ExprKind::Array(ref exprs) => self.propagate_through_exprs(exprs, succ), + hir::ExprKind::Array(exprs) => self.propagate_through_exprs(exprs, succ), - hir::ExprKind::Struct(_, ref fields, ref with_expr) => { + hir::ExprKind::Struct(_, fields, ref with_expr) => { let succ = self.propagate_through_opt_expr(with_expr.as_deref(), succ); fields .iter() .rev() - .fold(succ, |succ, field| self.propagate_through_expr(&field.expr, succ)) + .fold(succ, |succ, field| self.propagate_through_expr(field.expr, succ)) } - hir::ExprKind::Call(ref f, ref args) => { + hir::ExprKind::Call(ref f, args) => { let succ = self.check_is_ty_uninhabited(expr, succ); let succ = self.propagate_through_exprs(args, succ); - self.propagate_through_expr(&f, succ) + self.propagate_through_expr(f, succ) } - hir::ExprKind::MethodCall(.., receiver, ref args, _) => { + hir::ExprKind::MethodCall(.., receiver, args, _) => { let succ = self.check_is_ty_uninhabited(expr, succ); let succ = self.propagate_through_exprs(args, succ); self.propagate_through_expr(receiver, succ) } - hir::ExprKind::Tup(ref exprs) => self.propagate_through_exprs(exprs, succ), + hir::ExprKind::Tup(exprs) => self.propagate_through_exprs(exprs, succ), hir::ExprKind::Binary(op, ref l, ref r) if op.node.is_lazy() => { - let r_succ = self.propagate_through_expr(&r, succ); + let r_succ = self.propagate_through_expr(r, succ); let ln = self.live_node(expr.hir_id, expr.span); self.init_from_succ(ln, succ); self.merge_from_succ(ln, r_succ); - self.propagate_through_expr(&l, ln) + self.propagate_through_expr(l, ln) } hir::ExprKind::Index(ref l, ref r, _) | hir::ExprKind::Binary(_, ref l, ref r) => { - let r_succ = self.propagate_through_expr(&r, succ); - self.propagate_through_expr(&l, r_succ) + let r_succ = self.propagate_through_expr(r, succ); + self.propagate_through_expr(l, r_succ) } hir::ExprKind::AddrOf(_, _, ref e) @@ -1071,9 +1071,9 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { | hir::ExprKind::Type(ref e, _) | hir::ExprKind::DropTemps(ref e) | hir::ExprKind::Unary(_, ref e) - | hir::ExprKind::Repeat(ref e, _) => self.propagate_through_expr(&e, succ), + | hir::ExprKind::Repeat(ref e, _) => self.propagate_through_expr(e, succ), - hir::ExprKind::InlineAsm(ref asm) => { + hir::ExprKind::InlineAsm(asm) => { // Handle non-returning asm let mut succ = if asm.options.contains(InlineAsmOptions::NORETURN) { self.exit_ln @@ -1141,7 +1141,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { // Note that labels have been resolved, so we don't need to look // at the label ident - hir::ExprKind::Block(ref blk, _) => self.propagate_through_block(&blk, succ), + hir::ExprKind::Block(ref blk, _) => self.propagate_through_block(blk, succ), } } @@ -1197,7 +1197,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { match expr.kind { hir::ExprKind::Path(_) => succ, - hir::ExprKind::Field(ref e, _) => self.propagate_through_expr(&e, succ), + hir::ExprKind::Field(ref e, _) => self.propagate_through_expr(e, succ), _ => self.propagate_through_expr(expr, succ), } } @@ -1205,7 +1205,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { // see comment on propagate_through_place() fn write_place(&mut self, expr: &Expr<'_>, succ: LiveNode, acc: u32) -> LiveNode { match expr.kind { - hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { + hir::ExprKind::Path(hir::QPath::Resolved(_, path)) => { self.access_path(expr.hir_id, path, succ, acc) } @@ -1341,7 +1341,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for Liveness<'a, 'tcx> { fn visit_local(&mut self, local: &'tcx hir::Local<'tcx>) { - self.check_unused_vars_in_pat(&local.pat, None, None, |spans, hir_id, ln, var| { + self.check_unused_vars_in_pat(local.pat, None, None, |spans, hir_id, ln, var| { if local.init.is_some() { self.warn_about_dead_assign(spans, hir_id, ln, var); } @@ -1356,7 +1356,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Liveness<'a, 'tcx> { } fn visit_arm(&mut self, arm: &'tcx hir::Arm<'tcx>) { - self.check_unused_vars_in_pat(&arm.pat, None, None, |_, _, _, _| {}); + self.check_unused_vars_in_pat(arm.pat, None, None, |_, _, _, _| {}); intravisit::walk_arm(self, arm); } } @@ -1364,16 +1364,16 @@ impl<'a, 'tcx> Visitor<'tcx> for Liveness<'a, 'tcx> { fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr<'tcx>) { match expr.kind { hir::ExprKind::Assign(ref l, ..) => { - this.check_place(&l); + this.check_place(l); } hir::ExprKind::AssignOp(_, ref l, _) => { if !this.typeck_results.is_method_call(expr) { - this.check_place(&l); + this.check_place(l); } } - hir::ExprKind::InlineAsm(ref asm) => { + hir::ExprKind::InlineAsm(asm) => { for (op, _op_sp) in asm.operands { match op { hir::InlineAsmOperand::Out { expr, .. } => { @@ -1434,7 +1434,7 @@ fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr<'tcx>) { impl<'tcx> Liveness<'_, 'tcx> { fn check_place(&mut self, expr: &'tcx Expr<'tcx>) { match expr.kind { - hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { + hir::ExprKind::Path(hir::QPath::Resolved(_, path)) => { if let Res::Local(var_hid) = path.res { // Assignment to an immutable variable or argument: only legal // if there is no later assignment. If this local is actually @@ -1507,7 +1507,7 @@ impl<'tcx> Liveness<'_, 'tcx> { fn warn_about_unused_args(&self, body: &hir::Body<'_>, entry_ln: LiveNode) { for p in body.params { self.check_unused_vars_in_pat( - &p.pat, + p.pat, Some(entry_ln), Some(body), |spans, hir_id, ln, var| { diff --git a/compiler/rustc_passes/src/loops.rs b/compiler/rustc_passes/src/loops.rs index 25e131d7477..8e6d5805275 100644 --- a/compiler/rustc_passes/src/loops.rs +++ b/compiler/rustc_passes/src/loops.rs @@ -39,7 +39,7 @@ struct CheckLoopVisitor<'a, 'hir> { fn check_mod_loops(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) { tcx.hir().visit_item_likes_in_module( module_def_id, - &mut CheckLoopVisitor { sess: &tcx.sess, hir_map: tcx.hir(), cx: Normal }, + &mut CheckLoopVisitor { sess: tcx.sess, hir_map: tcx.hir(), cx: Normal }, ); } @@ -84,7 +84,7 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> { fn visit_expr(&mut self, e: &'hir hir::Expr<'hir>) { match e.kind { hir::ExprKind::Loop(ref b, _, source, _) => { - self.with_context(Loop(source), |v| v.visit_block(&b)); + self.with_context(Loop(source), |v| v.visit_block(b)); } hir::ExprKind::Closure(&hir::Closure { ref fn_decl, @@ -98,19 +98,19 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> { } else { Closure(fn_decl_span) }; - self.visit_fn_decl(&fn_decl); + self.visit_fn_decl(fn_decl); self.with_context(cx, |v| v.visit_nested_body(body)); } hir::ExprKind::Block(ref b, Some(_label)) => { - self.with_context(LabeledBlock, |v| v.visit_block(&b)); + self.with_context(LabeledBlock, |v| v.visit_block(b)); } hir::ExprKind::Block(ref b, None) if matches!(self.cx, Fn) => { - self.with_context(Normal, |v| v.visit_block(&b)); + self.with_context(Normal, |v| v.visit_block(b)); } hir::ExprKind::Block(ref b, None) if matches!(self.cx, Normal | Constant | UnlabeledBlock(_)) => { - self.with_context(UnlabeledBlock(b.span.shrink_to_lo()), |v| v.visit_block(&b)); + self.with_context(UnlabeledBlock(b.span.shrink_to_lo()), |v| v.visit_block(b)); } hir::ExprKind::Break(break_label, ref opt_expr) => { if let Some(e) = opt_expr { diff --git a/compiler/rustc_passes/src/naked_functions.rs b/compiler/rustc_passes/src/naked_functions.rs index 7f36c59ad98..54f296da5c5 100644 --- a/compiler/rustc_passes/src/naked_functions.rs +++ b/compiler/rustc_passes/src/naked_functions.rs @@ -211,7 +211,7 @@ impl<'tcx> CheckInlineAssembly<'tcx> { self.items.push((ItemKind::NonAsm, span)); } - ExprKind::InlineAsm(ref asm) => { + ExprKind::InlineAsm(asm) => { self.items.push((ItemKind::Asm, span)); self.check_inline_asm(asm, span); } @@ -282,13 +282,13 @@ impl<'tcx> Visitor<'tcx> for CheckInlineAssembly<'tcx> { StmtKind::Local(..) => { self.items.push((ItemKind::NonAsm, stmt.span)); } - StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => { + StmtKind::Expr(expr) | StmtKind::Semi(expr) => { self.check_expr(expr, stmt.span); } } } fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) { - self.check_expr(&expr, expr.span); + self.check_expr(expr, expr.span); } } diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index 03070dc6f28..fd7cf1ac11e 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -158,9 +158,9 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { return; } - let stab = attr::find_stability(&self.tcx.sess, attrs, item_sp); - let const_stab = attr::find_const_stability(&self.tcx.sess, attrs, item_sp); - let body_stab = attr::find_body_stability(&self.tcx.sess, attrs); + let stab = attr::find_stability(self.tcx.sess, attrs, item_sp); + let const_stab = attr::find_const_stability(self.tcx.sess, attrs, item_sp); + let body_stab = attr::find_body_stability(self.tcx.sess, attrs); let mut const_span = None; let const_stab = const_stab.map(|(const_stab, const_span_node)| { @@ -721,8 +721,8 @@ impl<'tcx> Visitor<'tcx> for Checker<'tcx> { let features = self.tcx.features(); if features.staged_api { let attrs = self.tcx.hir().attrs(item.hir_id()); - let stab = attr::find_stability(&self.tcx.sess, attrs, item.span); - let const_stab = attr::find_const_stability(&self.tcx.sess, attrs, item.span); + let stab = attr::find_stability(self.tcx.sess, attrs, item.span); + let const_stab = attr::find_const_stability(self.tcx.sess, attrs, item.span); // If this impl block has an #[unstable] attribute, give an // error if all involved types and traits are stable, because diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index a14c2916392..4324afe42b3 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -664,7 +664,7 @@ impl<'tcx> EmbargoVisitor<'tcx> { impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> { fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) { if self.impl_trait_pass - && let hir::ItemKind::OpaqueTy(ref opaque) = item.kind + && let hir::ItemKind::OpaqueTy(opaque) = item.kind && !opaque.in_trait { // FIXME: This is some serious pessimization intended to workaround deficiencies @@ -688,7 +688,7 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> { | hir::ItemKind::GlobalAsm(..) => {} // The interface is empty, and all nested items are processed by `visit_item`. hir::ItemKind::Mod(..) | hir::ItemKind::OpaqueTy(..) => {} - hir::ItemKind::Macro(ref macro_def, _) => { + hir::ItemKind::Macro(macro_def, _) => { if let Some(item_ev) = item_ev { self.update_reachability_from_macro(item.owner_id.def_id, macro_def, item_ev); } @@ -727,7 +727,7 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> { self.reach(item.owner_id.def_id, item_ev).generics().predicates(); } } - hir::ItemKind::Impl(ref impl_) => { + hir::ItemKind::Impl(impl_) => { // Type inference is very smart sometimes. It can make an impl reachable even some // components of its type or trait are unreachable. E.g. methods of // `impl ReachableTrait for ReachableTy { ... }` @@ -1741,7 +1741,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'tcx, '_> { // Subitems of trait impls have inherited publicity. DefKind::Impl { .. } => { let item = tcx.hir().item(id); - if let hir::ItemKind::Impl(ref impl_) = item.kind { + if let hir::ItemKind::Impl(impl_) = item.kind { let impl_vis = ty::Visibility::of_impl::( item.owner_id.def_id, tcx, diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs index 6ad72e37a8c..a290bd10bea 100644 --- a/compiler/rustc_query_impl/src/plumbing.rs +++ b/compiler/rustc_query_impl/src/plumbing.rs @@ -358,7 +358,7 @@ pub(crate) fn encode_query_results<'a, 'tcx, Q>( assert!(query.query_state(qcx).all_inactive()); let cache = query.query_cache(qcx); cache.iter(&mut |key, value, dep_node| { - if query.cache_on_disk(qcx.tcx, &key) { + if query.cache_on_disk(qcx.tcx, key) { let dep_node = SerializedDepNodeIndex::new(dep_node.index()); // Record position of the cache entry. diff --git a/compiler/rustc_query_system/src/dep_graph/graph.rs b/compiler/rustc_query_system/src/dep_graph/graph.rs index 831062b1678..d720744a7a7 100644 --- a/compiler/rustc_query_system/src/dep_graph/graph.rs +++ b/compiler/rustc_query_system/src/dep_graph/graph.rs @@ -743,7 +743,7 @@ impl DepGraphData { // in the previous compilation session too, so we can try to // mark it as green by recursively marking all of its // dependencies green. - self.try_mark_previous_green(qcx, prev_index, &dep_node, None) + self.try_mark_previous_green(qcx, prev_index, dep_node, None) .map(|dep_node_index| (prev_index, dep_node_index)) } } diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs index 1f3403d09be..6c08df99e9d 100644 --- a/compiler/rustc_query_system/src/query/plumbing.rs +++ b/compiler/rustc_query_system/src/query/plumbing.rs @@ -220,7 +220,7 @@ where C: QueryCache, Tcx: DepContext, { - match cache.lookup(&key) { + match cache.lookup(key) { Some((value, index)) => { tcx.profiler().query_cache_hit(index.into()); tcx.dep_graph().read_index(index); @@ -502,7 +502,7 @@ where // The diagnostics for this query will be promoted to the current session during // `try_mark_green()`, so we can ignore them here. if let Some(ret) = qcx.start_query(job_id, false, None, || { - try_load_from_disk_and_cache_in_memory(query, dep_graph_data, qcx, &key, &dep_node) + try_load_from_disk_and_cache_in_memory(query, dep_graph_data, qcx, &key, dep_node) }) { return ret; } @@ -563,7 +563,7 @@ where // Note this function can be called concurrently from the same query // We must ensure that this is handled correctly. - let (prev_dep_node_index, dep_node_index) = dep_graph_data.try_mark_green(qcx, &dep_node)?; + let (prev_dep_node_index, dep_node_index) = dep_graph_data.try_mark_green(qcx, dep_node)?; debug_assert!(dep_graph_data.is_index_green(prev_dep_node_index)); @@ -610,7 +610,7 @@ where // Sanity check for the logic in `ensure`: if the node is green and the result loadable, // we should actually be able to load it. debug_assert!( - !query.loadable_from_disk(qcx, &key, prev_dep_node_index), + !query.loadable_from_disk(qcx, key, prev_dep_node_index), "missing on-disk cache entry for loadable {dep_node:?}" ); @@ -667,7 +667,7 @@ pub(crate) fn incremental_verify_ich( let old_hash = dep_graph_data.prev_fingerprint_of(prev_index); if new_hash != old_hash { - incremental_verify_ich_failed(tcx, prev_index, &|| format_value(&result)); + incremental_verify_ich_failed(tcx, prev_index, &|| format_value(result)); } } 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]) { 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(doc: &'md str) -> Vec> { 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), ) diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index d4f9122e7e3..8ab48c99007 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -857,7 +857,7 @@ impl OutFileName { pub fn as_path(&self) -> &Path { match *self { OutFileName::Real(ref path) => path.as_ref(), - OutFileName::Stdout => &Path::new("stdout"), + OutFileName::Stdout => Path::new("stdout"), } } diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 38e09f47eac..efd75ce6151 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -808,7 +808,7 @@ impl Session { /// Returns a list of directories where target-specific tool binaries are located. pub fn get_tools_search_paths(&self, self_contained: bool) -> Vec { - let rustlib_path = rustc_target::target_rustlib_path(&self.sysroot, &config::host_triple()); + let rustlib_path = rustc_target::target_rustlib_path(&self.sysroot, config::host_triple()); let p = PathBuf::from_iter([ Path::new(&self.sysroot), Path::new(&rustlib_path), diff --git a/compiler/rustc_smir/src/rustc_internal/internal.rs b/compiler/rustc_smir/src/rustc_internal/internal.rs index 147d683b51f..24b1a3c63be 100644 --- a/compiler/rustc_smir/src/rustc_internal/internal.rs +++ b/compiler/rustc_smir/src/rustc_internal/internal.rs @@ -212,14 +212,14 @@ impl<'tcx> RustcInternal<'tcx> for BoundVariableKind { BoundVariableKind::Ty(kind) => rustc_ty::BoundVariableKind::Ty(match kind { BoundTyKind::Anon => rustc_ty::BoundTyKind::Anon, BoundTyKind::Param(def, symbol) => { - rustc_ty::BoundTyKind::Param(def.0.internal(tables), Symbol::intern(&symbol)) + rustc_ty::BoundTyKind::Param(def.0.internal(tables), Symbol::intern(symbol)) } }), BoundVariableKind::Region(kind) => rustc_ty::BoundVariableKind::Region(match kind { BoundRegionKind::BrAnon => rustc_ty::BoundRegionKind::BrAnon, BoundRegionKind::BrNamed(def, symbol) => rustc_ty::BoundRegionKind::BrNamed( def.0.internal(tables), - Symbol::intern(&symbol), + Symbol::intern(symbol), ), BoundRegionKind::BrEnv => rustc_ty::BoundRegionKind::BrEnv, }), diff --git a/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs b/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs index 1501e7d0cf7..1fd8542b2a6 100644 --- a/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs +++ b/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs @@ -552,7 +552,7 @@ fn encode_ty<'tcx>( // Use user-defined CFI encoding for type if let Some(value_str) = cfi_encoding.value_str() { if !value_str.to_string().trim().is_empty() { - s.push_str(&value_str.to_string().trim()); + s.push_str(value_str.to_string().trim()); } else { #[allow( rustc::diagnostic_outside_of_impl, @@ -604,7 +604,7 @@ fn encode_ty<'tcx>( // Use user-defined CFI encoding for type if let Some(value_str) = cfi_encoding.value_str() { if !value_str.to_string().trim().is_empty() { - s.push_str(&value_str.to_string().trim()); + s.push_str(value_str.to_string().trim()); } else { #[allow( rustc::diagnostic_outside_of_impl, @@ -1145,5 +1145,5 @@ pub fn typeid_for_instance<'tcx>( } } - typeid_for_fnabi(tcx, &fn_abi, options) + typeid_for_fnabi(tcx, fn_abi, options) } diff --git a/compiler/rustc_trait_selection/src/solve/assembly/mod.rs b/compiler/rustc_trait_selection/src/solve/assembly/mod.rs index b6d2228d4b8..59c979cf437 100644 --- a/compiler/rustc_trait_selection/src/solve/assembly/mod.rs +++ b/compiler/rustc_trait_selection/src/solve/assembly/mod.rs @@ -97,7 +97,7 @@ pub(super) trait GoalKind<'tcx>: bug!("expected object type in `consider_object_bound_candidate`"); }; ecx.add_goals(structural_traits::predicates_for_object_candidate( - &ecx, + ecx, goal.param_env, goal.predicate.trait_ref(tcx), bounds, diff --git a/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs b/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs index 6eefccbde04..f442e2a08a8 100644 --- a/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs +++ b/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs @@ -50,14 +50,14 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_auto_trait<'tcx>( ty::Array(element_ty, _) | ty::Slice(element_ty) => Ok(vec![element_ty]), - ty::Tuple(ref tys) => { + ty::Tuple(tys) => { // (T1, ..., Tn) -- meets any bound that all of T1...Tn meet Ok(tys.iter().collect()) } - ty::Closure(_, ref args) => Ok(vec![args.as_closure().tupled_upvars_ty()]), + ty::Closure(_, args) => Ok(vec![args.as_closure().tupled_upvars_ty()]), - ty::Coroutine(_, ref args, _) => { + ty::Coroutine(_, args, _) => { let coroutine_args = args.as_coroutine(); Ok(vec![coroutine_args.tupled_upvars_ty(), coroutine_args.witness()]) } diff --git a/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs b/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs index 5752d49ed2c..a287582dca7 100644 --- a/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs +++ b/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs @@ -175,7 +175,7 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> { warn!("unexpected root evaluation: {:?}", self.evaluation); return vec![]; } - inspect::CanonicalGoalEvaluationKind::Evaluation { ref revisions } => { + inspect::CanonicalGoalEvaluationKind::Evaluation { revisions } => { if let Some(last) = revisions.last() { last } else { diff --git a/compiler/rustc_trait_selection/src/traits/auto_trait.rs b/compiler/rustc_trait_selection/src/traits/auto_trait.rs index dbf6749b523..79314b4dfb4 100644 --- a/compiler/rustc_trait_selection/src/traits/auto_trait.rs +++ b/compiler/rustc_trait_selection/src/traits/auto_trait.rs @@ -252,7 +252,7 @@ impl<'tcx> AutoTraitFinder<'tcx> { fresh_preds.insert(self.clean_pred(infcx, predicate.as_predicate())); } - let mut select = SelectionContext::new(&infcx); + let mut select = SelectionContext::new(infcx); let mut already_visited = FxHashSet::default(); let mut predicates = VecDeque::new(); diff --git a/compiler/rustc_trait_selection/src/traits/engine.rs b/compiler/rustc_trait_selection/src/traits/engine.rs index d9a1a98191d..67718d0a348 100644 --- a/compiler/rustc_trait_selection/src/traits/engine.rs +++ b/compiler/rustc_trait_selection/src/traits/engine.rs @@ -108,7 +108,7 @@ impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> { param_env: ty::ParamEnv<'tcx>, value: T, ) -> T { - let infer_ok = self.infcx.at(&cause, param_env).normalize(value); + let infer_ok = self.infcx.at(cause, param_env).normalize(value); self.register_infer_ok_obligations(infer_ok) } @@ -204,7 +204,7 @@ impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> { generic_param_scope: LocalDefId, outlives_env: &OutlivesEnvironment<'tcx>, ) -> Result<(), ErrorGuaranteed> { - let errors = self.infcx.resolve_regions(&outlives_env); + let errors = self.infcx.resolve_regions(outlives_env); if errors.is_empty() { Ok(()) } else { diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/infer_ctxt_ext.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/infer_ctxt_ext.rs index b4835b011dd..0190d5ab4be 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/infer_ctxt_ext.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/infer_ctxt_ext.rs @@ -61,8 +61,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> { .params .iter() .map(|arg| { - if let hir::Pat { kind: hir::PatKind::Tuple(ref args, _), span, .. } = - *arg.pat + if let hir::Pat { kind: hir::PatKind::Tuple(args, _), span, .. } = *arg.pat { Some(ArgKind::Tuple( Some(span), @@ -92,7 +91,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> { .inputs .iter() .map(|arg| match arg.kind { - hir::TyKind::Tup(ref tys) => ArgKind::Tuple( + hir::TyKind::Tup(tys) => ArgKind::Tuple( Some(arg.span), vec![("_".to_owned(), "_".to_owned()); tys.len()], ), @@ -100,7 +99,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> { }) .collect::>(), ), - Node::Ctor(ref variant_data) => { + Node::Ctor(variant_data) => { let span = variant_data.ctor_hir_id().map_or(DUMMY_SP, |id| hir.span(id)); (span, None, vec![ArgKind::empty(); variant_data.fields().len()]) } diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs index da2d5dfbfb5..33e4fd33716 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs @@ -482,7 +482,7 @@ impl<'tcx> OnUnimplementedDirective { match Self::parse( tcx, item_def_id, - &items, + items, item.span(), false, is_diagnostic_namespace_variant, @@ -875,7 +875,7 @@ impl<'tcx> OnUnimplementedFormatString { // don't break messages using these two arguments incorrectly &empty_string } else if s == sym::ItemContext { - &item_context + item_context } else if s == sym::integral { "{integral}" } else if s == sym::integer_ { diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 145b0cd0092..38ef94a4d3b 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -99,7 +99,7 @@ impl<'tcx, 'a> CoroutineData<'tcx, 'a> { .awaits .into_iter() .map(|id| hir.expect_expr(id)) - .find(|await_expr| ty_matches(ty::Binder::dummy(self.0.expr_ty_adjusted(&await_expr)))) + .find(|await_expr| ty_matches(ty::Binder::dummy(self.0.expr_ty_adjusted(await_expr)))) .map(|expr| expr.span) } } @@ -501,7 +501,7 @@ pub fn suggest_restriction<'tcx>( impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { fn suggest_restricting_param_bound( &self, - mut err: &mut Diagnostic, + err: &mut Diagnostic, trait_pred: ty::PolyTraitPredicate<'tcx>, associated_ty: Option<(&'static str, Ty<'tcx>)>, mut body_id: LocalDefId, @@ -533,7 +533,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { suggest_restriction( self.tcx, body_id, - &generics, + generics, "`Self`", err, None, @@ -552,7 +552,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { assert!(param_ty); // Restricting `Self` for a single method. suggest_restriction( - self.tcx, body_id, &generics, "`Self`", err, None, projection, trait_pred, + self.tcx, body_id, generics, "`Self`", err, None, projection, trait_pred, None, ); return; @@ -575,7 +575,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { suggest_restriction( self.tcx, body_id, - &generics, + generics, "the associated type", err, Some(fn_sig), @@ -595,7 +595,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { suggest_restriction( self.tcx, body_id, - &generics, + generics, "the associated type", err, None, @@ -662,7 +662,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { if suggest_constraining_type_param( self.tcx, generics, - &mut err, + err, ¶m_name, &constraint, Some(trait_pred.def_id()), @@ -690,7 +690,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { if suggest_arbitrary_trait_bound( self.tcx, generics, - &mut err, + err, trait_pred, associated_ty, ) { @@ -1273,7 +1273,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { let code = if let ObligationCauseCode::FunctionArgumentObligation { parent_code, .. } = obligation.cause.code() { - &parent_code + parent_code } else if let ObligationCauseCode::ItemObligation(_) | ObligationCauseCode::ExprItemObligation(..) = obligation.cause.code() { @@ -1867,7 +1867,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { let body = self.tcx.hir().body(self.tcx.hir().body_owned_by(obligation.cause.body_id)); let mut visitor = ReturnsVisitor::default(); - visitor.visit_body(&body); + visitor.visit_body(body); let mut sugg = vec![(span.shrink_to_lo(), "Box<".to_string()), (span.shrink_to_hi(), ">".to_string())]; @@ -1922,7 +1922,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { let body = hir.body(*body_id); // Point at all the `return`s in the function as they have failed trait bounds. let mut visitor = ReturnsVisitor::default(); - visitor.visit_body(&body); + visitor.visit_body(body); let typeck_results = self.typeck_results.as_ref().unwrap(); for expr in &visitor.returns { if let Some(returned_ty) = typeck_results.node_type_opt(expr.hir_id) { @@ -2300,7 +2300,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { // cycles. If we can't use resolved types because the coroutine comes from another crate, // we still provide a targeted error but without all the relevant spans. let coroutine_data = match &self.typeck_results { - Some(t) if t.hir_owner.to_def_id() == coroutine_did_root => CoroutineData(&t), + Some(t) if t.hir_owner.to_def_id() == coroutine_did_root => CoroutineData(t), _ if coroutine_did.is_local() => { CoroutineData(self.tcx.typeck(coroutine_did.expect_local())) } @@ -2344,7 +2344,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { if interior_or_upvar_span.is_none() { interior_or_upvar_span = - coroutine_data.try_get_upvar_span(&self, coroutine_did, ty_matches); + coroutine_data.try_get_upvar_span(self, coroutine_did, ty_matches); } if interior_or_upvar_span.is_none() && !coroutine_did.is_local() { @@ -2517,7 +2517,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { CoroutineInteriorOrUpvar::Upvar(upvar_span) => { // `Some((ref_ty, is_mut))` if `target_ty` is `&T` or `&mut T` and fails to impl `Send` let non_send = match target_ty.kind() { - ty::Ref(_, ref_ty, mutability) => match self.evaluate_obligation(&obligation) { + ty::Ref(_, ref_ty, mutability) => match self.evaluate_obligation(obligation) { Ok(eval) if !eval.may_apply() => Some((ref_ty, mutability.is_mut())), _ => None, }, @@ -3305,7 +3305,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { err, predicate, param_env, - &parent_code, + parent_code, obligated_types, seen_requirements, ) @@ -3660,9 +3660,9 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { // If the expression we're calling on is a binding, we want to point at the // `let` when talking about the type. Otherwise we'll point at every part // of the method chain with the type. - self.point_at_chain(binding_expr, &typeck_results, type_diffs, param_env, err); + self.point_at_chain(binding_expr, typeck_results, type_diffs, param_env, err); } else { - self.point_at_chain(expr, &typeck_results, type_diffs, param_env, err); + self.point_at_chain(expr, typeck_results, type_diffs, param_env, err); } } let call_node = hir.find(call_hir_id); @@ -3856,7 +3856,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { suggest_restriction( tcx, hir.body_owner_def_id(body_id), - &generics, + generics, &format!("type parameter `{ty}`"), err, node.fn_sig(), diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs index 5239725f509..cdec0731778 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs @@ -511,7 +511,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { if Some(trait_ref.def_id()) == tcx.lang_items().tuple_trait() { self.add_tuple_trait_message( - &obligation.cause.code().peel_derives(), + obligation.cause.code().peel_derives(), &mut err, ); } @@ -569,7 +569,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { if Some(trait_ref.def_id()) == self.tcx.lang_items().sized_trait() { self.suggest_borrowing_for_object_cast( &mut err, - &root_obligation, + root_obligation, source, target, ); @@ -1965,7 +1965,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { } } ObligationCauseCode::FunctionArgumentObligation { parent_code, .. } => { - self.get_parent_trait_ref(&parent_code) + self.get_parent_trait_ref(parent_code) } _ => None, } @@ -2180,7 +2180,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { self.tcx.hir().maybe_body_owned_by(obligation.cause.body_id) { let mut expr_finder = FindExprBySpan::new(span); - expr_finder.visit_expr(&self.tcx.hir().body(body_id).value); + expr_finder.visit_expr(self.tcx.hir().body(body_id).value); if let Some(hir::Expr { kind: hir::ExprKind::Path(hir::QPath::Resolved(None, path)), @@ -2932,7 +2932,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { obligation.param_env, ) { self.report_similar_impl_candidates_for_root_obligation( - &obligation, + obligation, *trait_predicate, body_def_id, err, @@ -3044,13 +3044,13 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { (ty::ClosureKind::FnOnce, Some((span, place))) => { err.fn_once_label = Some(ClosureFnOnceLabel { span: *span, - place: ty::place_to_string_for_capture(self.tcx, &place), + place: ty::place_to_string_for_capture(self.tcx, place), }) } (ty::ClosureKind::FnMut, Some((span, place))) => { err.fn_mut_label = Some(ClosureFnMutLabel { span: *span, - place: ty::place_to_string_for_capture(self.tcx, &place), + place: ty::place_to_string_for_capture(self.tcx, place), }) } _ => {} @@ -3162,7 +3162,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { let mut not_tupled = false; let found = match found_trait_ref.skip_binder().args.type_at(1).kind() { - ty::Tuple(ref tys) => vec![ArgKind::empty(); tys.len()], + ty::Tuple(tys) => vec![ArgKind::empty(); tys.len()], _ => { not_tupled = true; vec![ArgKind::empty()] @@ -3171,7 +3171,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { let expected_ty = expected_trait_ref.skip_binder().args.type_at(1); let expected = match expected_ty.kind() { - ty::Tuple(ref tys) => { + ty::Tuple(tys) => { tys.iter().map(|t| ArgKind::from_expected_ty(t, Some(span))).collect() } _ => { diff --git a/compiler/rustc_trait_selection/src/traits/object_safety.rs b/compiler/rustc_trait_selection/src/traits/object_safety.rs index 3e5dd8c50d4..5d5440094fd 100644 --- a/compiler/rustc_trait_selection/src/traits/object_safety.rs +++ b/compiler/rustc_trait_selection/src/traits/object_safety.rs @@ -84,7 +84,7 @@ fn check_is_object_safe(tcx: TyCtxt<'_>, trait_def_id: DefId) -> bool { span, ) = violation { - lint_object_unsafe_trait(tcx, *span, trait_def_id, &violation); + lint_object_unsafe_trait(tcx, *span, trait_def_id, violation); } } return true; diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 3bc401128b3..06f65e414da 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -584,7 +584,7 @@ impl<'a, 'b, 'tcx> TypeFolder> for AssocTypeNormalizer<'a, 'b, 'tcx data, self.cause.clone(), self.depth, - &mut self.obligations, + self.obligations, ) } else { opt_normalize_projection_type( @@ -593,7 +593,7 @@ impl<'a, 'b, 'tcx> TypeFolder> for AssocTypeNormalizer<'a, 'b, 'tcx data, self.cause.clone(), self.depth, - &mut self.obligations, + self.obligations, ) .ok() .flatten() @@ -632,7 +632,7 @@ impl<'a, 'b, 'tcx> TypeFolder> for AssocTypeNormalizer<'a, 'b, 'tcx data, self.cause.clone(), self.depth, - &mut self.obligations, + self.obligations, ) .ok() .flatten() @@ -717,7 +717,7 @@ impl<'a, 'b, 'tcx> TypeFolder> for AssocTypeNormalizer<'a, 'b, 'tcx data, self.cause.clone(), self.depth, - &mut self.obligations, + self.obligations, ) } @@ -732,7 +732,7 @@ impl<'a, 'b, 'tcx> TypeFolder> for AssocTypeNormalizer<'a, 'b, 'tcx data, self.cause.clone(), self.depth, - &mut self.obligations, + self.obligations, ); PlaceholderReplacer::replace_placeholders( diff --git a/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs b/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs index f8efa6a1f6c..06d41243e75 100644 --- a/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs +++ b/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs @@ -48,9 +48,7 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { // (T1..Tn) and closures have same properties as T1..Tn -- // check if *all* of them are trivial. ty::Tuple(tys) => tys.iter().all(|t| trivial_dropck_outlives(tcx, t)), - ty::Closure(_, ref args) => { - trivial_dropck_outlives(tcx, args.as_closure().tupled_upvars_ty()) - } + ty::Closure(_, args) => trivial_dropck_outlives(tcx, args.as_closure().tupled_upvars_ty()), ty::Adt(def, _) => { if Some(def.did()) == tcx.lang_items().manually_drop() { diff --git a/compiler/rustc_trait_selection/src/traits/query/evaluate_obligation.rs b/compiler/rustc_trait_selection/src/traits/query/evaluate_obligation.rs index 65f32b1c48a..04b3119323f 100644 --- a/compiler/rustc_trait_selection/src/traits/query/evaluate_obligation.rs +++ b/compiler/rustc_trait_selection/src/traits/query/evaluate_obligation.rs @@ -108,7 +108,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> { match self.evaluate_obligation(obligation) { Ok(result) => result, Err(OverflowError::Canonical) => { - let mut selcx = SelectionContext::new(&self); + let mut selcx = SelectionContext::new(self); selcx.evaluate_root_obligation(obligation).unwrap_or_else(|r| match r { OverflowError::Canonical => { span_bug!( diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index 1529f736109..307a36761f2 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -634,7 +634,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let self_ty = placeholder_trait_predicate.self_ty(); let principal_trait_ref = match self_ty.kind() { - ty::Dynamic(ref data, ..) => { + ty::Dynamic(data, ..) => { if data.auto_traits().any(|did| did == obligation.predicate.def_id()) { debug!( "assemble_candidates_from_object_ty: matched builtin bound, \ @@ -759,10 +759,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { match (source.kind(), target.kind()) { // Trait+Kx+'a -> Trait+Ky+'b (upcasts). - ( - &ty::Dynamic(ref a_data, a_region, ty::Dyn), - &ty::Dynamic(ref b_data, b_region, ty::Dyn), - ) => { + (&ty::Dynamic(a_data, a_region, ty::Dyn), &ty::Dynamic(b_data, b_region, ty::Dyn)) => { // Upcast coercions permit several things: // // 1. Dropping auto traits, e.g., `Foo + Send` to `Foo` diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index 2ab3ecbd5a3..53b8b50252f 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -394,7 +394,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { obligation.recursion_depth + 1, obligation.param_env, trait_def_id, - &trait_ref.args, + trait_ref.args, obligation.predicate, ); @@ -455,7 +455,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { recursion_depth, param_env, impl_def_id, - &args.value, + args.value, parent_trait_pred, ); @@ -708,7 +708,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { obligation.recursion_depth, obligation.param_env, trait_def_id, - &args, + args, obligation.predicate, ); @@ -986,7 +986,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { Ok(match (source.kind(), target.kind()) { // Trait+Kx+'a -> Trait+Ky+'b (auto traits and lifetime subtyping). - (&ty::Dynamic(ref data_a, r_a, dyn_a), &ty::Dynamic(ref data_b, r_b, dyn_b)) + (&ty::Dynamic(data_a, r_a, dyn_a), &ty::Dynamic(data_b, r_b, dyn_b)) if dyn_a == dyn_b => { // See `assemble_candidates_for_unsizing` for more info. @@ -1031,7 +1031,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { } // `T` -> `Trait` - (_, &ty::Dynamic(ref data, r, ty::Dyn)) => { + (_, &ty::Dynamic(data, r, ty::Dyn)) => { let mut object_dids = data.auto_traits().chain(data.principal_def_id()); if let Some(did) = object_dids.find(|did| !tcx.check_is_object_safe(*did)) { return Err(TraitNotObjectSafe(did)); diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 1ed0da59b64..32e8d5b10ec 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -367,7 +367,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { debug_assert!(!self.infcx.next_trait_solver()); // Watch out for overflow. This intentionally bypasses (and does // not update) the cache. - self.check_recursion_limit(&stack.obligation, &stack.obligation)?; + self.check_recursion_limit(stack.obligation, stack.obligation)?; // Check the cache. Note that we freshen the trait-ref // separately rather than using `stack.fresh_trait_ref` -- @@ -416,7 +416,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let mut no_candidates_apply = true; for c in candidate_set.vec.iter() { - if self.evaluate_candidate(stack, &c)?.may_apply() { + if self.evaluate_candidate(stack, c)?.may_apply() { no_candidates_apply = false; break; } @@ -2218,7 +2218,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> { } } - ty::CoroutineWitness(def_id, ref args) => { + ty::CoroutineWitness(def_id, args) => { let hidden_types = bind_coroutine_hidden_types_above( self.infcx, def_id, @@ -2307,23 +2307,23 @@ impl<'tcx> SelectionContext<'_, 'tcx> { ty::Array(element_ty, _) | ty::Slice(element_ty) => t.rebind(vec![element_ty]), - ty::Tuple(ref tys) => { + ty::Tuple(tys) => { // (T1, ..., Tn) -- meets any bound that all of T1...Tn meet t.rebind(tys.iter().collect()) } - ty::Closure(_, ref args) => { + ty::Closure(_, args) => { let ty = self.infcx.shallow_resolve(args.as_closure().tupled_upvars_ty()); t.rebind(vec![ty]) } - ty::Coroutine(_, ref args, _) => { + ty::Coroutine(_, args, _) => { let ty = self.infcx.shallow_resolve(args.as_coroutine().tupled_upvars_ty()); let witness = args.as_coroutine().witness(); t.rebind([ty].into_iter().chain(iter::once(witness)).collect()) } - ty::CoroutineWitness(def_id, ref args) => { + ty::CoroutineWitness(def_id, args) => { bind_coroutine_hidden_types_above(self.infcx, def_id, args, t.bound_vars()) } diff --git a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs index efab29743f4..0f7a0ab17ef 100644 --- a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs @@ -107,7 +107,7 @@ pub fn translate_args_with_cause<'tcx>( param_env, source_impl, source_args, target_node ); let source_trait_ref = - infcx.tcx.impl_trait_ref(source_impl).unwrap().instantiate(infcx.tcx, &source_args); + infcx.tcx.impl_trait_ref(source_impl).unwrap().instantiate(infcx.tcx, source_args); // translate the Self and Param parts of the substitution, since those // vary across impls @@ -197,25 +197,22 @@ fn fulfill_implication<'tcx>( param_env, source_trait_ref, target_impl ); - let source_trait_ref = match traits::fully_normalize( - &infcx, - ObligationCause::dummy(), - param_env, - source_trait_ref, - ) { - Ok(source_trait_ref) => source_trait_ref, - Err(_errors) => { - infcx.tcx.sess.delay_span_bug( - infcx.tcx.def_span(source_impl), - format!("failed to fully normalize {source_trait_ref}"), - ); - source_trait_ref - } - }; + let source_trait_ref = + match traits::fully_normalize(infcx, ObligationCause::dummy(), param_env, source_trait_ref) + { + Ok(source_trait_ref) => source_trait_ref, + Err(_errors) => { + infcx.tcx.sess.delay_span_bug( + infcx.tcx.def_span(source_impl), + format!("failed to fully normalize {source_trait_ref}"), + ); + source_trait_ref + } + }; let source_trait = ImplSubject::Trait(source_trait_ref); - let selcx = &mut SelectionContext::new(&infcx); + let selcx = &mut SelectionContext::new(infcx); let target_args = infcx.fresh_args_for_item(DUMMY_SP, target_impl); let (target_trait, obligations) = util::impl_subject_and_oblig(selcx, param_env, target_impl, target_args, error_cause); diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index 9751cb60ed8..3a890d70d79 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -624,7 +624,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { // Note that we handle the len is implicitly checked while walking `arg`. } - ty::Tuple(ref tys) => { + ty::Tuple(tys) => { if let Some((_last, rest)) = tys.split_last() { for &elem in rest { self.require_sized(elem, traits::TupleElem); diff --git a/compiler/rustc_traits/src/evaluate_obligation.rs b/compiler/rustc_traits/src/evaluate_obligation.rs index 9fd550495aa..ce22da23fff 100644 --- a/compiler/rustc_traits/src/evaluate_obligation.rs +++ b/compiler/rustc_traits/src/evaluate_obligation.rs @@ -22,7 +22,7 @@ fn evaluate_obligation<'tcx>( debug!("evaluate_obligation: goal={:#?}", goal); let ParamEnvAnd { param_env, value: predicate } = goal; - let mut selcx = SelectionContext::with_query_mode(&infcx, TraitQueryMode::Canonical); + let mut selcx = SelectionContext::with_query_mode(infcx, TraitQueryMode::Canonical); let obligation = Obligation::new(tcx, ObligationCause::dummy(), param_env, predicate); selcx.evaluate_root_obligation(&obligation) diff --git a/compiler/rustc_ty_utils/src/assoc.rs b/compiler/rustc_ty_utils/src/assoc.rs index 0a34aef16ae..e29fed37f85 100644 --- a/compiler/rustc_ty_utils/src/assoc.rs +++ b/compiler/rustc_ty_utils/src/assoc.rs @@ -23,7 +23,7 @@ pub(crate) fn provide(providers: &mut Providers) { fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: LocalDefId) -> &[DefId] { let item = tcx.hir().expect_item(def_id); match item.kind { - hir::ItemKind::Trait(.., ref trait_item_refs) => { + hir::ItemKind::Trait(.., trait_item_refs) => { // We collect RPITITs for each trait method's return type and create a // corresponding associated item using associated_types_for_impl_traits_in_associated_fn // query. @@ -47,7 +47,7 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: LocalDefId) -> &[DefId] { ), ) } - hir::ItemKind::Impl(ref impl_) => { + hir::ItemKind::Impl(impl_) => { // We collect RPITITs for each trait method's return type, on the impl side too and // create a corresponding associated item using // associated_types_for_impl_traits_in_associated_fn query. @@ -98,7 +98,7 @@ fn associated_item(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AssocItem { let parent_def_id = tcx.hir().get_parent_item(id); let parent_item = tcx.hir().expect_item(parent_def_id.def_id); match parent_item.kind { - hir::ItemKind::Impl(ref impl_) => { + hir::ItemKind::Impl(impl_) => { if let Some(impl_item_ref) = impl_.items.iter().find(|i| i.id.owner_id.def_id == def_id) { let assoc_item = associated_item_from_impl_item_ref(impl_item_ref); @@ -107,7 +107,7 @@ fn associated_item(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AssocItem { } } - hir::ItemKind::Trait(.., ref trait_item_refs) => { + hir::ItemKind::Trait(.., trait_item_refs) => { if let Some(trait_item_ref) = trait_item_refs.iter().find(|i| i.id.owner_id.def_id == def_id) { diff --git a/compiler/rustc_ty_utils/src/consts.rs b/compiler/rustc_ty_utils/src/consts.rs index 9ced50c8e13..b521a5c1145 100644 --- a/compiler/rustc_ty_utils/src/consts.rs +++ b/compiler/rustc_ty_utils/src/consts.rs @@ -375,7 +375,7 @@ impl<'a, 'tcx> IsThirPolymorphic<'a, 'tcx> { impl<'a, 'tcx> visit::Visitor<'a, 'tcx> for IsThirPolymorphic<'a, 'tcx> { fn thir(&self) -> &'a thir::Thir<'tcx> { - &self.thir + self.thir } #[instrument(skip(self), level = "debug")] diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index b09566e1668..826c69ee716 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -320,7 +320,7 @@ fn layout_of_uncached<'tcx>( ty::Coroutine(def_id, args, _) => coroutine_layout(cx, ty, def_id, args)?, - ty::Closure(_, ref args) => { + ty::Closure(_, args) => { let tys = args.as_closure().upvar_tys(); univariant( &tys.iter() @@ -728,7 +728,7 @@ fn coroutine_layout<'tcx>( let Some(info) = tcx.coroutine_layout(def_id) else { return Err(error(cx, LayoutError::Unknown(ty))); }; - let (ineligible_locals, assignments) = coroutine_saved_local_eligibility(&info); + let (ineligible_locals, assignments) = coroutine_saved_local_eligibility(info); // Build a prefix layout, including "promoting" all ineligible // locals as part of the prefix. We compute the layout of all of diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index b7c75da7301..56e84b6015d 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -25,7 +25,7 @@ fn sized_constraint_for_ty<'tcx>( vec![ty] } - Tuple(ref tys) => match tys.last() { + Tuple(tys) => match tys.last() { None => vec![], Some(&ty) => sized_constraint_for_ty(tcx, adtdef, ty), }, @@ -285,7 +285,7 @@ fn issue33140_self_ty(tcx: TyCtxt<'_>, def_id: DefId) -> Option data.principal().is_none(), + ty::Dynamic(data, re, _) if re.is_static() => data.principal().is_none(), _ => false, }; diff --git a/compiler/stable_mir/src/mir/pretty.rs b/compiler/stable_mir/src/mir/pretty.rs index e52c3360ce4..c7422d66c0e 100644 --- a/compiler/stable_mir/src/mir/pretty.rs +++ b/compiler/stable_mir/src/mir/pretty.rs @@ -93,7 +93,7 @@ pub fn pretty_rvalue(rval: &Rvalue) -> String { match rval { Rvalue::AddressOf(muta, addr) => { pretty.push_str("&raw "); - pretty.push_str(&ret_mutability(&muta)); + pretty.push_str(&ret_mutability(muta)); pretty.push_str(format!("(*_{})", addr.local).as_str()); } Rvalue::Aggregate(aggregatekind, operands) => { @@ -155,7 +155,7 @@ pub fn pretty_rvalue(rval: &Rvalue) -> String { } Rvalue::NullaryOp(nul, ty) => { pretty.push_str(format!("{:#?}", nul).as_str()); - pretty.push_str(&&pretty_ty(ty.kind())); + pretty.push_str(&pretty_ty(ty.kind())); pretty.push_str(" "); } Rvalue::UnaryOp(un, op) => { diff --git a/compiler/stable_mir/src/mir/visit.rs b/compiler/stable_mir/src/mir/visit.rs index 40bedd67352..bc2d57eaa24 100644 --- a/compiler/stable_mir/src/mir/visit.rs +++ b/compiler/stable_mir/src/mir/visit.rs @@ -224,7 +224,7 @@ pub trait MirVisitor { fn super_terminator(&mut self, term: &Terminator, location: Location) { let Terminator { kind, span } = term; - self.visit_span(&span); + self.visit_span(span); match kind { TerminatorKind::Goto { .. } | TerminatorKind::Resume diff --git a/compiler/stable_mir/src/ty.rs b/compiler/stable_mir/src/ty.rs index f0b11dce9aa..abe6f8ec12f 100644 --- a/compiler/stable_mir/src/ty.rs +++ b/compiler/stable_mir/src/ty.rs @@ -138,7 +138,7 @@ impl Span { /// Return lines that corespond to this `Span` pub fn get_lines(&self) -> LineInfo { - with(|c| c.get_lines(&self)) + with(|c| c.get_lines(self)) } }