From 25e854a5108b116fc3d4b9e52a99dae011c25dc7 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 6 Jun 2024 17:00:09 +1000 Subject: [PATCH] Change the return type of `Ty::kind` from `&TyKind` to `TyKind`. This is valid because `TyKind` impls `Copy`, and makes `Ty` consistent with `Predicate` and `Region`, both of which have `kind` methods that return a non-reference. The change removes more than one thousand `&` and `*` sigils, while requiring the addition of just five! It's clearly moving with the grain of the existing code. Almost all of the removed sigils fit one of the following three patterns. - Remove the dereference in the match expression: `match *ty.kind() { ... }` -> `match ty.kind() { ... }` - Remove the dereference in the match pattern: `match ty.kind() { &ty::Foo(foo) => { ... foo ... }` -> `match ty.kind() { ty::Foo(foo) => { ... foo ... }` - Remove the derefernce in the match arm: `match ty.kind() { ty::Foo(foo) => { ... *foo ... }` -> `match ty.kind() { ty::Foo(foo) => { ... foo ... }` A couple of other methods had their signatures changed. - `TypeErrCtxt::cmp_fn_sig`: `&` removed from two args. - `EncodableWithShorthand::variant`: `&` removed from return type. --- .../src/diagnostics/conflict_errors.rs | 6 +- .../src/diagnostics/explain_borrow.rs | 57 +++++++++--------- .../rustc_borrowck/src/diagnostics/mod.rs | 12 ++-- .../src/diagnostics/mutability_errors.rs | 6 +- .../src/diagnostics/region_errors.rs | 21 ++++--- .../src/diagnostics/region_name.rs | 8 +-- compiler/rustc_borrowck/src/lib.rs | 2 +- .../rustc_borrowck/src/region_infer/mod.rs | 2 +- compiler/rustc_borrowck/src/type_check/mod.rs | 26 ++++---- .../src/type_check/relate_tys.rs | 16 ++--- .../rustc_borrowck/src/universal_regions.rs | 4 +- .../rustc_codegen_cranelift/src/abi/mod.rs | 6 +- compiler/rustc_codegen_cranelift/src/base.rs | 12 ++-- .../rustc_codegen_cranelift/src/common.rs | 4 +- .../src/debuginfo/types.rs | 6 +- .../rustc_codegen_cranelift/src/global_asm.rs | 2 +- .../rustc_codegen_cranelift/src/inline_asm.rs | 4 +- .../rustc_codegen_cranelift/src/unsize.rs | 10 ++-- .../src/value_and_place.rs | 24 ++++---- .../rustc_codegen_gcc/src/intrinsic/mod.rs | 2 +- .../rustc_codegen_gcc/src/intrinsic/simd.rs | 20 +++---- compiler/rustc_codegen_gcc/src/type_of.rs | 6 +- compiler/rustc_codegen_llvm/src/builder.rs | 2 +- .../src/debuginfo/metadata.rs | 17 +++--- .../src/debuginfo/metadata/enums/cpp_like.rs | 4 +- .../src/debuginfo/metadata/enums/mod.rs | 2 +- .../src/debuginfo/metadata/enums/native.rs | 4 +- .../rustc_codegen_llvm/src/debuginfo/mod.rs | 4 +- .../rustc_codegen_llvm/src/debuginfo/utils.rs | 2 +- compiler/rustc_codegen_llvm/src/intrinsic.rs | 34 +++++------ compiler/rustc_codegen_llvm/src/type_of.rs | 4 +- compiler/rustc_codegen_ssa/src/base.rs | 14 ++--- .../src/debuginfo/type_names.rs | 4 +- compiler/rustc_codegen_ssa/src/mir/block.rs | 4 +- .../rustc_codegen_ssa/src/mir/intrinsic.rs | 2 +- compiler/rustc_codegen_ssa/src/mir/rvalue.rs | 4 +- compiler/rustc_codegen_ssa/src/mono_item.rs | 2 +- .../src/check_consts/check.rs | 2 +- .../rustc_const_eval/src/check_consts/ops.rs | 6 +- .../src/const_eval/machine.rs | 2 +- .../src/const_eval/valtrees.rs | 6 +- .../rustc_const_eval/src/interpret/cast.rs | 12 ++-- .../src/interpret/discriminant.rs | 2 +- .../src/interpret/eval_context.rs | 2 +- .../src/interpret/intrinsics.rs | 2 +- .../src/interpret/projection.rs | 2 +- .../src/interpret/terminator.rs | 14 ++--- .../rustc_const_eval/src/interpret/util.rs | 2 +- .../src/interpret/validity.rs | 6 +- .../rustc_const_eval/src/interpret/visitor.rs | 2 +- .../rustc_const_eval/src/util/type_name.rs | 2 +- .../rustc_hir_analysis/src/check/check.rs | 10 ++-- .../src/check/compare_impl_item.rs | 4 +- .../src/check/compare_impl_item/refine.rs | 6 +- .../src/check/intrinsicck.rs | 6 +- compiler/rustc_hir_analysis/src/check/mod.rs | 2 +- .../rustc_hir_analysis/src/check/wfcheck.rs | 10 ++-- .../src/coherence/builtin.rs | 16 +++-- .../src/coherence/inherent_impls.rs | 6 +- .../src/coherence/orphan.rs | 2 +- compiler/rustc_hir_analysis/src/collect.rs | 4 +- .../src/constrained_generic_params.rs | 2 +- .../src/hir_ty_lowering/bounds.rs | 4 +- .../src/hir_ty_lowering/errors.rs | 2 +- .../src/outlives/implicit_infer.rs | 2 +- .../src/variance/constraints.rs | 2 +- .../rustc_hir_analysis/src/variance/mod.rs | 4 +- compiler/rustc_hir_typeck/src/_match.rs | 2 +- compiler/rustc_hir_typeck/src/autoderef.rs | 2 +- compiler/rustc_hir_typeck/src/callee.rs | 10 ++-- compiler/rustc_hir_typeck/src/cast.rs | 18 +++--- compiler/rustc_hir_typeck/src/closure.rs | 6 +- compiler/rustc_hir_typeck/src/coercion.rs | 22 +++---- compiler/rustc_hir_typeck/src/expr.rs | 24 ++++---- .../rustc_hir_typeck/src/expr_use_visitor.rs | 2 +- .../src/fn_ctxt/adjust_fulfillment_errors.rs | 8 +-- .../rustc_hir_typeck/src/fn_ctxt/checks.rs | 6 +- .../src/fn_ctxt/inspect_obligations.rs | 2 +- compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs | 4 +- .../src/fn_ctxt/suggestions.rs | 32 +++++----- compiler/rustc_hir_typeck/src/intrinsicck.rs | 4 +- .../rustc_hir_typeck/src/method/confirm.rs | 4 +- compiler/rustc_hir_typeck/src/method/mod.rs | 2 +- compiler/rustc_hir_typeck/src/method/probe.rs | 12 ++-- .../rustc_hir_typeck/src/method/suggest.rs | 19 +++--- compiler/rustc_hir_typeck/src/op.rs | 32 +++++----- compiler/rustc_hir_typeck/src/pat.rs | 16 ++--- compiler/rustc_hir_typeck/src/place_op.rs | 14 ++--- compiler/rustc_hir_typeck/src/upvar.rs | 4 +- compiler/rustc_hir_typeck/src/writeback.rs | 2 +- .../src/infer/canonical/canonicalizer.rs | 2 +- .../src/infer/canonical/query_response.rs | 2 +- .../src/infer/error_reporting/mod.rs | 56 +++++++++--------- .../infer/error_reporting/need_type_info.rs | 6 +- .../infer/error_reporting/note_and_explain.rs | 8 +-- .../infer/error_reporting/sub_relations.rs | 2 +- .../src/infer/error_reporting/suggest.rs | 6 +- compiler/rustc_infer/src/infer/freshen.rs | 2 +- compiler/rustc_infer/src/infer/mod.rs | 10 ++-- .../rustc_infer/src/infer/opaque_types/mod.rs | 10 ++-- .../src/infer/outlives/components.rs | 4 +- .../src/infer/outlives/for_liveness.rs | 2 +- .../src/infer/outlives/obligations.rs | 2 +- .../rustc_infer/src/infer/outlives/verify.rs | 2 +- .../rustc_infer/src/infer/relate/combine.rs | 20 +++---- .../src/infer/relate/generalize.rs | 6 +- .../rustc_infer/src/infer/relate/lattice.rs | 12 ++-- .../src/infer/relate/type_relating.rs | 16 ++--- compiler/rustc_infer/src/infer/resolve.rs | 2 +- .../rustc_infer/src/infer/snapshot/fudge.rs | 2 +- .../rustc_infer/src/infer/type_variable.rs | 2 +- compiler/rustc_lint/src/builtin.rs | 8 +-- .../src/for_loops_over_fallibles.rs | 6 +- compiler/rustc_lint/src/foreign_modules.rs | 12 ++-- .../rustc_lint/src/impl_trait_overcaptures.rs | 6 +- compiler/rustc_lint/src/internal.rs | 4 +- compiler/rustc_lint/src/map_unit_fn.rs | 10 +--- compiler/rustc_lint/src/non_fmt_panic.rs | 2 +- .../src/opaque_hidden_inferred_bound.rs | 6 +- compiler/rustc_lint/src/reference_casting.rs | 4 +- compiler/rustc_lint/src/shadowed_into_iter.rs | 4 +- compiler/rustc_lint/src/types.rs | 14 ++--- compiler/rustc_lint/src/unused.rs | 4 +- compiler/rustc_middle/src/mir/pretty.rs | 10 ++-- compiler/rustc_middle/src/mir/statement.rs | 2 +- compiler/rustc_middle/src/mir/tcx.rs | 4 +- compiler/rustc_middle/src/query/keys.rs | 2 +- compiler/rustc_middle/src/thir.rs | 4 +- compiler/rustc_middle/src/ty/_match.rs | 10 ++-- compiler/rustc_middle/src/ty/cast.rs | 2 +- compiler/rustc_middle/src/ty/codec.rs | 10 ++-- .../rustc_middle/src/ty/consts/valtree.rs | 4 +- compiler/rustc_middle/src/ty/context.rs | 2 +- compiler/rustc_middle/src/ty/diagnostics.rs | 8 +-- compiler/rustc_middle/src/ty/error.rs | 4 +- compiler/rustc_middle/src/ty/fast_reject.rs | 18 +++--- compiler/rustc_middle/src/ty/fold.rs | 2 +- .../rustc_middle/src/ty/inhabitedness/mod.rs | 2 +- compiler/rustc_middle/src/ty/instance.rs | 6 +- compiler/rustc_middle/src/ty/layout.rs | 10 ++-- compiler/rustc_middle/src/ty/mod.rs | 6 +- compiler/rustc_middle/src/ty/opaque_types.rs | 2 +- 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 | 50 ++++++++-------- .../rustc_middle/src/ty/structural_impls.rs | 6 +- compiler/rustc_middle/src/ty/sty.rs | 35 ++++++----- .../rustc_middle/src/ty/typeck_results.rs | 2 +- compiler/rustc_middle/src/ty/util.rs | 26 ++++---- compiler/rustc_middle/src/ty/walk.rs | 2 +- .../rustc_middle/src/util/find_self_call.rs | 2 +- .../rustc_mir_build/src/build/custom/parse.rs | 2 +- .../src/build/expr/as_place.rs | 2 +- .../rustc_mir_build/src/build/matches/test.rs | 4 +- compiler/rustc_mir_build/src/build/mod.rs | 4 +- .../rustc_mir_build/src/check_unsafety.rs | 4 +- compiler/rustc_mir_build/src/lints.rs | 4 +- compiler/rustc_mir_build/src/thir/cx/expr.rs | 12 ++-- compiler/rustc_mir_build/src/thir/cx/mod.rs | 2 +- .../src/thir/pattern/check_match.rs | 4 +- .../src/thir/pattern/const_to_pat.rs | 14 ++--- .../rustc_mir_build/src/thir/pattern/mod.rs | 10 ++-- .../rustc_mir_dataflow/src/elaborate_drops.rs | 6 +- .../src/impls/initialized.rs | 2 +- compiler/rustc_mir_dataflow/src/rustc_peek.rs | 2 +- .../src/abort_unwinding_calls.rs | 2 +- compiler/rustc_mir_transform/src/add_retag.rs | 2 +- .../src/check_alignment.rs | 2 +- compiler/rustc_mir_transform/src/coroutine.rs | 18 +++--- .../src/coroutine/by_move_body.rs | 4 +- .../rustc_mir_transform/src/cost_checker.rs | 2 +- .../src/dataflow_const_prop.rs | 4 +- .../src/ffi_unwind_calls.rs | 2 +- .../src/function_item_references.rs | 4 +- compiler/rustc_mir_transform/src/gvn.rs | 12 +--- compiler/rustc_mir_transform/src/inline.rs | 4 +- .../rustc_mir_transform/src/inline/cycle.rs | 6 +- .../rustc_mir_transform/src/instsimplify.rs | 6 +- .../rustc_mir_transform/src/large_enums.rs | 4 +- compiler/rustc_mir_transform/src/lib.rs | 2 +- .../src/lower_intrinsics.rs | 4 +- .../src/lower_slice_len.rs | 2 +- .../src/normalize_array_len.rs | 2 +- .../rustc_mir_transform/src/promote_consts.rs | 4 +- compiler/rustc_mir_transform/src/shim.rs | 12 ++-- .../src/shim/async_destructor_ctor.rs | 8 +-- compiler/rustc_mir_transform/src/validate.rs | 6 +- compiler/rustc_monomorphize/src/collector.rs | 10 ++-- .../src/collector/move_check.rs | 2 +- .../rustc_monomorphize/src/polymorphize.rs | 2 +- compiler/rustc_passes/src/abi_test.rs | 12 ++-- compiler/rustc_passes/src/dead.rs | 4 +- compiler/rustc_pattern_analysis/src/rustc.rs | 38 ++++++------ compiler/rustc_privacy/src/lib.rs | 2 +- .../src/cfi/typeid/itanium_cxx_abi/encode.rs | 36 +++++------ .../cfi/typeid/itanium_cxx_abi/transform.rs | 2 +- compiler/rustc_symbol_mangling/src/legacy.rs | 2 +- compiler/rustc_symbol_mangling/src/v0.rs | 7 +-- .../src/solve/assembly/mod.rs | 6 +- .../src/solve/assembly/structural_traits.rs | 12 ++-- .../src/solve/eval_ctxt/canonical.rs | 2 +- .../src/solve/eval_ctxt/mod.rs | 6 +- .../src/solve/normalize.rs | 4 +- .../src/solve/normalizes_to/mod.rs | 14 ++--- .../src/solve/trait_goals.rs | 24 ++++---- .../src/traits/auto_trait.rs | 2 +- .../src/traits/coherence.rs | 2 +- .../src/traits/error_reporting/suggestions.rs | 59 +++++++++---------- .../error_reporting/type_err_ctxt_ext.rs | 14 ++--- .../rustc_trait_selection/src/traits/misc.rs | 4 +- .../rustc_trait_selection/src/traits/mod.rs | 2 +- .../src/traits/normalize.rs | 2 +- .../src/traits/project.rs | 10 ++-- .../src/traits/query/dropck_outlives.rs | 4 +- .../src/traits/query/normalize.rs | 2 +- .../src/traits/select/candidate_assembly.rs | 34 +++++------ .../src/traits/select/confirmation.rs | 32 +++++----- .../src/traits/select/mod.rs | 12 ++-- .../src/traits/structural_match.rs | 2 +- .../src/traits/structural_normalize.rs | 2 +- .../rustc_trait_selection/src/traits/util.rs | 4 +- .../rustc_trait_selection/src/traits/wf.rs | 2 +- compiler/rustc_transmute/src/layout/tree.rs | 18 ++---- compiler/rustc_ty_utils/src/abi.rs | 12 ++-- compiler/rustc_ty_utils/src/consts.rs | 4 +- compiler/rustc_ty_utils/src/instance.rs | 8 +-- compiler/rustc_ty_utils/src/layout.rs | 6 +- compiler/rustc_ty_utils/src/needs_drop.rs | 4 +- compiler/rustc_ty_utils/src/opaque_types.rs | 4 +- .../rustc_ty_utils/src/representability.rs | 4 +- compiler/rustc_ty_utils/src/ty.rs | 4 +- src/librustdoc/clean/mod.rs | 6 +- src/librustdoc/clean/utils.rs | 6 +- .../passes/collect_intra_doc_links.rs | 2 +- src/librustdoc/scrape_examples.rs | 2 +- .../clippy_lints/src/borrow_deref_ref.rs | 2 +- .../src/casts/cast_possible_truncation.rs | 6 +- .../src/casts/cast_precision_loss.rs | 2 +- .../src/casts/cast_ptr_alignment.rs | 4 +- .../clippy_lints/src/casts/cast_sign_loss.rs | 4 +- .../src/casts/cast_slice_different_sizes.rs | 2 +- .../clippy_lints/src/casts/char_lit_as_u8.rs | 2 +- .../src/casts/fn_to_numeric_cast.rs | 2 +- .../src/casts/ptr_cast_constness.rs | 2 +- src/tools/clippy/clippy_lints/src/default.rs | 2 +- .../src/default_numeric_fallback.rs | 4 +- .../clippy/clippy_lints/src/dereference.rs | 12 ++-- .../clippy_lints/src/derivable_impls.rs | 4 +- src/tools/clippy/clippy_lints/src/derive.rs | 4 +- .../clippy/clippy_lints/src/eta_reduction.rs | 12 ++-- .../clippy/clippy_lints/src/float_literal.rs | 2 +- .../src/from_raw_with_void_ptr.rs | 2 +- .../clippy_lints/src/functions/must_use.rs | 2 +- .../src/functions/not_unsafe_ptr_arg_deref.rs | 2 +- .../clippy_lints/src/functions/result.rs | 2 +- .../clippy_lints/src/future_not_send.rs | 2 +- .../src/implied_bounds_in_impls.rs | 2 +- .../clippy_lints/src/index_refutable_slice.rs | 2 +- .../clippy_lints/src/indexing_slicing.rs | 2 +- .../src/iter_without_into_iter.rs | 2 +- .../clippy_lints/src/large_const_arrays.rs | 2 +- .../clippy_lints/src/large_enum_variant.rs | 2 +- .../clippy_lints/src/large_stack_arrays.rs | 2 +- src/tools/clippy/clippy_lints/src/len_zero.rs | 8 +-- .../src/loops/explicit_iter_loop.rs | 6 +- .../clippy_lints/src/loops/for_kv_map.rs | 2 +- .../clippy_lints/src/loops/manual_memcpy.rs | 4 +- .../src/loops/needless_range_loop.rs | 4 +- .../src/loops/unused_enumerate_index.rs | 2 +- .../src/manual_slice_size_calculation.rs | 2 +- .../clippy/clippy_lints/src/map_unit_fn.rs | 2 +- .../clippy_lints/src/matches/match_as_ref.rs | 2 +- .../clippy_lints/src/matches/match_bool.rs | 2 +- .../src/matches/match_str_case_mismatch.rs | 2 +- .../matches/significant_drop_in_scrutinee.rs | 6 +- .../clippy_lints/src/matches/single_match.rs | 2 +- .../clippy_lints/src/methods/bytecount.rs | 2 +- .../clippy_lints/src/methods/chars_cmp.rs | 2 +- .../src/methods/cloned_instead_of_copied.rs | 2 +- .../src/methods/iter_overeager_cloned.rs | 2 +- .../clippy_lints/src/methods/map_clone.rs | 6 +- .../clippy/clippy_lints/src/methods/mod.rs | 2 +- .../src/methods/needless_collect.rs | 6 +- .../src/methods/unnecessary_join.rs | 2 +- .../src/methods/unnecessary_to_owned.rs | 4 +- .../clippy/clippy_lints/src/methods/utils.rs | 4 +- .../clippy_lints/src/methods/zst_offset.rs | 2 +- .../src/mixed_read_write_in_expression.rs | 2 +- .../src/multiple_unsafe_ops_per_block.rs | 2 +- .../clippy/clippy_lints/src/mutex_atomic.rs | 2 +- .../src/needless_borrows_for_generic_args.rs | 6 +- .../clippy/clippy_lints/src/non_copy_const.rs | 2 +- .../src/non_send_fields_in_send_ty.rs | 2 +- .../src/only_used_in_recursion.rs | 2 +- .../operators/absurd_extreme_comparisons.rs | 10 ++-- .../clippy_lints/src/operators/identity_op.rs | 2 +- .../src/operators/modulo_arithmetic.rs | 2 +- .../clippy_lints/src/operators/modulo_one.rs | 2 +- .../clippy_lints/src/pass_by_ref_or_value.rs | 2 +- .../clippy_lints/src/pattern_type_mismatch.rs | 2 +- src/tools/clippy/clippy_lints/src/ptr.rs | 8 +-- .../clippy_lints/src/rc_clone_in_vec_init.rs | 2 +- .../clippy_lints/src/redundant_clone.rs | 2 +- .../src/significant_drop_tightening.rs | 4 +- .../src/size_of_in_element_count.rs | 2 +- .../clippy_lints/src/to_digit_is_some.rs | 2 +- .../src/transmute/crosspointer_transmute.rs | 2 +- .../src/transmute/transmute_ref_to_ref.rs | 4 +- .../src/transmute/transmute_undefined_repr.rs | 16 ++--- .../src/transmute/useless_transmute.rs | 2 +- .../src/tuple_array_conversions.rs | 5 +- .../src/unconditional_recursion.rs | 6 +- .../src/unit_types/let_unit_value.rs | 2 +- src/tools/clippy/clippy_lints/src/use_self.rs | 2 +- src/tools/clippy/clippy_utils/src/consts.rs | 20 +++---- src/tools/clippy/clippy_utils/src/lib.rs | 8 +-- .../clippy_utils/src/qualify_min_const_fn.rs | 4 +- src/tools/clippy/clippy_utils/src/ty.rs | 30 +++++----- .../clippy_utils/src/ty/type_certainty/mod.rs | 2 +- src/tools/clippy/clippy_utils/src/visitors.rs | 2 +- .../src/borrow_tracker/tree_borrows/mod.rs | 4 +- src/tools/miri/src/intrinsics/simd.rs | 4 +- 322 files changed, 1096 insertions(+), 1134 deletions(-) diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 821a903665479..096e52c4a5272 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -721,7 +721,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // borrowing the type, since `&mut F: FnMut` iff `F: FnMut` and similarly for `Fn`. // These types seem reasonably opaque enough that they could be instantiated with their // borrowed variants in a function body when we see a move error. - let borrow_level = match *ty.kind() { + let borrow_level = match ty.kind() { ty::Param(_) => tcx .explicit_predicates_of(self.mir_def_id().to_def_id()) .predicates @@ -1210,7 +1210,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } else if let ty::Param(param) = ty.kind() && let Some(_clone_trait_def) = self.infcx.tcx.lang_items().clone_trait() && let generics = self.infcx.tcx.generics_of(self.mir_def_id()) - && let generic_param = generics.type_param(*param, self.infcx.tcx) + && let generic_param = generics.type_param(param, self.infcx.tcx) && let param_span = self.infcx.tcx.def_span(generic_param.def_id) && if let Some(UseSpans::FnSelfUse { kind, .. }) = use_spans && let CallKind::FnCall { fn_trait_id, self_ty } = kind @@ -1358,7 +1358,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { .into_iter() .map(|err| match err.obligation.predicate.kind().skip_binder() { PredicateKind::Clause(ty::ClauseKind::Trait(predicate)) => { - match *predicate.self_ty().kind() { + match predicate.self_ty().kind() { ty::Param(param_ty) => Ok(( generics.type_param(param_ty, tcx), predicate.trait_ref.print_trait_sugared().to_string(), diff --git a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs index e3ad92a5b2bf5..d98acadaab3de 100644 --- a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs +++ b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs @@ -317,40 +317,37 @@ impl<'tcx> BorrowExplanation<'tcx> { let mut has_dyn = false; let mut failed = false; - let elaborated_args = - std::iter::zip(*args, &generics.own_params).map(|(arg, param)| { - if let Some(ty::Dynamic(obj, _, ty::Dyn)) = arg.as_type().map(Ty::kind) { - let default = tcx.object_lifetime_default(param.def_id); - - let re_static = tcx.lifetimes.re_static; - - let implied_region = match default { - // This is not entirely precise. - ObjectLifetimeDefault::Empty => re_static, - ObjectLifetimeDefault::Ambiguous => { + let elaborated_args = std::iter::zip(args, &generics.own_params).map(|(arg, param)| { + if let Some(ty::Dynamic(obj, _, ty::Dyn)) = arg.as_type().map(Ty::kind) { + let default = tcx.object_lifetime_default(param.def_id); + + let re_static = tcx.lifetimes.re_static; + + let implied_region = match default { + // This is not entirely precise. + ObjectLifetimeDefault::Empty => re_static, + ObjectLifetimeDefault::Ambiguous => { + failed = true; + re_static + } + ObjectLifetimeDefault::Param(param_def_id) => { + let index = generics.param_def_id_to_index[¶m_def_id] as usize; + args.get(index).and_then(|arg| arg.as_region()).unwrap_or_else(|| { failed = true; re_static - } - ObjectLifetimeDefault::Param(param_def_id) => { - let index = generics.param_def_id_to_index[¶m_def_id] as usize; - args.get(index).and_then(|arg| arg.as_region()).unwrap_or_else( - || { - failed = true; - re_static - }, - ) - } - ObjectLifetimeDefault::Static => re_static, - }; + }) + } + ObjectLifetimeDefault::Static => re_static, + }; - has_dyn = true; + has_dyn = true; - Ty::new_dynamic(tcx, obj, implied_region, ty::Dyn).into() - } else { - arg - } - }); - let elaborated_ty = Ty::new_adt(tcx, *def, tcx.mk_args_from_iter(elaborated_args)); + Ty::new_dynamic(tcx, obj, implied_region, ty::Dyn).into() + } else { + arg + } + }); + let elaborated_ty = Ty::new_adt(tcx, def, tcx.mk_args_from_iter(elaborated_args)); if has_dyn && !failed { err.note(format!( diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index 1eb67ea367c2d..9c27d719e76d1 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -114,7 +114,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { .. } = &terminator.kind { - if let ty::FnDef(id, _) = *const_.ty().kind() { + if let ty::FnDef(id, _) = const_.ty().kind() { debug!("add_moved_or_invoked_closure_note: id={:?}", id); if Some(self.infcx.tcx.parent(id)) == self.infcx.tcx.lang_items().fn_once_trait() { let closure = match args.first() { @@ -356,7 +356,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // If the type is a box, the field is described from the boxed type self.describe_field_from_ty(ty.boxed_ty(), field, variant_index, including_tuple_field) } else { - match *ty.kind() { + match ty.kind() { ty::Adt(def, _) => { let variant = if let Some(idx) = variant_index { assert!(def.is_enum()); @@ -467,7 +467,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // this by hooking into the pretty printer and telling it to label the // lifetimes without names with the value `'0`. if let ty::Ref(region, ..) = ty.kind() { - match **region { + match *region { ty::ReBound(_, ty::BoundRegion { kind: br, .. }) | ty::RePlaceholder(ty::PlaceholderRegion { bound: ty::BoundRegion { kind: br, .. }, @@ -487,7 +487,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let mut printer = ty::print::FmtPrinter::new(self.infcx.tcx, Namespace::TypeNS); let region = if let ty::Ref(region, ..) = ty.kind() { - match **region { + match *region { ty::ReBound(_, ty::BoundRegion { kind: br, .. }) | ty::RePlaceholder(ty::PlaceholderRegion { bound: ty::BoundRegion { kind: br, .. }, @@ -763,7 +763,7 @@ impl<'tcx> BorrowedContentSource<'tcx> { } fn from_call(func: Ty<'tcx>, tcx: TyCtxt<'tcx>) -> Option { - match *func.kind() { + match func.kind() { ty::FnDef(def_id, args) => { let trait_id = tcx.trait_of_item(def_id)?; @@ -1073,7 +1073,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // LL | blk(); // | ----- this value implements `FnOnce`, which causes it to be moved when called // ``` - if let ty::Param(param_ty) = *self_ty.kind() + if let ty::Param(param_ty) = self_ty.kind() && let generics = self.infcx.tcx.generics_of(self.mir_def_id()) && let param = generics.type_param(param_ty, self.infcx.tcx) && let Some(hir_generics) = self diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index df1a1411cf5f6..cfd72703ea456 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -377,7 +377,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { if suggest { self.construct_mut_suggestion_for_local_binding_patterns(&mut err, local); let tcx = self.infcx.tcx; - if let ty::Closure(id, _) = *the_place_err.ty(self.body, tcx).ty.kind() { + if let ty::Closure(id, _) = the_place_err.ty(self.body, tcx).ty.kind() { self.show_mutating_upvar(tcx, id.expect_local(), the_place_err, &mut err); } } @@ -431,7 +431,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { let tcx = self.infcx.tcx; if let ty::Ref(_, ty, Mutability::Mut) = the_place_err.ty(self.body, tcx).ty.kind() - && let ty::Closure(id, _) = *ty.kind() + && let ty::Closure(id, _) = ty.kind() { self.show_mutating_upvar(tcx, id.expect_local(), the_place_err, &mut err); } @@ -950,7 +950,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { if let Some(ty::FnDef(def_id, _)) = tables.node_type_opt(func.hir_id).as_ref().map(|ty| ty.kind()) { - let arg = match hir.get_if_local(*def_id) { + let arg = match hir.get_if_local(def_id) { Some( hir::Node::Item(hir::Item { ident, kind: hir::ItemKind::Fn(sig, ..), .. diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index 15a8764aab3c4..e1d84b0e57747 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -509,14 +509,14 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { ty::VarianceDiagInfo::Invariant { ty, param_index } => { let (desc, note) = match ty.kind() { ty::RawPtr(ty, mutbl) => { - assert_eq!(*mutbl, rustc_hir::Mutability::Mut); + assert_eq!(mutbl, rustc_hir::Mutability::Mut); ( format!("a mutable pointer to `{}`", ty), "mutable pointers are invariant over their type parameter".to_string(), ) } ty::Ref(_, inner_ty, mutbl) => { - assert_eq!(*mutbl, rustc_hir::Mutability::Mut); + assert_eq!(mutbl, rustc_hir::Mutability::Mut); ( format!("a mutable reference to `{inner_ty}`"), "mutable references are invariant over their type parameter" @@ -527,7 +527,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { let generic_arg = args[param_index as usize]; let identity_args = GenericArgs::identity_for_item(self.infcx.tcx, adt.did()); - let base_ty = Ty::new_adt(self.infcx.tcx, *adt, identity_args); + let base_ty = Ty::new_adt(self.infcx.tcx, adt, identity_args); let base_generic_arg = identity_args[param_index as usize]; let adt_desc = adt.descr(); @@ -540,8 +540,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { (desc, note) } ty::FnDef(def_id, _) => { - let name = self.infcx.tcx.item_name(*def_id); - let identity_args = GenericArgs::identity_for_item(self.infcx.tcx, *def_id); + let name = self.infcx.tcx.item_name(def_id); + let identity_args = GenericArgs::identity_for_item(self.infcx.tcx, def_id); let desc = format!("a function pointer to `{name}`"); let note = format!( "the function `{name}` is invariant over the parameter `{}`", @@ -593,7 +593,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { let ErrorConstraintInfo { outlived_fr, span, .. } = errci; let mut output_ty = self.regioncx.universal_regions().unnormalized_output_ty; - if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = *output_ty.kind() { + if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = output_ty.kind() { output_ty = self.infcx.tcx.type_of(def_id).instantiate_identity() }; @@ -602,7 +602,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { let err = FnMutError { span: *span, ty_err: match output_ty.kind() { - ty::Coroutine(def, ..) if self.infcx.tcx.coroutine_is_async(*def) => { + ty::Coroutine(def, ..) if self.infcx.tcx.coroutine_is_async(def) => { FnMutReturnTypeErr::ReturnAsyncBlock { span: *span } } _ if output_ty.contains_closure() => { @@ -952,7 +952,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { if let Ok(Some(instance)) = ty::Instance::resolve( tcx, self.param_env, - *fn_did, + fn_did, self.infcx.resolve_vars_if_possible(args), ) { instance @@ -1070,8 +1070,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { else { return; }; - let ty::Closure(_, args) = *tcx.type_of(closure_def_id).instantiate_identity().kind() - else { + let ty::Closure(_, args) = tcx.type_of(closure_def_id).instantiate_identity().kind() else { return; }; let args = args.as_closure(); @@ -1092,7 +1091,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { let liberated_sig = tcx.liberate_late_bound_regions(closure_def_id.to_def_id(), args.sig()); let mut peeled_ty = liberated_sig.output(); let mut count = 0; - while let ty::Ref(_, ref_ty, _) = *peeled_ty.kind() { + while let ty::Ref(_, ref_ty, _) = peeled_ty.kind() { peeled_ty = ref_ty; count += 1; } diff --git a/compiler/rustc_borrowck/src/diagnostics/region_name.rs b/compiler/rustc_borrowck/src/diagnostics/region_name.rs index 2cf548e28b18a..5d7a49caef238 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_name.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_name.rs @@ -519,7 +519,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { } // Otherwise, let's descend into the referent types. - search_stack.push((*referent_ty, &referent_hir_ty.ty)); + search_stack.push((referent_ty, &referent_hir_ty.ty)); } // Match up something like `Foo<'1>` @@ -548,17 +548,17 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { // The following cases don't have lifetimes, so we // just worry about trying to match up the rustc type // with the HIR types: - (&ty::Tuple(elem_tys), hir::TyKind::Tup(elem_hir_tys)) => { + (ty::Tuple(elem_tys), hir::TyKind::Tup(elem_hir_tys)) => { search_stack.extend(iter::zip(elem_tys, *elem_hir_tys)); } (ty::Slice(elem_ty), hir::TyKind::Slice(elem_hir_ty)) | (ty::Array(elem_ty, _), hir::TyKind::Array(elem_hir_ty, _)) => { - search_stack.push((*elem_ty, elem_hir_ty)); + search_stack.push((elem_ty, elem_hir_ty)); } (ty::RawPtr(mut_ty, _), hir::TyKind::Ptr(mut_hir_ty)) => { - search_stack.push((*mut_ty, &mut_hir_ty.ty)); + search_stack.push((mut_ty, &mut_hir_ty.ty)); } _ => { diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index 1d5801467da89..2b00f33ed2e98 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -268,7 +268,7 @@ fn do_mir_borrowck<'tcx>( // The first argument is the coroutine type passed by value if let Some(local) = body.local_decls.raw.get(1) // Get the interior types and args which typeck computed - && let ty::Coroutine(def_id, _) = *local.ty.kind() + && let ty::Coroutine(def_id, _) = local.ty.kind() && tcx.coroutine_movability(def_id) == hir::Movability::Movable { true diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index b57cf9066cf33..c89fb0acd5004 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -1127,7 +1127,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { use ty::TypeSuperFoldable as _; let tcx = self.tcx; - let &ty::Alias(ty::Opaque, ty::AliasTy { args, def_id, .. }) = t.kind() else { + let ty::Alias(ty::Opaque, ty::AliasTy { args, def_id, .. }) = t.kind() else { return t.super_fold_with(self); }; let args = std::iter::zip(args, tcx.variances_of(def_id)).map(|(arg, v)| { diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index fcfb297d50aa8..b3dcabb17fc3a 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -403,7 +403,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> { } } - if let ty::FnDef(def_id, args) = *constant.const_.ty().kind() { + if let ty::FnDef(def_id, args) = constant.const_.ty().kind() { let instantiated_predicates = tcx.predicates_of(def_id).instantiate(tcx, args); self.cx.normalize_and_prove_instantiated_predicates( def_id, @@ -441,7 +441,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> { // then remove the outermost reference so we can check the // type annotation for the remaining type. if let ty::Ref(_, rty, _) = local_decl.ty.kind() { - *rty + rty } else { bug!("{:?} with ref binding has wrong type {}", local, local_decl.ty); } @@ -655,7 +655,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { PlaceTy::from_ty(match base_ty.kind() { ty::Array(inner, _) => { assert!(!from_end, "array subslices should not use from_end"); - Ty::new_array(tcx, *inner, to - from) + Ty::new_array(tcx, inner, to - from) } ty::Slice(..) => { assert!(from_end, "slice subslices should use from_end"); @@ -779,7 +779,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { let tcx = self.tcx(); let (variant, args) = match base_ty { - PlaceTy { ty, variant_index: Some(variant_index) } => match *ty.kind() { + PlaceTy { ty, variant_index: Some(variant_index) } => match ty.kind() { ty::Adt(adt_def, args) => (adt_def.variant(variant_index), args), ty::Coroutine(def_id, args) => { let mut variants = args.as_coroutine().state_tys(def_id, tcx); @@ -797,7 +797,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { } _ => bug!("can't have downcast of non-adt non-coroutine type"), }, - PlaceTy { ty, variant_index: None } => match *ty.kind() { + PlaceTy { ty, variant_index: None } => match ty.kind() { ty::Adt(adt_def, args) if !adt_def.is_enum() => { (adt_def.variant(FIRST_VARIANT), args) } @@ -1602,7 +1602,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } let func_ty = func.ty(body, self.infcx.tcx); - if let ty::FnDef(def_id, _) = *func_ty.kind() { + if let ty::FnDef(def_id, _) = func_ty.kind() { // Some of the SIMD intrinsics are special: they need a particular argument to be a constant. // (Eventually this should use const-generics, but those are not up for the task yet: // https://github.com/rust-lang/rust/issues/85229.) @@ -2096,7 +2096,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { let outlives_predicate = tcx.mk_predicate(Binder::dummy( ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives( - ty::OutlivesPredicate(self_ty, *region), + ty::OutlivesPredicate(self_ty, region), )), )); self.prove_predicate( @@ -2117,8 +2117,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { return; }; if let Err(terr) = self.sub_types( - *ty_from, - *ty_to, + ty_from, + ty_to, location.to_locations(), ConstraintCategory::Cast { unsize_to: None }, ) { @@ -2138,7 +2138,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { let opt_ty_elem_mut = match ty_from.kind() { ty::RawPtr(array_ty, array_mut) => match array_ty.kind() { - ty::Array(ty_elem, _) => Some((ty_elem, *array_mut)), + ty::Array(ty_elem, _) => Some((ty_elem, array_mut)), _ => None, }, _ => None, @@ -2155,7 +2155,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { }; let (ty_to, ty_to_mut) = match ty.kind() { - ty::RawPtr(ty_to, ty_to_mut) => (ty_to, *ty_to_mut), + ty::RawPtr(ty_to, ty_to_mut) => (ty_to, ty_to_mut), _ => { span_mirbug!( self, @@ -2179,8 +2179,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } if let Err(terr) = self.sub_types( - *ty_elem, - *ty_to, + ty_elem, + ty_to, location.to_locations(), ConstraintCategory::Cast { unsize_to: None }, ) { diff --git a/compiler/rustc_borrowck/src/type_check/relate_tys.rs b/compiler/rustc_borrowck/src/type_check/relate_tys.rs index 9863c4a38832c..6bcaf44d5a388 100644 --- a/compiler/rustc_borrowck/src/type_check/relate_tys.rs +++ b/compiler/rustc_borrowck/src/type_check/relate_tys.rs @@ -147,8 +147,8 @@ impl<'me, 'bccx, 'tcx> NllTypeRelating<'me, 'bccx, 'tcx> { }; let (a, b) = match (a.kind(), b.kind()) { - (&ty::Alias(ty::Opaque, ..), _) => (a, enable_subtyping(b, true)?), - (_, &ty::Alias(ty::Opaque, ..)) => (enable_subtyping(a, false)?, b), + (ty::Alias(ty::Opaque, ..), _) => (a, enable_subtyping(b, true)?), + (_, ty::Alias(ty::Opaque, ..)) => (enable_subtyping(a, false)?, b), _ => unreachable!( "expected at least one opaque type in `relate_opaques`, got {a} and {b}." ), @@ -360,20 +360,20 @@ impl<'bccx, 'tcx> TypeRelation<'tcx> for NllTypeRelating<'_, 'bccx, 'tcx> { } match (a.kind(), b.kind()) { - (_, &ty::Infer(ty::TyVar(_))) => { + (_, ty::Infer(ty::TyVar(_))) => { span_bug!( self.span(), "should not be relating type variables on the right in MIR typeck" ); } - (&ty::Infer(ty::TyVar(a_vid)), _) => { + (ty::Infer(ty::TyVar(a_vid)), _) => { infcx.instantiate_ty_var(self, true, a_vid, self.ambient_variance, b)? } ( - &ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, .. }), - &ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }), + ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, .. }), + ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }), ) if a_def_id == b_def_id || infcx.next_trait_solver() => { infcx.super_combine_tys(self, a, b).map(|_| ()).or_else(|err| { // This behavior is only there for the old solver, the new solver @@ -387,8 +387,8 @@ impl<'bccx, 'tcx> TypeRelation<'tcx> for NllTypeRelating<'_, 'bccx, 'tcx> { if a_def_id.is_local() { self.relate_opaques(a, b) } else { Err(err) } })?; } - (&ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }), _) - | (_, &ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. })) + (ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }), _) + | (_, ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. })) if def_id.is_local() && !self.type_checker.infcx.next_trait_solver() => { self.relate_opaques(a, b)?; diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs index 9f5fb59e46c55..354592a4905e6 100644 --- a/compiler/rustc_borrowck/src/universal_regions.rs +++ b/compiler/rustc_borrowck/src/universal_regions.rs @@ -590,7 +590,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { let defining_ty = self.infcx.replace_free_regions_with_nll_infer_vars(FR, defining_ty); - match *defining_ty.kind() { + match defining_ty.kind() { ty::Closure(def_id, args) => DefiningTy::Closure(def_id, args), ty::Coroutine(def_id, args) => DefiningTy::Coroutine(def_id, args), ty::CoroutineClosure(def_id, args) => { @@ -713,7 +713,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { let (&output, tuplized_inputs) = inputs_and_output.skip_binder().split_last().unwrap(); assert_eq!(tuplized_inputs.len(), 1, "multiple closure inputs"); - let &ty::Tuple(inputs) = tuplized_inputs[0].kind() else { + let ty::Tuple(inputs) = tuplized_inputs[0].kind() else { bug!("closure inputs not a tuple: {:?}", tuplized_inputs[0]); }; diff --git a/compiler/rustc_codegen_cranelift/src/abi/mod.rs b/compiler/rustc_codegen_cranelift/src/abi/mod.rs index bd5a88769059f..7e33b67bbee0f 100644 --- a/compiler/rustc_codegen_cranelift/src/abi/mod.rs +++ b/compiler/rustc_codegen_cranelift/src/abi/mod.rs @@ -248,7 +248,7 @@ pub(crate) fn codegen_fn_prelude<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, start_ // individual function arguments. let tupled_arg_tys = match arg_ty.kind() { - ty::Tuple(ref tys) => tys, + ty::Tuple(tys) => tys, _ => bug!("spread argument isn't a tuple?! but {:?}", arg_ty), }; @@ -369,7 +369,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( let ret_place = codegen_place(fx, destination); // Handle special calls like intrinsics and empty drop glue. - let instance = if let ty::FnDef(def_id, fn_args) = *func.layout().ty.kind() { + let instance = if let ty::FnDef(def_id, fn_args) = func.layout().ty.kind() { let instance = ty::Instance::expect_resolve(fx.tcx, ty::ParamEnv::reveal_all(), def_id, fn_args) .polymorphize(fx.tcx); @@ -461,7 +461,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( }; let tupled_arguments = match pack_arg.value.layout().ty.kind() { - ty::Tuple(ref tupled_arguments) => tupled_arguments, + ty::Tuple(tupled_arguments) => tupled_arguments, _ => bug!("argument to function with \"rust-call\" ABI is not a tuple"), }; diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs index 963e5de91cefe..f40a3d9f77414 100644 --- a/compiler/rustc_codegen_cranelift/src/base.rs +++ b/compiler/rustc_codegen_cranelift/src/base.rs @@ -655,7 +655,7 @@ fn codegen_stmt<'tcx>( ) => { let from_ty = fx.monomorphize(operand.ty(&fx.mir.local_decls, fx.tcx)); let to_layout = fx.layout_of(fx.monomorphize(to_ty)); - match *from_ty.kind() { + match from_ty.kind() { ty::FnDef(def_id, args) => { let func_ref = fx.get_function_ref( Instance::resolve_for_fn_ptr( @@ -742,7 +742,7 @@ fn codegen_stmt<'tcx>( _to_ty, ) => { let operand = codegen_operand(fx, operand); - match *operand.layout().ty.kind() { + match operand.layout().ty.kind() { ty::Closure(def_id, args) => { let instance = Instance::resolve_closure( fx.tcx, @@ -937,7 +937,7 @@ fn codegen_stmt<'tcx>( } fn codegen_array_len<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, place: CPlace<'tcx>) -> Value { - match *place.layout().ty.kind() { + match place.layout().ty.kind() { ty::Array(_elem_ty, len) => { let len = fx.monomorphize(len).eval_target_usize(fx.tcx, ParamEnv::reveal_all()) as i64; fx.bcx.ins().iconst(fx.pointer_type, len) @@ -987,16 +987,16 @@ pub(crate) fn codegen_place<'tcx>( match cplace.layout().ty.kind() { ty::Array(elem_ty, _len) => { assert!(!from_end, "array subslices are never `from_end`"); - let elem_layout = fx.layout_of(*elem_ty); + let elem_layout = fx.layout_of(elem_ty); let ptr = cplace.to_ptr(); cplace = CPlace::for_ptr( ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * (from as i64)), - fx.layout_of(Ty::new_array(fx.tcx, *elem_ty, to - from)), + fx.layout_of(Ty::new_array(fx.tcx, elem_ty, to - from)), ); } ty::Slice(elem_ty) => { assert!(from_end, "slice subslices should be `from_end`"); - let elem_layout = fx.layout_of(*elem_ty); + let elem_layout = fx.layout_of(elem_ty); let (ptr, len) = cplace.to_ptr_unsized(); cplace = CPlace::for_ptr_with_extra( ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * (from as i64)), diff --git a/compiler/rustc_codegen_cranelift/src/common.rs b/compiler/rustc_codegen_cranelift/src/common.rs index 21d0cd2d30f2a..4d9b3a8a11e84 100644 --- a/compiler/rustc_codegen_cranelift/src/common.rs +++ b/compiler/rustc_codegen_cranelift/src/common.rs @@ -71,7 +71,7 @@ fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option pointer_ty(tcx), ty::RawPtr(pointee_ty, _) | ty::Ref(_, pointee_ty, _) => { - if has_ptr_meta(tcx, *pointee_ty) { + if has_ptr_meta(tcx, pointee_ty) { return None; } else { pointer_ty(tcx) @@ -91,7 +91,7 @@ fn clif_pair_type_from_ty<'tcx>( (clif_type_from_ty(tcx, types[0])?, clif_type_from_ty(tcx, types[1])?) } ty::RawPtr(pointee_ty, _) | ty::Ref(_, pointee_ty, _) => { - if has_ptr_meta(tcx, *pointee_ty) { + if has_ptr_meta(tcx, pointee_ty) { (pointer_ty(tcx), pointer_ty(tcx)) } else { return None; diff --git a/compiler/rustc_codegen_cranelift/src/debuginfo/types.rs b/compiler/rustc_codegen_cranelift/src/debuginfo/types.rs index 7baf0a3868d2c..70dcdcd78bf2d 100644 --- a/compiler/rustc_codegen_cranelift/src/debuginfo/types.rs +++ b/compiler/rustc_codegen_cranelift/src/debuginfo/types.rs @@ -43,20 +43,20 @@ impl DebugContext { tcx, type_dbg, ty, - *elem_ty, + elem_ty, len.eval_target_usize(tcx, ty::ParamEnv::reveal_all()), ), // ty::Slice(_) | ty::Str // ty::Dynamic // ty::Foreign ty::RawPtr(pointee_type, _) | ty::Ref(_, pointee_type, _) => { - self.pointer_type(tcx, type_dbg, ty, *pointee_type) + self.pointer_type(tcx, type_dbg, ty, pointee_type) } // ty::Adt(def, args) if def.is_box() && args.get(1).map_or(true, |arg| cx.layout_of(arg.expect_ty()).is_1zst()) // ty::FnDef(..) | ty::FnPtr(..) // ty::Closure(..) // ty::Adt(def, ..) - ty::Tuple(components) => self.tuple_type(tcx, type_dbg, ty, *components), + ty::Tuple(components) => self.tuple_type(tcx, type_dbg, ty, components), // ty::Param(_) // FIXME implement remaining types and add unreachable!() to the fallback branch _ => self.placeholder_for_type(tcx, type_dbg, ty), diff --git a/compiler/rustc_codegen_cranelift/src/global_asm.rs b/compiler/rustc_codegen_cranelift/src/global_asm.rs index 0c99a5ce12f6e..00b313aea36ce 100644 --- a/compiler/rustc_codegen_cranelift/src/global_asm.rs +++ b/compiler/rustc_codegen_cranelift/src/global_asm.rs @@ -65,7 +65,7 @@ pub(crate) fn codegen_global_asm_item(tcx: TyCtxt<'_>, global_asm: &mut String, let ty = tcx.typeck_body(anon_const.body).node_type(anon_const.hir_id); let instance = match ty.kind() { - &ty::FnDef(def_id, args) => Instance::new(def_id, args), + ty::FnDef(def_id, args) => Instance::new(def_id, args), _ => span_bug!(op_sp, "asm sym is not a function"), }; let symbol = tcx.symbol_name(instance); diff --git a/compiler/rustc_codegen_cranelift/src/inline_asm.rs b/compiler/rustc_codegen_cranelift/src/inline_asm.rs index 2de804f5e0423..e44d3b372f542 100644 --- a/compiler/rustc_codegen_cranelift/src/inline_asm.rs +++ b/compiler/rustc_codegen_cranelift/src/inline_asm.rs @@ -90,7 +90,7 @@ pub(crate) fn codegen_inline_asm_terminator<'tcx>( } let const_ = fx.monomorphize(value.const_); - if let ty::FnDef(def_id, args) = *const_.ty().kind() { + if let ty::FnDef(def_id, args) = const_.ty().kind() { let instance = ty::Instance::resolve_for_fn_ptr( fx.tcx, ty::ParamEnv::reveal_all(), @@ -260,7 +260,7 @@ pub(crate) fn codegen_naked_asm<'tcx>( ty::ParamEnv::reveal_all(), ty::EarlyBinder::bind(value.const_), ); - if let ty::FnDef(def_id, args) = *const_.ty().kind() { + if let ty::FnDef(def_id, args) = const_.ty().kind() { let instance = ty::Instance::resolve_for_fn_ptr( tcx, ty::ParamEnv::reveal_all(), diff --git a/compiler/rustc_codegen_cranelift/src/unsize.rs b/compiler/rustc_codegen_cranelift/src/unsize.rs index 4acbc8a27edb9..11ed80b6f2aae 100644 --- a/compiler/rustc_codegen_cranelift/src/unsize.rs +++ b/compiler/rustc_codegen_cranelift/src/unsize.rs @@ -68,11 +68,11 @@ fn unsize_ptr<'tcx>( dst_layout: TyAndLayout<'tcx>, old_info: Option, ) -> (Value, Value) { - match (&src_layout.ty.kind(), &dst_layout.ty.kind()) { - (&ty::Ref(_, a, _), &ty::Ref(_, b, _)) - | (&ty::Ref(_, a, _), &ty::RawPtr(b, _)) - | (&ty::RawPtr(a, _), &ty::RawPtr(b, _)) => (src, unsized_info(fx, *a, *b, old_info)), - (&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => { + match (src_layout.ty.kind(), dst_layout.ty.kind()) { + (ty::Ref(_, a, _), ty::Ref(_, b, _)) + | (ty::Ref(_, a, _), ty::RawPtr(b, _)) + | (ty::RawPtr(a, _), ty::RawPtr(b, _)) => (src, unsized_info(fx, a, b, old_info)), + (ty::Adt(def_a, _), ty::Adt(def_b, _)) => { assert_eq!(def_a, def_b); if src_layout == dst_layout { diff --git a/compiler/rustc_codegen_cranelift/src/value_and_place.rs b/compiler/rustc_codegen_cranelift/src/value_and_place.rs index 512a96450a4b6..dad369ec1adf8 100644 --- a/compiler/rustc_codegen_cranelift/src/value_and_place.rs +++ b/compiler/rustc_codegen_cranelift/src/value_and_place.rs @@ -801,7 +801,7 @@ impl<'tcx> CPlace<'tcx> { ) -> CPlace<'tcx> { let (elem_layout, ptr) = match self.layout().ty.kind() { ty::Array(elem_ty, _) => { - let elem_layout = fx.layout_of(*elem_ty); + let elem_layout = fx.layout_of(elem_ty); match self.inner { CPlaceInner::Addr(addr, None) => (elem_layout, addr), CPlaceInner::Var(_, _) @@ -809,7 +809,7 @@ impl<'tcx> CPlace<'tcx> { | CPlaceInner::VarPair(_, _, _) => bug!("Can't index into {self:?}"), } } - ty::Slice(elem_ty) => (fx.layout_of(*elem_ty), self.to_ptr_unsized().0), + ty::Slice(elem_ty) => (fx.layout_of(elem_ty), self.to_ptr_unsized().0), _ => bug!("place_index({:?})", self.layout().ty), }; @@ -867,10 +867,10 @@ pub(crate) fn assert_assignable<'tcx>( } match (from_ty.kind(), to_ty.kind()) { (ty::Ref(_, a, _), ty::Ref(_, b, _)) | (ty::RawPtr(a, _), ty::RawPtr(b, _)) => { - assert_assignable(fx, *a, *b, limit - 1); + assert_assignable(fx, a, b, limit - 1); } (ty::Ref(_, a, _), ty::RawPtr(b, _)) | (ty::RawPtr(a, _), ty::Ref(_, b, _)) => { - assert_assignable(fx, *a, *b, limit - 1); + assert_assignable(fx, a, b, limit - 1); } (ty::FnPtr(_), ty::FnPtr(_)) => { let from_sig = fx.tcx.normalize_erasing_late_bound_regions( @@ -918,7 +918,7 @@ pub(crate) fn assert_assignable<'tcx>( ); // fn(&T) -> for<'l> fn(&'l T) is allowed } - (&ty::Dynamic(from_traits, _, _from_kind), &ty::Dynamic(to_traits, _, _to_kind)) => { + (ty::Dynamic(from_traits, _, _from_kind), ty::Dynamic(to_traits, _, _to_kind)) => { // FIXME(dyn-star): Do the right thing with DynKinds for (from, to) in from_traits.iter().zip(to_traits) { let from = @@ -932,7 +932,7 @@ pub(crate) fn assert_assignable<'tcx>( } // dyn for<'r> Trait<'r> -> dyn Trait<'_> is allowed } - (&ty::Tuple(types_a), &ty::Tuple(types_b)) => { + (ty::Tuple(types_a), ty::Tuple(types_b)) => { let mut types_a = types_a.iter(); let mut types_b = types_b.iter(); loop { @@ -943,7 +943,7 @@ pub(crate) fn assert_assignable<'tcx>( } } } - (&ty::Adt(adt_def_a, args_a), &ty::Adt(adt_def_b, args_b)) + (ty::Adt(adt_def_a, args_a), ty::Adt(adt_def_b, args_b)) if adt_def_a.did() == adt_def_b.did() => { let mut types_a = args_a.types(); @@ -956,10 +956,8 @@ pub(crate) fn assert_assignable<'tcx>( } } } - (ty::Array(a, _), ty::Array(b, _)) => assert_assignable(fx, *a, *b, limit - 1), - (&ty::Closure(def_id_a, args_a), &ty::Closure(def_id_b, args_b)) - if def_id_a == def_id_b => - { + (ty::Array(a, _), ty::Array(b, _)) => assert_assignable(fx, a, b, limit - 1), + (ty::Closure(def_id_a, args_a), ty::Closure(def_id_b, args_b)) if def_id_a == def_id_b => { let mut types_a = args_a.types(); let mut types_b = args_b.types(); loop { @@ -970,7 +968,7 @@ pub(crate) fn assert_assignable<'tcx>( } } } - (&ty::Coroutine(def_id_a, args_a), &ty::Coroutine(def_id_b, args_b)) + (ty::Coroutine(def_id_a, args_a), ty::Coroutine(def_id_b, args_b)) if def_id_a == def_id_b => { let mut types_a = args_a.types(); @@ -983,7 +981,7 @@ pub(crate) fn assert_assignable<'tcx>( } } } - (&ty::CoroutineWitness(def_id_a, args_a), &ty::CoroutineWitness(def_id_b, args_b)) + (ty::CoroutineWitness(def_id_a, args_a), ty::CoroutineWitness(def_id_b, args_b)) if def_id_a == def_id_b => { let mut types_a = args_a.types(); diff --git a/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs index 43f12b514affa..f0e0ee253e658 100644 --- a/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs +++ b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs @@ -106,7 +106,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> { let tcx = self.tcx; let callee_ty = instance.ty(tcx, ty::ParamEnv::reveal_all()); - let (def_id, fn_args) = match *callee_ty.kind() { + let (def_id, fn_args) = match callee_ty.kind() { ty::FnDef(def_id, fn_args) => (def_id, fn_args), _ => bug!("expected fn item type, found {}", callee_ty), }; diff --git a/compiler/rustc_codegen_gcc/src/intrinsic/simd.rs b/compiler/rustc_codegen_gcc/src/intrinsic/simd.rs index 1625e6ecdb701..65ef9fbf8d0e5 100644 --- a/compiler/rustc_codegen_gcc/src/intrinsic/simd.rs +++ b/compiler/rustc_codegen_gcc/src/intrinsic/simd.rs @@ -591,7 +591,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>( }}; } let (elem_ty_str, elem_ty) = if let ty::Float(f) = in_elem.kind() { - let elem_ty = bx.cx.type_float_from_ty(*f); + let elem_ty = bx.cx.type_float_from_ty(f); match f.bit_width() { 32 => ("f", elem_ty), 64 => ("", elem_ty), @@ -599,7 +599,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>( return_error!(InvalidMonomorphization::FloatingPointVector { span, name, - f_ty: *f, + f_ty: f, in_ty }); } @@ -686,7 +686,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>( vec_len: u64, ) -> Type<'gcc> { // FIXME: use cx.layout_of(ty).llvm_type() ? - let elem_ty = match *elem_ty.kind() { + let elem_ty = match elem_ty.kind() { ty::Int(v) => cx.type_int_from_ty(v), ty::Uint(v) => cx.type_uint_from_ty(v), ty::Float(v) => cx.type_float_from_ty(v), @@ -797,7 +797,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>( // This counts how many pointers fn ptr_count(t: Ty<'_>) -> usize { - match *t.kind() { + match t.kind() { ty::RawPtr(p_ty, _) => 1 + ptr_count(p_ty), _ => 0, } @@ -805,7 +805,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>( // Non-ptr type fn non_ptr(t: Ty<'_>) -> Ty<'_> { - match *t.kind() { + match t.kind() { ty::RawPtr(p_ty, _) => non_ptr(p_ty), _ => t, } @@ -815,7 +815,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>( // to the element type of the first argument let (_, element_ty0) = arg_tys[0].simd_size_and_type(bx.tcx()); let (_, element_ty1) = arg_tys[1].simd_size_and_type(bx.tcx()); - let (pointer_count, underlying_ty) = match *element_ty1.kind() { + let (pointer_count, underlying_ty) = match element_ty1.kind() { ty::RawPtr(p_ty, _) if p_ty == in_elem => (ptr_count(element_ty1), non_ptr(element_ty1)), _ => { require!( @@ -911,7 +911,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>( // This counts how many pointers fn ptr_count(t: Ty<'_>) -> usize { - match *t.kind() { + match t.kind() { ty::RawPtr(p_ty, _) => 1 + ptr_count(p_ty), _ => 0, } @@ -919,7 +919,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>( // Non-ptr type fn non_ptr(t: Ty<'_>) -> Ty<'_> { - match *t.kind() { + match t.kind() { ty::RawPtr(p_ty, _) => non_ptr(p_ty), _ => t, } @@ -930,7 +930,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>( let (_, element_ty0) = arg_tys[0].simd_size_and_type(bx.tcx()); let (_, element_ty1) = arg_tys[1].simd_size_and_type(bx.tcx()); let (_, element_ty2) = arg_tys[2].simd_size_and_type(bx.tcx()); - let (pointer_count, underlying_ty) = match *element_ty1.kind() { + let (pointer_count, underlying_ty) = match element_ty1.kind() { ty::RawPtr(p_ty, mutbl) if p_ty == in_elem && mutbl == hir::Mutability::Mut => { (ptr_count(element_ty1), non_ptr(element_ty1)) } @@ -1034,7 +1034,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>( let rhs = args[1].immediate(); let is_add = name == sym::simd_saturating_add; let ptr_bits = bx.tcx().data_layout.pointer_size.bits() as _; - let (signed, elem_width, elem_ty) = match *in_elem.kind() { + let (signed, elem_width, elem_ty) = match in_elem.kind() { ty::Int(i) => (true, i.bit_width().unwrap_or(ptr_bits) / 8, bx.cx.type_int_from_ty(i)), ty::Uint(i) => { (false, i.bit_width().unwrap_or(ptr_bits) / 8, bx.cx.type_uint_from_ty(i)) diff --git a/compiler/rustc_codegen_gcc/src/type_of.rs b/compiler/rustc_codegen_gcc/src/type_of.rs index a88d50cb43403..06b59adc38119 100644 --- a/compiler/rustc_codegen_gcc/src/type_of.rs +++ b/compiler/rustc_codegen_gcc/src/type_of.rs @@ -103,14 +103,14 @@ fn uncached_gcc_type<'gcc, 'tcx>( if !cx.sess().fewer_names() => { let mut name = with_no_trimmed_paths!(layout.ty.to_string()); - if let (&ty::Adt(def, _), &Variants::Single { index }) = + if let (ty::Adt(def, _), &Variants::Single { index }) = (layout.ty.kind(), &layout.variants) { if def.is_enum() && !def.variants().is_empty() { write!(&mut name, "::{}", def.variant(index).name).unwrap(); } } - if let (&ty::Coroutine(_, _), &Variants::Single { index }) = + if let (ty::Coroutine(_, _), &Variants::Single { index }) = (layout.ty.kind(), &layout.variants) { write!(&mut name, "::{}", ty::CoroutineArgs::variant_name(index)).unwrap(); @@ -215,7 +215,7 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> { if let Some(&ty) = cx.scalar_types.borrow().get(&self.ty) { return ty; } - let ty = match *self.ty.kind() { + let ty = match self.ty.kind() { // NOTE: we cannot remove this match like in the LLVM codegen because the call // to fn_ptr_backend_type handle the on-stack attribute. // TODO(antoyo): find a less hackish way to hande the on-stack attribute. diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs index 72ff9ea118e28..3e3966e6f4067 100644 --- a/compiler/rustc_codegen_llvm/src/builder.rs +++ b/compiler/rustc_codegen_llvm/src/builder.rs @@ -396,7 +396,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { let new_kind = match ty.kind() { Int(t @ Isize) => Int(t.normalize(self.tcx.sess.target.pointer_width)), Uint(t @ Usize) => Uint(t.normalize(self.tcx.sess.target.pointer_width)), - t @ (Uint(_) | Int(_)) => *t, + t @ (Uint(_) | Int(_)) => t, _ => panic!("tried to get overflow intrinsic for op applied to non-int type"), }; diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index a543ccbde0edf..04d71b510f35a 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -129,7 +129,7 @@ fn build_fixed_size_array_di_node<'ll, 'tcx>( bug!("build_fixed_size_array_di_node() called with non-ty::Array type `{:?}`", array_type) }; - let element_type_di_node = type_di_node(cx, *element_type); + let element_type_di_node = type_di_node(cx, element_type); return_if_di_node_created_in_meantime!(cx, unique_type_id); @@ -416,7 +416,7 @@ fn build_slice_type_di_node<'ll, 'tcx>( unique_type_id: UniqueTypeId<'tcx>, ) -> DINodeCreationResult<'ll> { let element_type = match slice_type.kind() { - ty::Slice(element_type) => *element_type, + ty::Slice(element_type) => element_type, ty::Str => cx.tcx.types.u8, _ => { bug!( @@ -445,7 +445,7 @@ pub fn type_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll D debug!("type_di_node: {:?} kind: {:?}", t, t.kind()); - let DINodeCreationResult { di_node, already_stored_in_typemap } = match *t.kind() { + let DINodeCreationResult { di_node, already_stored_in_typemap } = match t.kind() { ty::Never | ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) => { build_basic_type_di_node(cx, t) } @@ -789,7 +789,7 @@ fn build_foreign_type_di_node<'ll, 'tcx>( ) -> DINodeCreationResult<'ll> { debug!("build_foreign_type_di_node: {:?}", t); - let &ty::Foreign(def_id) = unique_type_id.expect_ty().kind() else { + let ty::Foreign(def_id) = unique_type_id.expect_ty().kind() else { bug!( "build_foreign_type_di_node() called with unexpected type: {:?}", unique_type_id.expect_ty() @@ -1081,7 +1081,7 @@ fn build_upvar_field_di_nodes<'ll, 'tcx>( closure_or_coroutine_ty: Ty<'tcx>, closure_or_coroutine_di_node: &'ll DIType, ) -> SmallVec<&'ll DIType> { - let (&def_id, up_var_tys) = match closure_or_coroutine_ty.kind() { + let (def_id, up_var_tys) = match closure_or_coroutine_ty.kind() { ty::Coroutine(def_id, args) => (def_id, args.as_coroutine().prefix_tys()), ty::Closure(def_id, args) => (def_id, args.as_closure().upvar_tys()), ty::CoroutineClosure(def_id, args) => (def_id, args.as_coroutine_closure().upvar_tys()), @@ -1124,7 +1124,7 @@ fn build_tuple_type_di_node<'ll, 'tcx>( unique_type_id: UniqueTypeId<'tcx>, ) -> DINodeCreationResult<'ll> { let tuple_type = unique_type_id.expect_ty(); - let &ty::Tuple(component_types) = tuple_type.kind() else { + let ty::Tuple(component_types) = tuple_type.kind() else { bug!("build_tuple_type_di_node() called with non-tuple-type: {:?}", tuple_type) }; @@ -1170,8 +1170,7 @@ fn build_closure_env_di_node<'ll, 'tcx>( unique_type_id: UniqueTypeId<'tcx>, ) -> DINodeCreationResult<'ll> { let closure_env_type = unique_type_id.expect_ty(); - let &(ty::Closure(def_id, _) | ty::CoroutineClosure(def_id, _)) = closure_env_type.kind() - else { + let (ty::Closure(def_id, _) | ty::CoroutineClosure(def_id, _)) = closure_env_type.kind() else { bug!("build_closure_env_di_node() called with non-closure-type: {:?}", closure_env_type) }; let containing_scope = get_namespace_for_item(cx, def_id); @@ -1249,7 +1248,7 @@ fn build_generic_type_param_di_nodes<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>, ) -> SmallVec<&'ll DIType> { - if let ty::Adt(def, args) = *ty.kind() { + if let ty::Adt(def, args) = ty.kind() { if args.types().next().is_some() { let generics = cx.tcx.generics_of(def.did()); let names = get_parameter_names(cx, generics); 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 12f98eef97d43..d27a8a57796f3 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 @@ -197,7 +197,7 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>( unique_type_id: UniqueTypeId<'tcx>, ) -> DINodeCreationResult<'ll> { let enum_type = unique_type_id.expect_ty(); - let &ty::Adt(enum_adt_def, _) = enum_type.kind() else { + let ty::Adt(enum_adt_def, _) = enum_type.kind() else { bug!("build_enum_type_di_node() called with non-enum type: `{:?}`", enum_type) }; @@ -679,7 +679,7 @@ fn build_union_fields_for_direct_tag_coroutine<'ll, 'tcx>( }; let (coroutine_def_id, coroutine_args) = match coroutine_type_and_layout.ty.kind() { - &ty::Coroutine(def_id, args) => (def_id, args.as_coroutine()), + ty::Coroutine(def_id, args) => (def_id, args.as_coroutine()), _ => unreachable!(), }; diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs index 2b00bb14593e4..2492f5df3c832 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs @@ -49,7 +49,7 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>( unique_type_id: UniqueTypeId<'tcx>, ) -> DINodeCreationResult<'ll> { let enum_type = unique_type_id.expect_ty(); - let &ty::Adt(enum_adt_def, _) = enum_type.kind() else { + let ty::Adt(enum_adt_def, _) = enum_type.kind() else { bug!("build_enum_type_di_node() called with non-enum type: `{:?}`", enum_type) }; 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 115d5187eafa8..4bb9da1e9df6f 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs @@ -55,7 +55,7 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>( unique_type_id: UniqueTypeId<'tcx>, ) -> DINodeCreationResult<'ll> { let enum_type = unique_type_id.expect_ty(); - let &ty::Adt(enum_adt_def, _) = enum_type.kind() else { + let ty::Adt(enum_adt_def, _) = enum_type.kind() else { bug!("build_enum_type_di_node() called with non-enum type: `{:?}`", enum_type) }; @@ -135,7 +135,7 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>( unique_type_id: UniqueTypeId<'tcx>, ) -> DINodeCreationResult<'ll> { let coroutine_type = unique_type_id.expect_ty(); - let &ty::Coroutine(coroutine_def_id, coroutine_args) = coroutine_type.kind() else { + let ty::Coroutine(coroutine_def_id, coroutine_args) = coroutine_type.kind() else { bug!("build_coroutine_di_node() called with non-coroutine type: `{:?}`", coroutine_type) }; diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs index 3486ce4becb46..5e8663ddb8ac1 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs @@ -455,9 +455,9 @@ impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { let t = arg.layout.ty; let t = match t.kind() { ty::Array(ct, _) - if (*ct == cx.tcx.types.u8) || cx.layout_of(*ct).is_zst() => + if (ct == cx.tcx.types.u8) || cx.layout_of(ct).is_zst() => { - Ty::new_imm_ptr(cx.tcx, *ct) + Ty::new_imm_ptr(cx.tcx, ct) } _ => t, }; diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/utils.rs b/compiler/rustc_codegen_llvm/src/debuginfo/utils.rs index 155e7a89fd8b9..f7c3b784d8e1e 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/utils.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/utils.rs @@ -76,7 +76,7 @@ pub(crate) fn fat_pointer_kind<'ll, 'tcx>( return None; } - match *pointee_tail_ty.kind() { + match pointee_tail_ty.kind() { ty::Str | ty::Slice(_) => Some(FatPtrKind::Slice), ty::Dynamic(..) => Some(FatPtrKind::Dyn), ty::Foreign(_) => { diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 7b1038d561765..5ee38ff17511f 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -159,7 +159,7 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> { let tcx = self.tcx; let callee_ty = instance.ty(tcx, ty::ParamEnv::reveal_all()); - let ty::FnDef(def_id, fn_args) = *callee_ty.kind() else { + let ty::FnDef(def_id, fn_args) = callee_ty.kind() else { bug!("expected fn item type, found {}", callee_ty); }; @@ -496,9 +496,9 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> { { let (size, elem_ty) = ty.simd_size_and_type(self.tcx()); let elem_ll_ty = match elem_ty.kind() { - ty::Float(f) => self.type_float_from_ty(*f), - ty::Int(i) => self.type_int_from_ty(*i), - ty::Uint(u) => self.type_uint_from_ty(*u), + ty::Float(f) => self.type_float_from_ty(f), + ty::Int(i) => self.type_int_from_ty(i), + ty::Uint(u) => self.type_uint_from_ty(u), ty::RawPtr(_, _) => self.type_ptr(), _ => unreachable!(), }; @@ -516,9 +516,9 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> { { let (size, elem_ty) = ret_ty.simd_size_and_type(self.tcx()); let elem_ll_ty = match elem_ty.kind() { - ty::Float(f) => self.type_float_from_ty(*f), - ty::Int(i) => self.type_int_from_ty(*i), - ty::Uint(u) => self.type_uint_from_ty(*u), + ty::Float(f) => self.type_float_from_ty(f), + ty::Int(i) => self.type_int_from_ty(i), + ty::Uint(u) => self.type_uint_from_ty(u), ty::RawPtr(_, _) => self.type_ptr(), _ => unreachable!(), }; @@ -1465,14 +1465,14 @@ fn generic_simd_intrinsic<'ll, 'tcx>( } let (elem_ty_str, elem_ty) = if let ty::Float(f) = in_elem.kind() { - let elem_ty = bx.cx.type_float_from_ty(*f); + let elem_ty = bx.cx.type_float_from_ty(f); match f.bit_width() { 32 => ("f32", elem_ty), 64 => ("f64", elem_ty), _ => return_error!(InvalidMonomorphization::FloatingPointVector { span, name, - f_ty: *f, + f_ty: f, in_ty, }), } @@ -1541,7 +1541,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>( // https://github.com/llvm-mirror/llvm/blob/master/include/llvm/IR/Function.h#L182 // https://github.com/llvm-mirror/llvm/blob/master/include/llvm/IR/Intrinsics.h#L81 fn llvm_vector_str(bx: &Builder<'_, '_, '_>, elem_ty: Ty<'_>, vec_len: u64) -> String { - match *elem_ty.kind() { + match elem_ty.kind() { ty::Int(v) => format!( "v{}i{}", vec_len, @@ -1561,7 +1561,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>( } fn llvm_vector_ty<'ll>(cx: &CodegenCx<'ll, '_>, elem_ty: Ty<'_>, vec_len: u64) -> &'ll Type { - let elem_ty = match *elem_ty.kind() { + let elem_ty = match elem_ty.kind() { ty::Int(v) => cx.type_int_from_ty(v), ty::Uint(v) => cx.type_uint_from_ty(v), ty::Float(v) => cx.type_float_from_ty(v), @@ -1620,7 +1620,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>( require!( matches!( - *element_ty1.kind(), + element_ty1.kind(), ty::RawPtr(p_ty, _) if p_ty == in_elem && p_ty.kind() == element_ty0.kind() ), InvalidMonomorphization::ExpectedElementType { @@ -1727,7 +1727,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>( require!( matches!( - *pointer_ty.kind(), + pointer_ty.kind(), ty::RawPtr(p_ty, _) if p_ty == values_elem && p_ty.kind() == values_elem.kind() ), InvalidMonomorphization::ExpectedElementType { @@ -1820,7 +1820,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>( // The second argument must be a mutable pointer type matching the element type require!( matches!( - *pointer_ty.kind(), + pointer_ty.kind(), ty::RawPtr(p_ty, p_mutbl) if p_ty == values_elem && p_ty.kind() == values_elem.kind() && p_mutbl.is_mut() ), InvalidMonomorphization::ExpectedElementType { @@ -1918,7 +1918,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>( require!( matches!( - *element_ty1.kind(), + element_ty1.kind(), ty::RawPtr(p_ty, p_mutbl) if p_ty == in_elem && p_mutbl.is_mut() && p_ty.kind() == element_ty0.kind() ), @@ -2396,7 +2396,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>( sym::simd_bswap | sym::simd_bitreverse | sym::simd_ctlz | sym::simd_ctpop | sym::simd_cttz ) { let vec_ty = bx.cx.type_vector( - match *in_elem.kind() { + match in_elem.kind() { ty::Int(i) => bx.cx.type_int_from_ty(i), ty::Uint(i) => bx.cx.type_uint_from_ty(i), _ => return_error!(InvalidMonomorphization::UnsupportedOperation { @@ -2473,7 +2473,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>( let rhs = args[1].immediate(); let is_add = name == sym::simd_saturating_add; let ptr_bits = bx.tcx().data_layout.pointer_size.bits() as _; - let (signed, elem_width, elem_ty) = match *in_elem.kind() { + let (signed, elem_width, elem_ty) = match in_elem.kind() { ty::Int(i) => (true, i.bit_width().unwrap_or(ptr_bits), bx.cx.type_int_from_ty(i)), ty::Uint(i) => (false, i.bit_width().unwrap_or(ptr_bits), bx.cx.type_uint_from_ty(i)), _ => { diff --git a/compiler/rustc_codegen_llvm/src/type_of.rs b/compiler/rustc_codegen_llvm/src/type_of.rs index 7be941ed74980..980700ba41c68 100644 --- a/compiler/rustc_codegen_llvm/src/type_of.rs +++ b/compiler/rustc_codegen_llvm/src/type_of.rs @@ -35,14 +35,14 @@ fn uncached_llvm_type<'a, 'tcx>( if !cx.sess().fewer_names() => { let mut name = with_no_visible_paths!(with_no_trimmed_paths!(layout.ty.to_string())); - if let (&ty::Adt(def, _), &Variants::Single { index }) = + if let (ty::Adt(def, _), &Variants::Single { index }) = (layout.ty.kind(), &layout.variants) { if def.is_enum() && !def.variants().is_empty() { write!(&mut name, "::{}", def.variant(index).name).unwrap(); } } - if let (&ty::Coroutine(_, _), &Variants::Single { index }) = + if let (ty::Coroutine(_, _), &Variants::Single { index }) = (layout.ty.kind(), &layout.variants) { write!(&mut name, "::{}", ty::CoroutineArgs::variant_name(index)).unwrap(); diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index f372d3a052267..1a7b671f99590 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -148,10 +148,10 @@ pub fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( let (source, target) = cx.tcx().struct_lockstep_tails_erasing_lifetimes(source, target, bx.param_env()); match (source.kind(), target.kind()) { - (&ty::Array(_, len), &ty::Slice(_)) => { + (ty::Array(_, len), ty::Slice(_)) => { cx.const_usize(len.eval_target_usize(cx.tcx(), ty::ParamEnv::reveal_all())) } - (&ty::Dynamic(data_a, _, src_dyn_kind), &ty::Dynamic(data_b, _, 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 = @@ -195,12 +195,12 @@ pub fn unsize_ptr<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( ) -> (Bx::Value, Bx::Value) { debug!("unsize_ptr: {:?} => {:?}", src_ty, dst_ty); match (src_ty.kind(), dst_ty.kind()) { - (&ty::Ref(_, a, _), &ty::Ref(_, b, _) | &ty::RawPtr(b, _)) - | (&ty::RawPtr(a, _), &ty::RawPtr(b, _)) => { + (ty::Ref(_, a, _), ty::Ref(_, b, _) | ty::RawPtr(b, _)) + | (ty::RawPtr(a, _), ty::RawPtr(b, _)) => { assert_eq!(bx.cx().type_is_sized(a), old_info.is_none()); (src, unsized_info(bx, a, b, old_info)) } - (&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => { + (ty::Adt(def_a, _), ty::Adt(def_b, _)) => { assert_eq!(def_a, def_b); // implies same number of fields let src_layout = bx.cx().layout_of(src_ty); let dst_layout = bx.cx().layout_of(dst_ty); @@ -262,7 +262,7 @@ pub fn coerce_unsized_into<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( let src_ty = src.layout.ty; let dst_ty = dst.layout.ty; match (src_ty.kind(), dst_ty.kind()) { - (&ty::Ref(..), &ty::Ref(..) | &ty::RawPtr(..)) | (&ty::RawPtr(..), &ty::RawPtr(..)) => { + (ty::Ref(..), ty::Ref(..) | ty::RawPtr(..)) | (ty::RawPtr(..), ty::RawPtr(..)) => { let (base, info) = match bx.load_operand(src).val { OperandValue::Pair(base, info) => unsize_ptr(bx, base, src_ty, dst_ty, Some(info)), OperandValue::Immediate(base) => unsize_ptr(bx, base, src_ty, dst_ty, None), @@ -271,7 +271,7 @@ pub fn coerce_unsized_into<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( OperandValue::Pair(base, info).store(bx, dst); } - (&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => { + (ty::Adt(def_a, _), ty::Adt(def_b, _)) => { assert_eq!(def_a, def_b); // implies same number of fields for i in def_a.variant(FIRST_VARIANT).fields.indices() { diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs index c4e5c8582404b..7fc091624de1b 100644 --- a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs +++ b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs @@ -58,7 +58,7 @@ fn push_debuginfo_type_name<'tcx>( // .natvis visualizers (and perhaps other existing native debuggers?) let cpp_like_debuginfo = cpp_like_debuginfo(tcx); - match *t.kind() { + match t.kind() { ty::Bool => output.push_str("bool"), ty::Char => output.push_str("char"), ty::Str => { @@ -699,7 +699,7 @@ fn push_const_param<'tcx>(tcx: TyCtxt<'tcx>, ct: ty::Const<'tcx>, output: &mut S // FIXME: directly extract the bits from a valtree instead of evaluating an // alreay evaluated `Const` in order to get the bits. let bits = ct.eval_bits(tcx, ty::ParamEnv::reveal_all()); - let val = Integer::from_int_ty(&tcx, *ity).size().sign_extend(bits) as i128; + let val = Integer::from_int_ty(&tcx, ity).size().sign_extend(bits) as i128; write!(output, "{val}") } ty::Uint(_) => { diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index bd9704b37aea9..4e546f90434fd 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -835,7 +835,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { // Create the callee. This is a fn ptr or zero-sized and hence a kind of scalar. let callee = self.codegen_operand(bx, func); - let (instance, mut llfn) = match *callee.layout.ty.kind() { + let (instance, mut llfn) = match callee.layout.ty.kind() { ty::FnDef(def_id, args) => ( Some( ty::Instance::expect_resolve( @@ -1213,7 +1213,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } mir::InlineAsmOperand::SymFn { ref value } => { let const_ = self.monomorphize(value.const_); - if let ty::FnDef(def_id, args) = *const_.ty().kind() { + if let ty::FnDef(def_id, args) = const_.ty().kind() { let instance = ty::Instance::resolve_for_fn_ptr( bx.tcx(), ty::ParamEnv::reveal_all(), diff --git a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs index f88deaa7abca6..989a934face84 100644 --- a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs +++ b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs @@ -66,7 +66,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { ) -> Result<(), ty::Instance<'tcx>> { let callee_ty = instance.ty(bx.tcx(), ty::ParamEnv::reveal_all()); - let ty::FnDef(def_id, fn_args) = *callee_ty.kind() else { + let ty::FnDef(def_id, fn_args) = callee_ty.kind() else { bug!("expected fn item type, found {}", callee_ty); }; diff --git a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs index c23867be3a10d..93e26e1a08811 100644 --- a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs +++ b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs @@ -415,7 +415,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { OperandValue::Immediate(lladdr) } mir::CastKind::PointerCoercion(PointerCoercion::ReifyFnPointer) => { - match *operand.layout.ty.kind() { + match operand.layout.ty.kind() { ty::FnDef(def_id, args) => { let instance = ty::Instance::resolve_for_fn_ptr( bx.tcx(), @@ -431,7 +431,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } } mir::CastKind::PointerCoercion(PointerCoercion::ClosureFnPointer(_)) => { - match *operand.layout.ty.kind() { + match operand.layout.ty.kind() { ty::Closure(def_id, args) => { let instance = Instance::resolve_closure( bx.cx().tcx(), diff --git a/compiler/rustc_codegen_ssa/src/mono_item.rs b/compiler/rustc_codegen_ssa/src/mono_item.rs index 0fbcb938d1a74..ef2bcc3b41f63 100644 --- a/compiler/rustc_codegen_ssa/src/mono_item.rs +++ b/compiler/rustc_codegen_ssa/src/mono_item.rs @@ -78,7 +78,7 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> { .typeck_body(anon_const.body) .node_type(anon_const.hir_id); let instance = match ty.kind() { - &ty::FnDef(def_id, args) => Instance::new(def_id, args), + ty::FnDef(def_id, args) => Instance::new(def_id, args), _ => span_bug!(*op_sp, "asm sym is not a function"), }; diff --git a/compiler/rustc_const_eval/src/check_consts/check.rs b/compiler/rustc_const_eval/src/check_consts/check.rs index 9e01c59a96f9f..02b76d0a6df3e 100644 --- a/compiler/rustc_const_eval/src/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/check_consts/check.rs @@ -717,7 +717,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { let fn_ty = func.ty(body, tcx); - let (mut callee, mut fn_args) = match *fn_ty.kind() { + let (mut callee, mut fn_args) = match fn_ty.kind() { ty::FnDef(def_id, fn_args) => (def_id, fn_args), ty::FnPtr(_) => { diff --git a/compiler/rustc_const_eval/src/check_consts/ops.rs b/compiler/rustc_const_eval/src/check_consts/ops.rs index feab5b929acbb..59ac23fac4970 100644 --- a/compiler/rustc_const_eval/src/check_consts/ops.rs +++ b/compiler/rustc_const_eval/src/check_consts/ops.rs @@ -187,8 +187,8 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> { CallKind::FnCall { fn_trait_id, self_ty } => { let note = match self_ty.kind() { FnDef(def_id, ..) => { - let span = tcx.def_span(*def_id); - if ccx.tcx.is_const_fn_raw(*def_id) { + let span = tcx.def_span(def_id); + if ccx.tcx.is_const_fn_raw(def_id) { span_bug!(span, "calling const FnDef errored when it shouldn't"); } @@ -229,7 +229,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> { let mut tmp_ty = self_ty; while let rustc_middle::ty::Ref(_, inner_ty, _) = tmp_ty.kind() { num_refs += 1; - tmp_ty = *inner_ty; + tmp_ty = inner_ty; } let deref = "*".repeat(num_refs); diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs index 79a161d3f03d7..1e07597323a26 100644 --- a/compiler/rustc_const_eval/src/const_eval/machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/machine.rs @@ -709,7 +709,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeInterpreter<'tcx> { // If it's a frozen shared reference that's not already immutable, make it immutable. // (Do nothing on `None` provenance, that cannot store immutability anyway.) if let ty::Ref(_, ty, mutbl) = val.layout.ty.kind() - && *mutbl == Mutability::Not + && mutbl == Mutability::Not && val.to_scalar_and_meta().0.to_pointer(ecx)?.provenance.is_some_and(|p| !p.immutable()) // That next check is expensive, that's why we have all the guards above. && ty.is_freeze(*ecx.tcx, ecx.param_env) diff --git a/compiler/rustc_const_eval/src/const_eval/valtrees.rs b/compiler/rustc_const_eval/src/const_eval/valtrees.rs index 5312f1f946f50..7f235f58f9a80 100644 --- a/compiler/rustc_const_eval/src/const_eval/valtrees.rs +++ b/compiler/rustc_const_eval/src/const_eval/valtrees.rs @@ -106,7 +106,7 @@ fn const_to_valtree_inner<'tcx>( // The valtree of the base type is the same as the valtree of the pattern type. // Since the returned valtree does not contain the type or layout, we can just // switch to the base type. - place.layout = ecx.layout_of(*base).unwrap(); + place.layout = ecx.layout_of(base).unwrap(); ensure_sufficient_stack(|| const_to_valtree_inner(ecx, &place, num_nodes)) }, @@ -286,7 +286,7 @@ pub fn valtree_to_const_value<'tcx>( let (param_env, ty) = param_env_ty.into_parts(); - match *ty.kind() { + match ty.kind() { ty::FnDef(..) => { assert!(valtree.unwrap_branch().is_empty()); mir::ConstValue::ZeroSized @@ -399,7 +399,7 @@ fn valtree_into_mplace<'tcx>( ecx.write_immediate(Immediate::Scalar(scalar_int.into()), place).unwrap(); } ty::Ref(_, inner_ty, _) => { - let imm = valtree_to_ref(ecx, valtree, *inner_ty); + let imm = valtree_to_ref(ecx, valtree, inner_ty); debug!(?imm); ecx.write_immediate(imm, place).unwrap(); } diff --git a/compiler/rustc_const_eval/src/interpret/cast.rs b/compiler/rustc_const_eval/src/interpret/cast.rs index 19414c72c6a42..900a432742923 100644 --- a/compiler/rustc_const_eval/src/interpret/cast.rs +++ b/compiler/rustc_const_eval/src/interpret/cast.rs @@ -80,7 +80,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { ensure_monomorphic_enough(*self.tcx, src.layout.ty)?; // The src operand does not matter, just its type - match *src.layout.ty.kind() { + match src.layout.ty.kind() { ty::FnDef(def_id, args) => { let instance = ty::Instance::resolve_for_fn_ptr( *self.tcx, @@ -113,7 +113,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { ensure_monomorphic_enough(*self.tcx, src.layout.ty)?; // The src operand does not matter, just its type - match *src.layout.ty.kind() { + match src.layout.ty.kind() { ty::Closure(def_id, args) => { let instance = ty::Instance::resolve_closure( *self.tcx, @@ -278,10 +278,10 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { let v = if signed { self.sign_extend(v, src_layout) } else { v }; trace!("cast_from_scalar: {}, {} -> {}", v, src_layout.ty, cast_ty); - Ok(match *cast_ty.kind() { + Ok(match cast_ty.kind() { // int -> int Int(_) | Uint(_) => { - let size = match *cast_ty.kind() { + let size = match cast_ty.kind() { Int(t) => Integer::from_int_ty(self, t).size(), Uint(t) => Integer::from_uint_ty(self, t).size(), _ => bug!(), @@ -336,7 +336,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { if f2.is_nan() { M::generate_nan(ecx, &[f1]) } else { f2 } } - match *dest_ty.kind() { + match dest_ty.kind() { // float -> uint Uint(t) => { let size = Integer::from_uint_ty(self, t).size(); @@ -442,7 +442,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { trace!("Unsizing {:?} of type {} into {}", *src, src.layout.ty, cast_ty.ty); match (&src.layout.ty.kind(), &cast_ty.ty.kind()) { (&ty::Ref(_, s, _), &ty::Ref(_, c, _) | &ty::RawPtr(c, _)) - | (&ty::RawPtr(s, _), &ty::RawPtr(c, _)) => self.unsize_into_ptr(src, dest, *s, *c), + | (&ty::RawPtr(s, _), &ty::RawPtr(c, _)) => self.unsize_into_ptr(src, dest, s, c), (&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => { assert_eq!(def_a, def_b); // implies same number of fields diff --git a/compiler/rustc_const_eval/src/interpret/discriminant.rs b/compiler/rustc_const_eval/src/interpret/discriminant.rs index 67fbf9642bf0a..bf28ab3fcf866 100644 --- a/compiler/rustc_const_eval/src/interpret/discriminant.rs +++ b/compiler/rustc_const_eval/src/interpret/discriminant.rs @@ -132,7 +132,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { let discr_val = self.int_to_int_or_float(&tag_val, discr_layout).unwrap(); let discr_bits = discr_val.to_scalar().assert_bits(discr_layout.size); // Convert discriminant to variant index, and catch invalid discriminants. - let index = match *ty.kind() { + let index = match ty.kind() { ty::Adt(adt, _) => { adt.discriminants(*self.tcx).find(|(_, var)| var.val == discr_bits) } diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index 7c2100fcbe38a..b72d89af9cb67 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -1059,7 +1059,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { ty::Tuple(tys) => tys.last().iter().all(|ty| is_very_trivially_sized(**ty)), - ty::Pat(ty, ..) => is_very_trivially_sized(*ty), + ty::Pat(ty, ..) => is_very_trivially_sized(ty), // We don't want to do any queries, so there is not much we can do with ADTs. ty::Adt(..) => false, diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index 18b76443cd954..16e25234fe304 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -67,7 +67,7 @@ pub(crate) fn eval_nullary_intrinsic<'tcx>( ty::Alias(..) | ty::Param(_) | ty::Placeholder(_) | ty::Infer(_) => { throw_inval!(TooGeneric) } - ty::Pat(_, pat) => match **pat { + ty::Pat(_, pat) => match *pat { ty::PatternKind::Range { .. } => ConstValue::from_target_usize(0u64, &tcx), // Future pattern kinds may have more variants }, diff --git a/compiler/rustc_const_eval/src/interpret/projection.rs b/compiler/rustc_const_eval/src/interpret/projection.rs index 0e594914c3a79..c207582cac7ea 100644 --- a/compiler/rustc_const_eval/src/interpret/projection.rs +++ b/compiler/rustc_const_eval/src/interpret/projection.rs @@ -326,7 +326,7 @@ where // It is not nice to match on the type, but that seems to be the only way to // implement this. ty::Array(inner, _) => { - (MemPlaceMeta::None, Ty::new_array(self.tcx.tcx, *inner, inner_len)) + (MemPlaceMeta::None, Ty::new_array(self.tcx.tcx, inner, inner_len)) } ty::Slice(..) => { let len = Scalar::from_target_usize(inner_len, self); diff --git a/compiler/rustc_const_eval/src/interpret/terminator.rs b/compiler/rustc_const_eval/src/interpret/terminator.rs index cbfe25ca8df51..c4cb1bda6ae19 100644 --- a/compiler/rustc_const_eval/src/interpret/terminator.rs +++ b/compiler/rustc_const_eval/src/interpret/terminator.rs @@ -133,7 +133,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { let extra_args = self.tcx.mk_type_list_from_iter(extra_args.iter().map(|arg| arg.layout().ty)); - let (fn_val, fn_abi, with_caller_location) = match *func.layout.ty.kind() { + let (fn_val, fn_abi, with_caller_location) = match func.layout.ty.kind() { ty::FnPtr(_sig) => { let fn_ptr = self.read_pointer(&func)?; let fn_val = self.get_ptr_fn(fn_ptr)?; @@ -281,7 +281,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { may_unfold: impl Fn(AdtDef<'tcx>) -> bool, ) -> TyAndLayout<'tcx> { match layout.ty.kind() { - ty::Adt(adt_def, _) if adt_def.repr().transparent() && may_unfold(*adt_def) => { + ty::Adt(adt_def, _) if adt_def.repr().transparent() && may_unfold(adt_def) => { assert!(!adt_def.is_enum()); // Find the non-1-ZST field, and recurse. let (_, field) = layout.non_1zst_field(self).unwrap(); @@ -332,7 +332,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { // Option<&T> behaves like &T, and same for fn() inner } - ty::Adt(def, _) if is_npo(*def) => { + ty::Adt(def, _) if is_npo(def) => { // Once we found a `nonnull_optimization_guaranteed` type, further strip off // newtype structs from it to find the underlying ABI type. self.unfold_transparent(inner, /* may_unfold */ |def| def.is_struct()) @@ -387,8 +387,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { let pointee_ty = |ty: Ty<'tcx>| -> InterpResult<'tcx, Option>> { // We cannot use `builtin_deref` here since we need to reject `Box`. Ok(Some(match ty.kind() { - ty::Ref(_, ty, _) => *ty, - ty::RawPtr(ty, _) => *ty, + ty::Ref(_, ty, _) => ty, + ty::RawPtr(ty, _) => ty, // We only accept `Box` with the default allocator. _ if ty.is_box_global(*self.tcx) => ty.boxed_ty(), _ => return Ok(None), @@ -410,8 +410,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { // `char` counts as `u32.` let int_ty = |ty: Ty<'tcx>| { Some(match ty.kind() { - ty::Int(ity) => (Integer::from_int_ty(&self.tcx, *ity), /* signed */ true), - ty::Uint(uty) => (Integer::from_uint_ty(&self.tcx, *uty), /* signed */ false), + ty::Int(ity) => (Integer::from_int_ty(&self.tcx, ity), /* signed */ true), + ty::Uint(uty) => (Integer::from_uint_ty(&self.tcx, uty), /* signed */ false), ty::Char => (Integer::I32, /* signed */ false), _ => return None, }) diff --git a/compiler/rustc_const_eval/src/interpret/util.rs b/compiler/rustc_const_eval/src/interpret/util.rs index 10fd6399b9a37..98e5fbe0a5148 100644 --- a/compiler/rustc_const_eval/src/interpret/util.rs +++ b/compiler/rustc_const_eval/src/interpret/util.rs @@ -38,7 +38,7 @@ where return ControlFlow::Continue(()); } - match *ty.kind() { + match ty.kind() { ty::Param(_) => ControlFlow::Break(FoundParam), ty::Closure(def_id, args) | ty::CoroutineClosure(def_id, args, ..) diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index e35ce9ef28d61..33815d3c8c645 100644 --- a/compiler/rustc_const_eval/src/interpret/validity.rs +++ b/compiler/rustc_const_eval/src/interpret/validity.rs @@ -590,7 +590,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> { Ok(true) } ty::Ref(_, _ty, mutbl) => { - self.check_safe_pointer(value, PointerKind::Ref(*mutbl))?; + self.check_safe_pointer(value, PointerKind::Ref(mutbl))?; Ok(true) } ty::FnPtr(_sig) => { @@ -878,7 +878,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValueVisitor<'tcx, M> for ValidityVisitor<'rt, // This is the length of the array/slice. let len = op.len(self.ecx)?; // This is the element type size. - let layout = self.ecx.layout_of(*tys)?; + let layout = self.ecx.layout_of(tys)?; // This is the size in bytes of the whole array. (This checks for overflow.) let size = layout.size * len; // If the size is 0, there is nothing to check. @@ -937,7 +937,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValueVisitor<'tcx, M> for ValidityVisitor<'rt, // Fast path for arrays and slices of ZSTs. We only need to check a single ZST element // of an array and not all of them, because there's only a single value of a specific // ZST type, so either validation fails for all elements or none. - ty::Array(tys, ..) | ty::Slice(tys) if self.ecx.layout_of(*tys)?.is_zst() => { + ty::Array(tys, ..) | ty::Slice(tys) if self.ecx.layout_of(tys)?.is_zst() => { // Validate just the first element (if any). if op.len(self.ecx)? > 0 { self.visit_field(op, 0, &self.ecx.project_index(op, 0)?)?; diff --git a/compiler/rustc_const_eval/src/interpret/visitor.rs b/compiler/rustc_const_eval/src/interpret/visitor.rs index b812e89854b20..8e4956cdb73c5 100644 --- a/compiler/rustc_const_eval/src/interpret/visitor.rs +++ b/compiler/rustc_const_eval/src/interpret/visitor.rs @@ -87,7 +87,7 @@ pub trait ValueVisitor<'tcx, M: Machine<'tcx>>: Sized { trace!("walk_value: type: {ty}"); // Special treatment for special types, where the (static) layout is not sufficient. - match *ty.kind() { + match ty.kind() { // If it is a trait object, switch to the real type that was used to create it. ty::Dynamic(data, _, ty::Dyn) => { // Dyn types. This is unsized, and the actual dynamic type of the data is given by the diff --git a/compiler/rustc_const_eval/src/util/type_name.rs b/compiler/rustc_const_eval/src/util/type_name.rs index 01e517250f77e..bf5f79889cffe 100644 --- a/compiler/rustc_const_eval/src/util/type_name.rs +++ b/compiler/rustc_const_eval/src/util/type_name.rs @@ -24,7 +24,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> { } fn print_type(&mut self, ty: Ty<'tcx>) -> Result<(), PrintError> { - match *ty.kind() { + match ty.kind() { // Types without identity. ty::Bool | ty::Char diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 76b6cbd6e5310..095179e6b33ba 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -162,7 +162,7 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b } ty::Array(elem, _len) => { // Like `Copy`, we do *not* special-case length 0. - allowed_union_field(*elem, tcx, param_env) + allowed_union_field(elem, tcx, param_env) } _ => { // Fallback case: allow `ManuallyDrop` and things that are `Copy`, @@ -653,7 +653,7 @@ fn check_static_linkage(tcx: TyCtxt<'_>, def_id: LocalDefId) { if tcx.codegen_fn_attrs(def_id).import_linkage.is_some() { if match tcx.type_of(def_id).instantiate_identity().kind() { ty::RawPtr(_, _) => false, - ty::Adt(adt_def, args) => !is_enum_of_nonnullable_ptr(tcx, *adt_def, *args), + ty::Adt(adt_def, args) => !is_enum_of_nonnullable_ptr(tcx, adt_def, args), _ => true, } { tcx.dcx().emit_err(errors::LinkageType { span: tcx.def_span(def_id) }); @@ -1253,7 +1253,7 @@ pub(super) fn check_transparent<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>) ) -> ControlFlow<(&'static str, DefId, GenericArgsRef<'tcx>, bool)> { match t.kind() { ty::Tuple(list) => list.iter().try_for_each(|t| check_non_exhaustive(tcx, t)), - ty::Array(ty, _) => check_non_exhaustive(tcx, *ty), + ty::Array(ty, _) => check_non_exhaustive(tcx, ty), ty::Adt(def, args) => { if !def.did().is_local() { let non_exhaustive = def.is_variant_list_non_exhaustive() @@ -1634,7 +1634,7 @@ fn opaque_type_cycle_error( } impl<'tcx> ty::visit::TypeVisitor> for OpaqueTypeCollector { fn visit_ty(&mut self, t: Ty<'tcx>) { - match *t.kind() { + match t.kind() { ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => { self.opaques.push(def); } @@ -1671,7 +1671,7 @@ fn opaque_type_cycle_error( && let ty::Alias( ty::Opaque, ty::AliasTy { def_id: captured_def_id, .. }, - ) = *ty.kind() + ) = ty.kind() && captured_def_id == opaque_def_id.to_def_id() { err.span_label( 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 82b57cdd10691..a7b315d5431fb 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -858,7 +858,7 @@ impl<'tcx> ty::FallibleTypeFolder> for RemapHiddenTyRegions<'tcx> { } fn try_fold_ty(&mut self, t: Ty<'tcx>) -> Result, Self::Error> { - if let ty::Alias(ty::Opaque, ty::AliasTy { args, def_id, .. }) = *t.kind() { + if let ty::Alias(ty::Opaque, ty::AliasTy { args, def_id, .. }) = t.kind() { let mut mapped_args = Vec::with_capacity(args.len()); for (arg, v) in std::iter::zip(args, self.tcx.variances_of(def_id)) { mapped_args.push(match (arg.unpack(), v) { @@ -2266,7 +2266,7 @@ fn try_report_async_mismatch<'tcx>( } let ty::Alias(ty::Projection, ty::AliasTy { def_id: async_future_def_id, .. }) = - *tcx.fn_sig(trait_m.def_id).skip_binder().skip_binder().output().kind() + tcx.fn_sig(trait_m.def_id).skip_binder().skip_binder().output().kind() else { bug!("expected `async fn` to return an RPITIT"); }; diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs index 10b097a1060f3..e19dc4c57ed7a 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs @@ -76,7 +76,7 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>( let hidden_ty = hidden_tys[&trait_projection.def_id].instantiate(tcx, impl_opaque_args); // If the hidden type is not an opaque, then we have "refined" the trait signature. - let ty::Alias(ty::Opaque, impl_opaque) = *hidden_ty.kind() else { + let ty::Alias(ty::Opaque, impl_opaque) = hidden_ty.kind() else { report_mismatched_rpitit_signature( tcx, trait_m_sig_with_self_for_diag, @@ -212,7 +212,7 @@ struct ImplTraitInTraitCollector<'tcx> { impl<'tcx> TypeVisitor> for ImplTraitInTraitCollector<'tcx> { fn visit_ty(&mut self, ty: Ty<'tcx>) { - if let ty::Alias(ty::Projection, proj) = *ty.kind() + if let ty::Alias(ty::Projection, proj) = ty.kind() && self.tcx.is_impl_trait_in_trait(proj.def_id) { if self.types.insert(proj) { @@ -304,7 +304,7 @@ fn report_mismatched_rpitit_signature<'tcx>( } fn type_visibility<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option> { - match *ty.kind() { + match ty.kind() { ty::Ref(_, ty, _) => type_visibility(tcx, ty), ty::Adt(def, args) => { if def.is_fundamental() { diff --git a/compiler/rustc_hir_analysis/src/check/intrinsicck.rs b/compiler/rustc_hir_analysis/src/check/intrinsicck.rs index 2672614a89548..0962e2e391922 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsicck.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsicck.rs @@ -55,7 +55,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> { width => bug!("unsupported pointer width: {width}"), }; - match *ty.kind() { + match ty.kind() { ty::Int(IntTy::I8) | ty::Uint(UintTy::U8) => Some(InlineAsmType::I8), ty::Int(IntTy::I16) | ty::Uint(UintTy::U16) => Some(InlineAsmType::I16), ty::Int(IntTy::I32) | ty::Uint(UintTy::U32) => Some(InlineAsmType::I32), @@ -75,7 +75,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> { if let Some(len) = len.try_eval_target_usize(self.tcx, self.tcx.param_env(adt.did())) { - (len, *ty) + (len, ty) } else { return None; } @@ -130,7 +130,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> { bug!("inference variable in asm operand ty: {:?} {:?}", expr, ty); } - let asm_ty = match *ty.kind() { + let asm_ty = match ty.kind() { // `!` is allowed for input but not for output (issue #87802) ty::Never if is_input => return None, _ if ty.references_error() => return None, diff --git a/compiler/rustc_hir_analysis/src/check/mod.rs b/compiler/rustc_hir_analysis/src/check/mod.rs index 4d1b96d9c1bac..a70fa224e1f09 100644 --- a/compiler/rustc_hir_analysis/src/check/mod.rs +++ b/compiler/rustc_hir_analysis/src/check/mod.rs @@ -438,7 +438,7 @@ fn fn_sig_suggestion<'tcx>( let mut output = sig.output(); let asyncness = if tcx.asyncness(assoc.def_id).is_async() { - output = if let ty::Alias(_, alias_ty) = *output.kind() { + output = if let ty::Alias(_, alias_ty) = output.kind() { tcx.explicit_item_super_predicates(alias_ty.def_id) .iter_instantiated_copied(tcx, alias_ty.args) .find_map(|(bound, _)| { diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index b206d8046ee9c..62dcbbdbd52a4 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -157,13 +157,13 @@ where for ty in assumed_wf_types.iter() { match ty.kind() { ty::Adt(def, _) => { - if is_bevy_paramset(*def) { + if is_bevy_paramset(def) { break 'is_bevy true; } } ty::Ref(_, ty, _) => match ty.kind() { ty::Adt(def, _) => { - if is_bevy_paramset(*def) { + if is_bevy_paramset(def) { break 'is_bevy true; } } @@ -976,11 +976,11 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(), match ty.kind() { ty::Adt(adt_def, ..) => adt_def.did().is_local(), // Arrays and slices use the inner type's `ConstParamTy`. - ty::Array(ty, ..) => ty_is_local(*ty), - ty::Slice(ty) => ty_is_local(*ty), + ty::Array(ty, ..) => ty_is_local(ty), + ty::Slice(ty) => ty_is_local(ty), // `&` references use the inner type's `ConstParamTy`. // `&mut` are not supported. - ty::Ref(_, ty, ast::Mutability::Not) => ty_is_local(*ty), + ty::Ref(_, ty, ast::Mutability::Not) => ty_is_local(ty), // Say that a tuple is local if any of its components are local. // This is not strictly correct, but it's likely that the user can fix the local component. ty::Tuple(tys) => tys.iter().any(|ty| ty_is_local(ty)), diff --git a/compiler/rustc_hir_analysis/src/coherence/builtin.rs b/compiler/rustc_hir_analysis/src/coherence/builtin.rs index 61adb7a3cbaeb..4ea83db5d4ab4 100644 --- a/compiler/rustc_hir_analysis/src/coherence/builtin.rs +++ b/compiler/rustc_hir_analysis/src/coherence/builtin.rs @@ -190,11 +190,9 @@ fn visit_implementation_of_dispatch_from_dyn(checker: &Checker<'_>) -> Result<() // even if they do not carry that attribute. use rustc_type_ir::TyKind::*; match (source.kind(), target.kind()) { - (&Ref(r_a, _, mutbl_a), Ref(r_b, _, mutbl_b)) if r_a == *r_b && mutbl_a == *mutbl_b => { - Ok(()) - } - (&RawPtr(_, a_mutbl), &RawPtr(_, b_mutbl)) if a_mutbl == b_mutbl => Ok(()), - (&Adt(def_a, args_a), &Adt(def_b, args_b)) if def_a.is_struct() && def_b.is_struct() => { + (Ref(r_a, _, mutbl_a), Ref(r_b, _, mutbl_b)) if r_a == r_b && mutbl_a == mutbl_b => Ok(()), + (RawPtr(_, a_mutbl), RawPtr(_, b_mutbl)) if a_mutbl == b_mutbl => Ok(()), + (Adt(def_a, args_a), Adt(def_b, args_b)) if def_a.is_struct() && def_b.is_struct() => { if def_a != def_b { let source_path = tcx.def_path_str(def_a.did()); let target_path = tcx.def_path_str(def_b.did()); @@ -338,26 +336,26 @@ pub fn coerce_unsized_info<'tcx>( (mt_a.ty, mt_b.ty, unsize_trait, None) }; let (source, target, trait_def_id, kind) = match (source.kind(), target.kind()) { - (&ty::Ref(r_a, ty_a, mutbl_a), &ty::Ref(r_b, ty_b, mutbl_b)) => { + (ty::Ref(r_a, ty_a, mutbl_a), ty::Ref(r_b, ty_b, mutbl_b)) => { infcx.sub_regions(infer::RelateObjectBound(span), r_b, r_a); let mt_a = ty::TypeAndMut { ty: ty_a, mutbl: mutbl_a }; let mt_b = ty::TypeAndMut { ty: ty_b, mutbl: mutbl_b }; check_mutbl(mt_a, mt_b, &|ty| Ty::new_imm_ref(tcx, r_b, ty)) } - (&ty::Ref(_, ty_a, mutbl_a), &ty::RawPtr(ty_b, mutbl_b)) => check_mutbl( + (ty::Ref(_, ty_a, mutbl_a), ty::RawPtr(ty_b, mutbl_b)) => check_mutbl( ty::TypeAndMut { ty: ty_a, mutbl: mutbl_a }, ty::TypeAndMut { ty: ty_b, mutbl: mutbl_b }, &|ty| Ty::new_imm_ptr(tcx, ty), ), - (&ty::RawPtr(ty_a, mutbl_a), &ty::RawPtr(ty_b, mutbl_b)) => check_mutbl( + (ty::RawPtr(ty_a, mutbl_a), ty::RawPtr(ty_b, mutbl_b)) => check_mutbl( ty::TypeAndMut { ty: ty_a, mutbl: mutbl_a }, ty::TypeAndMut { ty: ty_b, mutbl: mutbl_b }, &|ty| Ty::new_imm_ptr(tcx, ty), ), - (&ty::Adt(def_a, args_a), &ty::Adt(def_b, args_b)) + (ty::Adt(def_a, args_a), ty::Adt(def_b, args_b)) if def_a.is_struct() && def_b.is_struct() => { if def_a != def_b { diff --git a/compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs b/compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs index e2d3ff558cf7d..fae9a447179a6 100644 --- a/compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs +++ b/compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs @@ -123,7 +123,7 @@ impl<'tcx> InherentCollect<'tcx> { let span = self.tcx.def_span(impl_def_id); let mut note = None; if let ty::Ref(_, subty, _) = ty.kind() { - note = Some(errors::InherentPrimitiveTyNote { subty: *subty }); + note = Some(errors::InherentPrimitiveTyNote { subty }); } return Err(self.tcx.dcx().emit_err(errors::InherentPrimitiveTy { span, note })); } @@ -148,10 +148,10 @@ impl<'tcx> InherentCollect<'tcx> { let mut self_ty = self.tcx.peel_off_weak_alias_tys(self_ty); // We allow impls on pattern types exactly when we allow impls on the base type. // FIXME(pattern_types): Figure out the exact coherence rules we want here. - while let ty::Pat(base, _) = *self_ty.kind() { + while let ty::Pat(base, _) = self_ty.kind() { self_ty = base; } - match *self_ty.kind() { + match self_ty.kind() { ty::Adt(def, _) => self.check_def_id(id, self_ty, def.did()), ty::Foreign(did) => self.check_def_id(id, self_ty, did), ty::Dynamic(data, ..) if data.principal_def_id().is_some() => { diff --git a/compiler/rustc_hir_analysis/src/coherence/orphan.rs b/compiler/rustc_hir_analysis/src/coherence/orphan.rs index 61ac4af015194..f8bb761fa51d0 100644 --- a/compiler/rustc_hir_analysis/src/coherence/orphan.rs +++ b/compiler/rustc_hir_analysis/src/coherence/orphan.rs @@ -400,7 +400,7 @@ fn emit_orphan_check_error<'tcx>( let is_foreign = !trait_ref.def_id.is_local() && matches!(is_target_ty, IsFirstInputType::No); - match *ty.kind() { + match ty.kind() { ty::Slice(_) => { if is_foreign { diag.subdiagnostic( diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 092d2d304c38e..92086ced03424 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -996,7 +996,7 @@ impl<'tcx> FieldUniquenessCheckContext<'tcx> { // Here we don't care about the generic parameters, so `instantiate_identity` is enough. match self.tcx.type_of(field.did).instantiate_identity().kind() { ty::Adt(adt_def, _) => { - self.check_field_in_nested_adt(*adt_def, unnamed_field_span); + self.check_field_in_nested_adt(adt_def, unnamed_field_span); } ty_kind => span_bug!( self.tcx.def_span(field.did), @@ -1543,7 +1543,7 @@ pub fn suggest_impl_trait<'tcx>( item_ty: Ty<'tcx>| { let trait_name = tcx.item_name(trait_def_id); let args_tuple = args.type_at(1); - let ty::Tuple(types) = *args_tuple.kind() else { + let ty::Tuple(types) = args_tuple.kind() else { return None; }; let types = types.make_suggestable(tcx, false, None)?; diff --git a/compiler/rustc_hir_analysis/src/constrained_generic_params.rs b/compiler/rustc_hir_analysis/src/constrained_generic_params.rs index 620170164f535..a032e12c55a53 100644 --- a/compiler/rustc_hir_analysis/src/constrained_generic_params.rs +++ b/compiler/rustc_hir_analysis/src/constrained_generic_params.rs @@ -62,7 +62,7 @@ struct ParameterCollector { impl<'tcx> TypeVisitor> for ParameterCollector { fn visit_ty(&mut self, t: Ty<'tcx>) { - match *t.kind() { + match t.kind() { // Projections are not injective in general. ty::Alias(ty::Projection | ty::Inherent | ty::Opaque, _) if !self.include_nonconstraining => diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs index 7f6f57907c28b..b11803c425e2b 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs @@ -378,7 +378,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { // Next, we need to check that the return-type notation is being used on // an RPITIT (return-position impl trait in trait) or AFIT (async fn in trait). let output = tcx.fn_sig(assoc_item.def_id).skip_binder().output(); - let output = if let ty::Alias(ty::Projection, alias_ty) = *output.skip_binder().kind() + let output = if let ty::Alias(ty::Projection, alias_ty) = output.skip_binder().kind() && tcx.is_impl_trait_in_trait(alias_ty.def_id) { alias_ty.into() @@ -628,7 +628,7 @@ impl<'tcx> TypeVisitor> for GenericParamAndBoundVarCollector<'tcx> ty::Param(param) => { self.params.insert(param.index); } - ty::Bound(db, bt) if *db >= self.depth => { + ty::Bound(db, bt) if db >= self.depth => { self.vars.insert(match bt.kind { ty::BoundTyKind::Param(def_id, name) => (def_id, name), ty::BoundTyKind::Anon => { diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs index 3a9ef244fd3f5..656a102b4a7c3 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs @@ -1505,7 +1505,7 @@ fn generics_args_err_extend<'a>( GenericsArgsErrExtend::SelfTyAlias { def_id, span } => { let ty = tcx.at(span).type_of(def_id).instantiate_identity(); let span_of_impl = tcx.span_of_impl(def_id); - let def_id = match *ty.kind() { + let def_id = match ty.kind() { ty::Adt(self_def, _) => self_def.did(), _ => return, }; diff --git a/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs b/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs index af08f50f65596..8fabd59f9a79b 100644 --- a/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs +++ b/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs @@ -114,7 +114,7 @@ fn insert_required_predicates_to_be_wf<'tcx>( GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => continue, }; - match *leaf_ty.kind() { + match leaf_ty.kind() { ty::Ref(region, rty, _) => { // The type is `&'a T` which means that we will have // a predicate requirement of `T: 'a` (`T` outlives `'a`). diff --git a/compiler/rustc_hir_analysis/src/variance/constraints.rs b/compiler/rustc_hir_analysis/src/variance/constraints.rs index 0c436e21c16d9..e3123975bed62 100644 --- a/compiler/rustc_hir_analysis/src/variance/constraints.rs +++ b/compiler/rustc_hir_analysis/src/variance/constraints.rs @@ -224,7 +224,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { ) { debug!("add_constraints_from_ty(ty={:?}, variance={:?})", ty, variance); - match *ty.kind() { + match ty.kind() { ty::Bool | ty::Char | ty::Int(_) diff --git a/compiler/rustc_hir_analysis/src/variance/mod.rs b/compiler/rustc_hir_analysis/src/variance/mod.rs index 1977451f39e0a..3d2847c551d69 100644 --- a/compiler/rustc_hir_analysis/src/variance/mod.rs +++ b/compiler/rustc_hir_analysis/src/variance/mod.rs @@ -115,9 +115,9 @@ fn variance_of_opaque(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Varianc fn visit_ty(&mut self, t: Ty<'tcx>) { match t.kind() { ty::Alias(_, ty::AliasTy { def_id, args, .. }) - if matches!(self.tcx.def_kind(*def_id), DefKind::OpaqueTy) => + if matches!(self.tcx.def_kind(def_id), DefKind::OpaqueTy) => { - self.visit_opaque(*def_id, args); + self.visit_opaque(def_id, args); } _ => t.super_visit_with(self), } diff --git a/compiler/rustc_hir_typeck/src/_match.rs b/compiler/rustc_hir_typeck/src/_match.rs index a599e8d05fd3c..8d63565be66f8 100644 --- a/compiler/rustc_hir_typeck/src/_match.rs +++ b/compiler/rustc_hir_typeck/src/_match.rs @@ -588,7 +588,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expectation: Expectation<'tcx>, ) -> Option { let expected_ty = expectation.to_option(self)?; - let (def_id, args) = match *expected_ty.kind() { + let (def_id, args) = match expected_ty.kind() { // FIXME: Could also check that the RPIT is not defined ty::Alias(ty::Opaque, alias_ty) => (alias_ty.def_id.as_local()?, alias_ty.args), // FIXME(-Znext-solver): Remove this branch once `replace_opaque_types_with_infer` is gone. diff --git a/compiler/rustc_hir_typeck/src/autoderef.rs b/compiler/rustc_hir_typeck/src/autoderef.rs index 2bb7caea3c432..cb0fa8e1d431f 100644 --- a/compiler/rustc_hir_typeck/src/autoderef.rs +++ b/compiler/rustc_hir_typeck/src/autoderef.rs @@ -48,7 +48,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.try_overloaded_deref(autoderef.span(), source).and_then( |InferOk { value: method, obligations: o }| { obligations.extend(o); - if let ty::Ref(region, _, mutbl) = *method.sig.output().kind() { + if let ty::Ref(region, _, mutbl) = method.sig.output().kind() { Some(OverloadedDeref { region, mutbl, span: autoderef.span() }) } else { None diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 9736c8b89204e..d5aaa0417e021 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -140,7 +140,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.structurally_resolve_type(autoderef.span(), autoderef.final_ty(false)); // If the callee is a bare function or a closure, then we're all set. - match *adjusted_ty.kind() { + match adjusted_ty.kind() { ty::FnDef(..) | ty::FnPtr(_) => { let adjustments = self.adjust_steps(autoderef); self.apply_adjustments(callee_expr, adjustments); @@ -323,10 +323,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // For initial two-phase borrow // deployment, conservatively omit // overloaded function call ops. - let mutbl = AutoBorrowMutability::new(*mutbl, AllowTwoPhase::No); + let mutbl = AutoBorrowMutability::new(mutbl, AllowTwoPhase::No); autoref = Some(Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(*region, mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)), target: method.sig.inputs()[0], }); } @@ -437,7 +437,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { arg_exprs: &'tcx [hir::Expr<'tcx>], expected: Expectation<'tcx>, ) -> Ty<'tcx> { - let (fn_sig, def_id) = match *callee_ty.kind() { + let (fn_sig, def_id) = match callee_ty.kind() { ty::FnDef(def_id, args) => { self.enforce_context_effects(call_expr.span, def_id, args); let fn_sig = self.tcx.fn_sig(def_id).instantiate(self.tcx, args); @@ -551,7 +551,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // in the function signature (`F: FnOnce`), so I did not bother to add another check here. // // This check is here because there is currently no way to express a trait bound for `FnDef` types only. - if let ty::FnDef(def_id, _args) = *arg_ty.kind() { + if let ty::FnDef(def_id, _args) = arg_ty.kind() { let fn_once_def_id = self.tcx.require_lang_item(hir::LangItem::FnOnce, Some(span)); let fn_once_output_def_id = diff --git a/compiler/rustc_hir_typeck/src/cast.rs b/compiler/rustc_hir_typeck/src/cast.rs index 9e9a1f678edd7..37a6f17d2e288 100644 --- a/compiler/rustc_hir_typeck/src/cast.rs +++ b/compiler/rustc_hir_typeck/src/cast.rs @@ -99,7 +99,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return Ok(Some(PointerKind::Thin)); } - Ok(match *t.kind() { + Ok(match t.kind() { ty::Slice(_) | ty::Str => Some(PointerKind::Length), 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() { @@ -363,15 +363,15 @@ impl<'a, 'tcx> CastCheck<'tcx> { ); let mut sugg = None; let mut sugg_mutref = false; - if let ty::Ref(reg, cast_ty, mutbl) = *self.cast_ty.kind() { - if let ty::RawPtr(expr_ty, _) = *self.expr_ty.kind() + if let ty::Ref(reg, cast_ty, mutbl) = self.cast_ty.kind() { + if let ty::RawPtr(expr_ty, _) = self.expr_ty.kind() && fcx.can_coerce( Ty::new_ref(fcx.tcx, fcx.tcx.lifetimes.re_erased, expr_ty, mutbl), self.cast_ty, ) { sugg = Some((format!("&{}*", mutbl.prefix_str()), cast_ty == expr_ty)); - } else if let ty::Ref(expr_reg, expr_ty, expr_mutbl) = *self.expr_ty.kind() + } else if let ty::Ref(expr_reg, expr_ty, expr_mutbl) = self.expr_ty.kind() && expr_mutbl == Mutability::Not && mutbl == Mutability::Mut && fcx.can_coerce(Ty::new_mut_ref(fcx.tcx, expr_reg, expr_ty), self.cast_ty) @@ -388,7 +388,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { { sugg = Some((format!("&{}", mutbl.prefix_str()), false)); } - } else if let ty::RawPtr(_, mutbl) = *self.cast_ty.kind() + } else if let ty::RawPtr(_, mutbl) = self.cast_ty.kind() && fcx.can_coerce( Ty::new_ref(fcx.tcx, fcx.tcx.lifetimes.re_erased, self.expr_ty, mutbl), self.cast_ty, @@ -685,7 +685,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { (Some(t_from), Some(t_cast)) => (t_from, t_cast), // Function item types may need to be reified before casts. (None, Some(t_cast)) => { - match *self.expr_ty.kind() { + match self.expr_ty.kind() { ty::FnDef(..) => { // Attempt a coercion to a fn pointer type. let f = fcx.normalize(self.expr_span, self.expr_ty.fn_sig(fcx.tcx)); @@ -710,7 +710,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { // a cast. ty::Ref(_, inner_ty, mutbl) => { return match t_cast { - Int(_) | Float => match *inner_ty.kind() { + Int(_) | Float => match inner_ty.kind() { ty::Int(_) | ty::Uint(_) | ty::Float(_) @@ -734,7 +734,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { } _ => return Err(CastError::NonScalar), }; - if let ty::Adt(adt_def, _) = *self.expr_ty.kind() { + if let ty::Adt(adt_def, _) = self.expr_ty.kind() { if adt_def.did().krate != LOCAL_CRATE { if adt_def.variants().iter().any(VariantDef::is_field_list_non_exhaustive) { return Err(CastError::ForeignNonExhaustiveAdt); @@ -896,7 +896,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { }); // this will report a type mismatch if needed - fcx.demand_eqtype(self.span, *ety, m_cast.ty); + fcx.demand_eqtype(self.span, ety, m_cast.ty); return Ok(CastKind::ArrayPtrCast); } } diff --git a/compiler/rustc_hir_typeck/src/closure.rs b/compiler/rustc_hir_typeck/src/closure.rs index ac7ed3e26f976..ced8bb92380d9 100644 --- a/compiler/rustc_hir_typeck/src/closure.rs +++ b/compiler/rustc_hir_typeck/src/closure.rs @@ -311,7 +311,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expected_ty: Ty<'tcx>, closure_kind: hir::ClosureKind, ) -> (Option>, Option) { - match *expected_ty.kind() { + match expected_ty.kind() { ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => self .deduce_closure_signature_from_predicates( expected_ty, @@ -480,7 +480,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let arg_param_ty = self.resolve_vars_if_possible(arg_param_ty); debug!(?arg_param_ty); - let ty::Tuple(input_tys) = *arg_param_ty.kind() else { + let ty::Tuple(input_tys) = arg_param_ty.kind() else { return None; }; @@ -869,7 +869,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } }; - let output_ty = match *ret_ty.kind() { + let output_ty = match ret_ty.kind() { ty::Infer(ty::TyVar(ret_vid)) => { self.obligations_for_self_ty(ret_vid).into_iter().find_map(|obligation| { get_future_output(obligation.predicate, obligation.cause.span) diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 93726ce2b3eb1..9e3269767111a 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -202,7 +202,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { } // Examine the supertype and consider auto-borrowing. - match *b.kind() { + match b.kind() { ty::RawPtr(_, b_mutbl) => { return self.coerce_unsafe_ptr(a, b, b_mutbl); } @@ -215,7 +215,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { _ => {} } - match *a.kind() { + match a.kind() { ty::FnDef(..) => { // Function items are coercible to any closure // type; function pointers are not (that would @@ -305,7 +305,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { // to type check, we will construct the type that `&M*expr` would // yield. - let (r_a, mt_a) = match *a.kind() { + let (r_a, mt_a) = match a.kind() { ty::Ref(r_a, ty, mutbl) => { let mt_a = ty::TypeAndMut { ty, mutbl }; coerce_mutbls(mt_a.mutbl, mutbl_b)?; @@ -469,7 +469,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { }; let mutbl = AutoBorrowMutability::new(mutbl_b, self.allow_two_phase); adjustments.push(Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(*r_borrow, mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(r_borrow, mutbl)), target: ty, }); @@ -515,7 +515,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { // Handle reborrows before selecting `Source: CoerceUnsized`. let reborrow = match (source.kind(), target.kind()) { - (&ty::Ref(_, ty_a, mutbl_a), &ty::Ref(_, _, mutbl_b)) => { + (ty::Ref(_, ty_a, mutbl_a), ty::Ref(_, _, mutbl_b)) => { coerce_mutbls(mutbl_a, mutbl_b)?; let coercion = Coercion(self.cause.span); @@ -534,7 +534,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { }, )) } - (&ty::Ref(_, ty_a, mt_a), &ty::RawPtr(_, mt_b)) => { + (ty::Ref(_, ty_a, mt_a), ty::RawPtr(_, mt_b)) => { coerce_mutbls(mt_a, mt_b)?; Some(( @@ -627,7 +627,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { let unsize_ty = trait_pred.trait_ref.args[1].expect_ty(); debug!("coerce_unsized: ambiguous unsize case for {:?}", trait_pred); match (self_ty.kind(), unsize_ty.kind()) { - (&ty::Infer(ty::TyVar(v)), ty::Dynamic(..)) + (ty::Infer(ty::TyVar(v)), ty::Dynamic(..)) if self.type_var_is_sized(v) => { debug!("coerce_unsized: have sized infer {:?}", v); @@ -843,7 +843,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { match b.kind() { ty::FnPtr(b_sig) => { let a_sig = a.fn_sig(self.tcx); - if let ty::FnDef(def_id, _) = *a.kind() { + if let ty::FnDef(def_id, _) = a.kind() { // Intrinsics are not coercible to function pointers if self.tcx.intrinsic(def_id).is_some() { return Err(TypeError::IntrinsicCast); @@ -944,7 +944,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { ) -> CoerceResult<'tcx> { debug!("coerce_unsafe_ptr(a={:?}, b={:?})", a, b); - let (is_ref, mt_a) = match *a.kind() { + let (is_ref, mt_a) = match a.kind() { ty::Ref(_, ty, mutbl) => (true, ty::TypeAndMut { ty, mutbl }), ty::RawPtr(ty, mutbl) => (false, ty::TypeAndMut { ty, mutbl }), _ => return self.unify_and(a, b, identity), @@ -1096,7 +1096,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Function items or non-capturing closures of differing IDs or GenericArgs. let (a_sig, b_sig) = { let is_capturing_closure = |ty: Ty<'tcx>| { - if let &ty::Closure(closure_def_id, _args) = ty.kind() { + if let ty::Closure(closure_def_id, _args) = ty.kind() { self.tcx.upvars_mentioned(closure_def_id.expect_local()).is_some() } else { false @@ -1224,7 +1224,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Adjustment { kind: Adjust::Deref(_), .. }, Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(_, mutbl_adj)), .. }, ] => { - match *self.node_ty(expr.hir_id).kind() { + match self.node_ty(expr.hir_id).kind() { ty::Ref(_, _, mt_orig) => { let mutbl_adj: hir::Mutability = mutbl_adj.into(); // Reborrow that we can safely ignore, because diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 7dd7b3ff055e5..4f7983dcee089 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -391,7 +391,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { hir::UnOp::Not => { let result = self.check_user_unop(expr, oprnd_t, unop, expected_inner); // If it's builtin, we can reuse the type, this helps inference. - if !(oprnd_t.is_integral() || *oprnd_t.kind() == ty::Bool) { + if !(oprnd_t.is_integral() || oprnd_t.kind() == ty::Bool) { oprnd_t = result; } } @@ -422,9 +422,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Places may legitimately have unsized types. // For example, dereferences of a fat pointer and // the last field of a struct can be unsized. - ExpectHasType(*ty) + ExpectHasType(ty) } else { - Expectation::rvalue_hint(self, *ty) + Expectation::rvalue_hint(self, ty) } } _ => NoExpectation, @@ -532,7 +532,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } }; - if let ty::FnDef(did, _) = *ty.kind() { + if let ty::FnDef(did, _) = ty.kind() { let fn_sig = ty.fn_sig(tcx); if tcx.is_intrinsic(did, sym::transmute) { @@ -1404,7 +1404,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let element_ty = if !args.is_empty() { let coerce_to = expected .to_option(self) - .and_then(|uty| match *uty.kind() { + .and_then(|uty| match uty.kind() { ty::Array(ty, _) | ty::Slice(ty) => Some(ty), _ => None, }) @@ -1470,7 +1470,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } let uty = match expected { - ExpectHasType(uty) => match *uty.kind() { + ExpectHasType(uty) => match uty.kind() { ty::Array(ty, _) | ty::Slice(ty) => Some(ty), _ => None, }, @@ -1525,7 +1525,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // out into a separate constant (or a const block in the future), so we check that // to tell them that in the diagnostic. Does not affect typeck. let is_constable = match element.kind { - hir::ExprKind::Call(func, _args) => match *self.node_ty(func.hir_id).kind() { + hir::ExprKind::Call(func, _args) => match self.node_ty(func.hir_id).kind() { ty::FnDef(def_id, _) if tcx.is_const_fn(def_id) => traits::IsConstable::Fn, _ => traits::IsConstable::No, }, @@ -1823,7 +1823,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // `MyStruct<'a, _, F2, C>`, as opposed to just `_`... // This is important to allow coercions to happen in // `other_struct` itself. See `coerce-in-base-expr.rs`. - let fresh_base_ty = Ty::new_adt(self.tcx, *adt, fresh_args); + let fresh_base_ty = Ty::new_adt(self.tcx, adt, fresh_args); self.check_expr_has_type_or_error( base_expr, self.resolve_vars_if_possible(fresh_base_ty), @@ -2328,7 +2328,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let body_hir_id = self.tcx.local_def_id_to_hir_id(self.body_id); let (ident, def_scope) = self.tcx.adjust_ident_and_get_scope(field, base_def.did(), body_hir_id); - let mut adt_def = *base_def; + let mut adt_def = base_def; let mut last_ty = None; let mut nested_fields = Vec::new(); let mut index = None; @@ -2536,7 +2536,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); let mut err = self.no_such_field_err(ident, base_ty, base.hir_id); - match *base_ty.peel_refs().kind() { + match base_ty.peel_refs().kind() { ty::Array(_, len) => { self.maybe_suggest_array_indexing(&mut err, expr, base, ident, len); } @@ -2870,7 +2870,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // For compile-time reasons put a limit on number of fields we search .take(100) .collect::>(), - *args, + args, )); } _ => None, @@ -3191,7 +3191,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // function. if is_input { let ty = self.structurally_resolve_type(expr.span, ty); - match *ty.kind() { + match ty.kind() { ty::FnDef(..) => { let fnptr_ty = Ty::new_fn_ptr(self.tcx, ty.fn_sig(self.tcx)); self.demand_coerce(expr, ty, fnptr_ty, None, AllowTwoPhase::No); diff --git a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs index 0ba4bd090f5e2..1a9e6feadb8ad 100644 --- a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs +++ b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs @@ -1473,7 +1473,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx let base_ty = self.expr_ty_adjusted(base)?; let ty::Ref(region, _, mutbl) = - *self.cx.try_structurally_resolve_type(base.span, base_ty).kind() + self.cx.try_structurally_resolve_type(base.span, base_ty).kind() else { span_bug!(expr.span, "cat_overloaded_place: base is not a reference"); }; 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 4edc11d7ab15b..680cc41eadcb9 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 @@ -47,7 +47,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { predicate_args.iter().find_map(|arg| { arg.walk().find_map(|arg| { if let ty::GenericArgKind::Type(ty) = arg.unpack() - && let ty::Param(param_ty) = *ty.kind() + && let ty::Param(param_ty) = ty.kind() && matches(ty::ParamTerm::Ty(param_ty)) { Some(arg) @@ -364,7 +364,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { )) = error.code && let ty::Closure(def_id, _) | ty::Coroutine(def_id, ..) = expected_trait_ref.self_ty().kind() - && span.overlaps(self.tcx.def_span(*def_id)) + && span.overlaps(self.tcx.def_span(def_id)) { true } else { @@ -648,7 +648,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return self.blame_specific_part_of_expr_corresponding_to_generic_param( param, borrowed_expr, - (*ty_ref_type).into(), + ty_ref_type.into(), ); } @@ -882,7 +882,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .variant_with_id(variant_def_id) .fields .iter() - .map(|field| field.ty(self.tcx, *in_ty_adt_generic_args)) + .map(|field| field.ty(self.tcx, in_ty_adt_generic_args)) .enumerate() .filter(|(_index, field_type)| find_param_in_ty((*field_type).into(), param)), ) else { diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index b8333d4749378..4e7619abd35a0 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -1534,7 +1534,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Ok((variant, ty.normalized)) } else { - Err(match *ty.normalized.kind() { + Err(match ty.normalized.kind() { ty::Error(guar) => { // E0071 might be caused by a spelling error, which will have // already caused an error message and probably a suggestion @@ -2136,7 +2136,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { && let Some(callee_ty) = callee_ty { let callee_ty = callee_ty.peel_refs(); - match *callee_ty.kind() { + match callee_ty.kind() { ty::Param(param) => { let param = self.tcx.generics_of(self.body_id).type_param(param, self.tcx); if param.kind.is_synthetic() { @@ -2385,7 +2385,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if rcvr.hir_id.owner == typeck.hir_owner && let Some(rcvr_ty) = typeck.node_type_opt(rcvr.hir_id) && let ty::Closure(call_def_id, _) = rcvr_ty.kind() - && def_id == *call_def_id + && def_id == call_def_id && let Some(idx) = expected_idx && let Some(arg) = args.get(idx) && let Some(arg_ty) = typeck.node_type_opt(arg.hir_id) diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs index 23f4d3c36a370..3f0a330b5a3d6 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs @@ -60,7 +60,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let ty = self.shallow_resolve(ty); debug!(?ty); - match *ty.kind() { + match ty.kind() { ty::Infer(ty::TyVar(found_vid)) => { self.root_var(expected_vid) == self.root_var(found_vid) } diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs index f02b0f953900a..22731c8ed6b26 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs @@ -303,7 +303,7 @@ impl<'tcx> HirTyLowerer<'tcx> for FnCtxt<'_, 'tcx> { fn probe_adt(&self, span: Span, ty: Ty<'tcx>) -> Option> { match ty.kind() { - ty::Adt(adt_def, _) => Some(*adt_def), + ty::Adt(adt_def, _) => Some(adt_def), // FIXME(#104767): Should we handle bound regions here? ty::Alias(ty::Projection | ty::Inherent | ty::Weak, _) if !ty.has_escaping_bound_vars() => @@ -324,7 +324,7 @@ impl<'tcx> HirTyLowerer<'tcx> for FnCtxt<'_, 'tcx> { if let ty::Alias(ty::Projection | ty::Weak, ty::AliasTy { args, def_id, .. }) = ty.kind() { - self.add_required_obligations_for_hir(span, *def_id, args, hir_id); + self.add_required_obligations_for_hir(span, def_id, args, hir_id); } self.normalize(span, ty) diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index caaf4142f7d1f..6a62c829e6b01 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -350,7 +350,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } if self.suggest_fn_call(err, expr, found, |output| self.can_coerce(output, expected)) - && let ty::FnDef(def_id, ..) = *found.kind() + && let ty::FnDef(def_id, ..) = found.kind() && let Some(sp) = self.tcx.hir().span_if_local(def_id) { let name = self.tcx.item_name(def_id); @@ -426,7 +426,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Some((found_ty_inner, expected_ty_inner, error_tys)) = self.deconstruct_option_or_result(found, expected) - && let ty::Ref(_, peeled, hir::Mutability::Not) = *expected_ty_inner.kind() + && let ty::Ref(_, peeled, hir::Mutability::Not) = expected_ty_inner.kind() { // Suggest removing any stray borrows (unless there's macro shenanigans involved). let inner_expr = expr.peel_borrows(); @@ -590,7 +590,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { found: Ty<'tcx>, ) -> bool { if let (ty::FnPtr(_), ty::Closure(def_id, _)) = (expected.kind(), found.kind()) { - if let Some(upvars) = self.tcx.upvars_mentioned(*def_id) { + if let Some(upvars) = self.tcx.upvars_mentioned(def_id) { // Report upto four upvars being captured to reduce the amount error messages // reported back to the user. let spans_and_labels = upvars @@ -1165,8 +1165,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ty::Ref(_, inner_expected_ty, _), ) => { expr = *inner_expr; - expr_ty = *inner_expr_ty; - expected_ty = *inner_expected_ty; + expr_ty = inner_expr_ty; + expected_ty = inner_expected_ty; } (hir::ExprKind::Block(blk, _), _, _) => { self.suggest_block_to_brackets(diag, *blk, expr_ty, expected_ty); @@ -1186,7 +1186,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) -> bool { if let ty::Ref(_, inner_ty, hir::Mutability::Not) = expr_ty.kind() && let Some(clone_trait_def) = self.tcx.lang_items().clone_trait() - && expected_ty == *inner_ty + && expected_ty == inner_ty && self .infcx .type_implements_trait( @@ -1235,7 +1235,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { { let expr_inner_ty = args.type_at(0); let expected_inner_ty = expected_args.type_at(0); - if let &ty::Ref(_, ty, _mutability) = expr_inner_ty.kind() + if let ty::Ref(_, ty, _mutability) = expr_inner_ty.kind() && self.can_eq(self.param_env, ty, expected_inner_ty) { let def_path = self.tcx.def_path_str(adt_def.did()); @@ -1385,7 +1385,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expected_ty: Ty<'tcx>, ) { if let ty::Slice(elem_ty) | ty::Array(elem_ty, _) = expected_ty.kind() { - if self.can_coerce(blk_ty, *elem_ty) + if self.can_coerce(blk_ty, elem_ty) && blk.stmts.is_empty() && blk.rules == hir::BlockCheckMode::DefaultBlock { @@ -1655,7 +1655,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // diagnostic in cases where we have `(&&T).clone()` and we expect `T`). && !results.expr_adjustments(callee_expr).iter().any(|adj| matches!(adj.kind, ty::adjustment::Adjust::Deref(..))) // Check that we're in fact trying to clone into the expected type - && self.can_coerce(*pointee_ty, expected_ty) + && self.can_coerce(pointee_ty, expected_ty) && let trait_ref = ty::TraitRef::new(self.tcx, clone_trait_did, [expected_ty]) // And the expected type doesn't implement `Clone` && !self.predicate_must_hold_considering_regions(&traits::Obligation::new( @@ -2387,8 +2387,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let expr = expr.peel_drop_temps(); match (&expr.kind, expected.kind(), checked_ty.kind()) { - (_, &ty::Ref(_, exp, _), &ty::Ref(_, check, _)) => match (exp.kind(), check.kind()) { - (&ty::Str, &ty::Array(arr, _) | &ty::Slice(arr)) if arr == self.tcx.types.u8 => { + (_, ty::Ref(_, exp, _), ty::Ref(_, check, _)) => match (exp.kind(), check.kind()) { + (ty::Str, ty::Array(arr, _) | ty::Slice(arr)) if arr == self.tcx.types.u8 => { if let hir::ExprKind::Lit(_) = expr.kind && let Ok(src) = sm.span_to_snippet(sp) && replace_prefix(&src, "b\"", "\"").is_some() @@ -2403,7 +2403,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { )); } } - (&ty::Array(arr, _) | &ty::Slice(arr), &ty::Str) if arr == self.tcx.types.u8 => { + (ty::Array(arr, _) | ty::Slice(arr), ty::Str) if arr == self.tcx.types.u8 => { if let hir::ExprKind::Lit(_) = expr.kind && let Ok(src) = sm.span_to_snippet(sp) && replace_prefix(&src, "\"", "b\"").is_some() @@ -2419,7 +2419,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } _ => {} }, - (_, &ty::Ref(_, _, mutability), _) => { + (_, ty::Ref(_, _, mutability), _) => { // Check if it can work when put into a ref. For example: // // ``` @@ -2525,7 +2525,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { kind: hir::ExprKind::Binary(_, lhs, ..), .. }) = self.tcx.parent_hir_node(expr.hir_id) - && let &ty::Ref(..) = self.check_expr(lhs).kind() + && let ty::Ref(..) = self.check_expr(lhs).kind() { let (sugg, verbose) = make_sugg(lhs, lhs.span, "*"); @@ -2549,7 +2549,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { )); } } - (hir::ExprKind::AddrOf(hir::BorrowKind::Ref, _, expr), _, &ty::Ref(_, checked, _)) + (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| { @@ -2588,7 +2588,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return make_sugg(sp, expr.span.lo()); } } - (_, &ty::RawPtr(ty_b, mutbl_b), &ty::Ref(_, ty_a, mutbl_a)) => { + (_, ty::RawPtr(ty_b, mutbl_b), ty::Ref(_, ty_a, mutbl_a)) => { if let Some(steps) = self.deref_steps(ty_a, ty_b) // Only suggest valid if dereferencing needed. && steps > 0 diff --git a/compiler/rustc_hir_typeck/src/intrinsicck.rs b/compiler/rustc_hir_typeck/src/intrinsicck.rs index fb8863c143f76..5c3d7eda8dea1 100644 --- a/compiler/rustc_hir_typeck/src/intrinsicck.rs +++ b/compiler/rustc_hir_typeck/src/intrinsicck.rs @@ -12,7 +12,7 @@ use super::FnCtxt; /// If the type is `Option`, it will return `T`, otherwise /// the type itself. Works on most `Option`-like types. fn unpack_option_like<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> { - let ty::Adt(def, args) = *ty.kind() else { return ty }; + let ty::Adt(def, args) = ty.kind() else { return ty }; if def.variants().len() == 2 && !def.repr().c() && def.repr().int.is_none() { let data_idx; @@ -73,7 +73,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Special-case transmuting from `typeof(function)` and // `Option` to present a clearer error. let from = unpack_option_like(tcx, from); - if let (&ty::FnDef(..), SizeSkeleton::Known(size_to)) = (from.kind(), sk_to) + if let (ty::FnDef(..), SizeSkeleton::Known(size_to)) = (from.kind(), sk_to) && size_to == Pointer(dl.instruction_address_space).size(&tcx) { struct_span_code_err!(tcx.dcx(), span, E0591, "can't transmute zero-sized type") diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs index 3c9a49e91a3f9..d0784e3f53426 100644 --- a/compiler/rustc_hir_typeck/src/method/confirm.rs +++ b/compiler/rustc_hir_typeck/src/method/confirm.rs @@ -204,7 +204,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { if unsize { let unsized_ty = if let ty::Array(elem_ty, _) = base_ty.kind() { - Ty::new_slice(self.tcx, *elem_ty) + Ty::new_slice(self.tcx, elem_ty) } else { bug!( "AutorefOrPtrAdjustment's unsize flag should only be set for array ty, found {}", @@ -220,7 +220,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { } Some(probe::AutorefOrPtrAdjustment::ToConstPtr) => { target = match target.kind() { - &ty::RawPtr(ty, mutbl) => { + ty::RawPtr(ty, mutbl) => { assert!(mutbl.is_mut()); Ty::new_imm_ptr(self.tcx, ty) } diff --git a/compiler/rustc_hir_typeck/src/method/mod.rs b/compiler/rustc_hir_typeck/src/method/mod.rs index 1f90d5e4c88ac..08c17ebf2760c 100644 --- a/compiler/rustc_hir_typeck/src/method/mod.rs +++ b/compiler/rustc_hir_typeck/src/method/mod.rs @@ -202,7 +202,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Some(span) = result.illegal_sized_bound { let mut needs_mut = false; if let ty::Ref(region, t_type, mutability) = self_ty.kind() { - let trait_type = Ty::new_ref(self.tcx, *region, *t_type, mutability.invert()); + let trait_type = Ty::new_ref(self.tcx, region, t_type, mutability.invert()); // We probe again to see if there might be a borrow mutability discrepancy. match self.lookup_probe( segment.ident, diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index ab0f16bd87d07..0bffdee9458d8 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -433,7 +433,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .probe_instantiate_query_response(span, &orig_values, ty) .unwrap_or_else(|_| span_bug!(span, "instantiating {:?} failed?", ty)); let ty = self.resolve_vars_if_possible(ty.value); - let guar = match *ty.kind() { + let guar = match ty.kind() { ty::Infer(ty::TyVar(_)) => { let raw_ptr_call = bad_ty.reached_raw_pointer && !self.tcx.features().arbitrary_self_types; @@ -539,7 +539,7 @@ fn method_autoderef_steps<'tcx>( steps.push(CandidateStep { self_ty: infcx.make_query_response_ignoring_pending_obligations( inference_vars, - Ty::new_slice(infcx.tcx, *elem_ty), + Ty::new_slice(infcx.tcx, elem_ty), ), autoderefs: dereferences, // this could be from an unsafe deref if we had @@ -638,7 +638,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { fn assemble_probe(&mut self, self_ty: &Canonical<'tcx, QueryResponse<'tcx, Ty<'tcx>>>) { debug!("assemble_probe: self_ty={:?}", self_ty); let raw_self_ty = self_ty.value.value; - match *raw_self_ty.kind() { + match raw_self_ty.kind() { ty::Dynamic(data, ..) if let Some(p) = data.principal() => { // Subtle: we can't use `instantiate_query_response` here: using it will // commit to all of the type equalities assumed by inference going through @@ -777,7 +777,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { let bound_predicate = predicate.kind(); match bound_predicate.skip_binder() { ty::ClauseKind::Trait(trait_predicate) => { - match *trait_predicate.trait_ref.self_ty().kind() { + match trait_predicate.trait_ref.self_ty().kind() { ty::Param(p) if p == param_ty => { Some(bound_predicate.rebind(trait_predicate.trait_ref)) } @@ -1103,7 +1103,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { pick.autoderefs = step.autoderefs; // Insert a `&*` or `&mut *` if this is a reference type: - if let ty::Ref(_, _, mutbl) = *step.self_ty.value.value.kind() { + if let ty::Ref(_, _, mutbl) = step.self_ty.value.value.kind() { pick.autoderefs += 1; pick.autoref_or_ptr_adjustment = Some(AutorefOrPtrAdjustment::Autoref { mutbl, @@ -1153,7 +1153,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { return None; } - let &ty::RawPtr(ty, hir::Mutability::Mut) = self_ty.kind() else { + let ty::RawPtr(ty, hir::Mutability::Mut) = self_ty.kind() else { return None; }; diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index c1e14f7fb753a..eec60cdffec35 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -123,7 +123,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let Some(arg_ty) = args[0].as_type() else { return false; }; - let ty::Param(param) = *arg_ty.kind() else { + let ty::Param(param) = arg_ty.kind() else { return false; }; // Is `generic_param` the same as the arg for this trait predicate? @@ -154,7 +154,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return false; } - match *ty.peel_refs().kind() { + match ty.peel_refs().kind() { ty::Param(param) => { let generics = self.tcx.generics_of(self.body_id); let generic_param = generics.type_param(param, self.tcx); @@ -314,8 +314,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } if let ty::Ref(region, t_type, mutability) = rcvr_ty.kind() { if needs_mut { - let trait_type = - Ty::new_ref(self.tcx, *region, *t_type, mutability.invert()); + let trait_type = Ty::new_ref(self.tcx, region, t_type, mutability.invert()); let msg = format!("you need `{trait_type}` instead of `{rcvr_ty}`"); let mut kind = &self_expr.kind; while let hir::ExprKind::AddrOf(_, _, expr) @@ -740,7 +739,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // on pointers, check if the method would exist on a reference if let SelfSource::MethodCall(rcvr_expr) = source - && let ty::RawPtr(ty, ptr_mutbl) = *rcvr_ty.kind() + && let ty::RawPtr(ty, ptr_mutbl) = rcvr_ty.kind() && let Ok(pick) = self.lookup_probe_for_diagnostic( item_name, Ty::new_ref(tcx, ty::Region::new_error_misc(tcx), ty, ptr_mutbl), @@ -748,7 +747,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ProbeScope::TraitsInScope, None, ) - && let ty::Ref(_, _, sugg_mutbl) = *pick.self_ty.kind() + && let ty::Ref(_, _, sugg_mutbl) = pick.self_ty.kind() && (sugg_mutbl.is_not() || ptr_mutbl.is_mut()) { let (method, method_anchor) = match sugg_mutbl { @@ -1346,7 +1345,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { )), _ => arg, })); - let rcvr_ty = Ty::new_adt(tcx, *def, new_args); + let rcvr_ty = Ty::new_adt(tcx, def, new_args); if let Ok(method) = self.lookup_method_for_diagnostic( rcvr_ty, &item_segment, @@ -2691,7 +2690,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Target wrapper types - types that wrap or pretend to wrap another type, // perhaps this inner type is meant to be called? ty::AdtKind::Struct | ty::AdtKind::Union => { - let [first] = ***args else { + let [first] = **args else { return; }; let ty::GenericArgKind::Type(ty) = first.unpack() else { @@ -3470,9 +3469,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .sort_by_key(|&info| (!info.def_id.is_local(), self.tcx.def_path_str(info.def_id))); candidates.dedup(); - let param_type = match *rcvr_ty.kind() { + let param_type = match rcvr_ty.kind() { ty::Param(param) => Some(param), - ty::Ref(_, ty, _) => match *ty.kind() { + ty::Ref(_, ty, _) => match ty.kind() { ty::Param(param) => Some(param), _ => None, }, diff --git a/compiler/rustc_hir_typeck/src/op.rs b/compiler/rustc_hir_typeck/src/op.rs index d774ae2146aa0..22cdf01e56d18 100644 --- a/compiler/rustc_hir_typeck/src/op.rs +++ b/compiler/rustc_hir_typeck/src/op.rs @@ -256,9 +256,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let by_ref_binop = !op.node.is_by_value(); if is_assign == IsAssign::Yes || by_ref_binop { if let ty::Ref(region, _, mutbl) = method.sig.inputs()[0].kind() { - let mutbl = AutoBorrowMutability::new(*mutbl, AllowTwoPhase::Yes); + let mutbl = AutoBorrowMutability::new(mutbl, AllowTwoPhase::Yes); let autoref = Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(*region, mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)), target: method.sig.inputs()[0], }; self.apply_adjustments(lhs_expr, vec![autoref]); @@ -268,10 +268,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let ty::Ref(region, _, mutbl) = method.sig.inputs()[1].kind() { // Allow two-phase borrows for binops in initial deployment // since they desugar to methods - let mutbl = AutoBorrowMutability::new(*mutbl, AllowTwoPhase::Yes); + let mutbl = AutoBorrowMutability::new(mutbl, AllowTwoPhase::Yes); let autoref = Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(*region, mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)), target: method.sig.inputs()[1], }; // HACK(eddyb) Bypass checks due to reborrows being in @@ -507,12 +507,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else if is_assign == IsAssign::No && let Ref(region, lhs_deref_ty, mutbl) = lhs_ty.kind() { - if self.type_is_copy_modulo_regions(self.param_env, *lhs_deref_ty) { - suggest_deref_binop(&mut err, *lhs_deref_ty); + if self.type_is_copy_modulo_regions(self.param_env, lhs_deref_ty) { + suggest_deref_binop(&mut err, lhs_deref_ty); } else { let lhs_inv_mutbl = mutbl.invert(); let lhs_inv_mutbl_ty = - Ty::new_ref(self.tcx, *region, *lhs_deref_ty, lhs_inv_mutbl); + Ty::new_ref(self.tcx, region, lhs_deref_ty, lhs_inv_mutbl); suggest_different_borrow( &mut err, @@ -525,7 +525,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Ref(region, rhs_deref_ty, mutbl) = rhs_ty.kind() { let rhs_inv_mutbl = mutbl.invert(); let rhs_inv_mutbl_ty = - Ty::new_ref(self.tcx, *region, *rhs_deref_ty, rhs_inv_mutbl); + Ty::new_ref(self.tcx, region, rhs_deref_ty, rhs_inv_mutbl); suggest_different_borrow( &mut err, @@ -704,12 +704,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |ty: Ty<'tcx>| ty.ty_adt_def().is_some_and(|ty_def| Some(ty_def.did()) == string_type); match (lhs_ty.kind(), rhs_ty.kind()) { - (&Ref(_, l_ty, _), &Ref(_, r_ty, _)) // &str or &String + &str, &String or &&str - if (*l_ty.kind() == Str || is_std_string(l_ty)) - && (*r_ty.kind() == Str + (Ref(_, l_ty, _), Ref(_, r_ty, _)) // &str or &String + &str, &String or &&str + if (l_ty.kind() == Str || is_std_string(l_ty)) + && (r_ty.kind() == Str || is_std_string(r_ty) || matches!( - r_ty.kind(), Ref(_, inner_ty, _) if *inner_ty.kind() == Str + r_ty.kind(), Ref(_, inner_ty, _) if inner_ty.kind() == Str )) => { if let IsAssign::No = is_assign { // Do not supply this message if `&str += &str` @@ -733,8 +733,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } true } - (&Ref(_, l_ty, _), &Adt(..)) // Handle `&str` & `&String` + `String` - if (*l_ty.kind() == Str || is_std_string(l_ty)) && is_std_string(rhs_ty) => + (Ref(_, l_ty, _), Adt(..)) // Handle `&str` & `&String` + `String` + if (l_ty.kind() == Str || is_std_string(l_ty)) && is_std_string(rhs_ty) => { err.span_label( op.span, @@ -849,7 +849,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } Str | Never | Char | Tuple(_) | Array(_, _) => {} - Ref(_, lty, _) if *lty.kind() == Str => {} + Ref(_, lty, _) if lty.kind() == Str => {} _ => { self.note_unmet_impls_on_type(&mut err, errors, true); } @@ -1062,7 +1062,7 @@ enum Op { /// Dereferences a single level of immutable referencing. fn deref_ty_if_possible(ty: Ty<'_>) -> Ty<'_> { match ty.kind() { - ty::Ref(_, ty, hir::Mutability::Not) => *ty, + ty::Ref(_, ty, hir::Mutability::Not) => ty, _ => ty, } } diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index be91e7d45b610..b8fd09544ff7f 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -418,7 +418,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // // See the examples in `ui/match-defbm*.rs`. let mut pat_adjustments = vec![]; - while let ty::Ref(_, inner_ty, inner_mutability) = *expected.kind() { + while let ty::Ref(_, inner_ty, inner_mutability) = expected.kind() { debug!("inspecting {:?}", expected); debug!("current discriminant is Ref, inserting implicit deref"); @@ -472,7 +472,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut pat_ty = ty; if let hir::ExprKind::Lit(Spanned { node: ast::LitKind::ByteStr(..), .. }) = lt.kind { let expected = self.structurally_resolve_type(span, expected); - if let ty::Ref(_, inner_ty, _) = *expected.kind() + if let ty::Ref(_, inner_ty, _) = expected.kind() && self.try_structurally_resolve_type(span, inner_ty).is_slice() { let tcx = self.tcx; @@ -800,7 +800,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) { match (expected.kind(), actual.kind(), ba) { (ty::Ref(_, inner_ty, _), _, BindingMode::NONE) - if self.can_eq(self.param_env, *inner_ty, actual) => + if self.can_eq(self.param_env, inner_ty, actual) => { err.span_suggestion_verbose( span.shrink_to_lo(), @@ -810,7 +810,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); } (_, ty::Ref(_, inner_ty, _), BindingMode::REF) - if self.can_eq(self.param_env, expected, *inner_ty) => + if self.can_eq(self.param_env, expected, inner_ty) => { err.span_suggestion_verbose( span.with_hi(span.lo() + BytePos(4)), @@ -1020,7 +1020,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return Ty::new_error(tcx, e); } Res::SelfCtor(def_id) => { - if let ty::Adt(adt_def, _) = *tcx.type_of(def_id).skip_binder().kind() + if let ty::Adt(adt_def, _) = tcx.type_of(def_id).skip_binder().kind() && adt_def.is_struct() && let Some((CtorKind::Const, _)) = adt_def.non_enum_variant().ctor { @@ -2197,7 +2197,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // to avoid creating needless variables. This also helps with // the bad interactions of the given hack detailed in (note_1). debug!("check_pat_ref: expected={:?}", expected); - match *expected.kind() { + match expected.kind() { ty::Ref(_, r_ty, r_mutbl) if (new_match_ergonomics && r_mutbl >= pat_mutbl) || r_mutbl == pat_mutbl => @@ -2334,7 +2334,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let expected = self.structurally_resolve_type(span, expected); debug!(?expected); - let (element_ty, opt_slice_ty, inferred) = match *expected.kind() { + let (element_ty, opt_slice_ty, inferred) = match expected.kind() { // An array, so we might have something like `let [a, b, c] = [0, 1, 2];`. ty::Array(element_ty, len) => { let min = before.len() as u64 + after.len() as u64; @@ -2548,7 +2548,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ty::Adt(adt_def, _) if self.tcx.is_diagnostic_item(sym::Vec, adt_def.did()) => { (true, ty) } - ty::Ref(_, ty, _) => self.is_slice_or_array_or_vector(*ty), + ty::Ref(_, ty, _) => self.is_slice_or_array_or_vector(ty), ty::Slice(..) | ty::Array(..) => (true, ty), _ => (false, ty), } diff --git a/compiler/rustc_hir_typeck/src/place_op.rs b/compiler/rustc_hir_typeck/src/place_op.rs index 515e1b5ed0e0b..daa044c2f904e 100644 --- a/compiler/rustc_hir_typeck/src/place_op.rs +++ b/compiler/rustc_hir_typeck/src/place_op.rs @@ -30,7 +30,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.apply_adjustments( oprnd_expr, vec![Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(*region, AutoBorrowMutability::Not)), + kind: Adjust::Borrow(AutoBorrow::Ref(region, AutoBorrowMutability::Not)), target: method.sig.inputs()[0], }], ); @@ -138,7 +138,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if unsize { // We only unsize arrays here. if let ty::Array(element_ty, _) = adjusted_ty.kind() { - self_ty = Ty::new_slice(self.tcx, *element_ty); + self_ty = Ty::new_slice(self.tcx, element_ty); } else { continue; } @@ -158,8 +158,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut adjustments = self.adjust_steps(autoderef); if let ty::Ref(region, _, hir::Mutability::Not) = method.sig.inputs()[0].kind() { adjustments.push(Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(*region, AutoBorrowMutability::Not)), - target: Ty::new_imm_ref(self.tcx, *region, adjusted_ty), + kind: Adjust::Borrow(AutoBorrow::Ref(region, AutoBorrowMutability::Not)), + target: Ty::new_imm_ref(self.tcx, region, adjusted_ty), }); } else { span_bug!(expr.span, "input to index is not a ref?"); @@ -289,7 +289,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) { let method = self.register_infer_ok_obligations(ok); - if let ty::Ref(region, _, mutbl) = *method.sig.output().kind() { + if let ty::Ref(region, _, mutbl) = method.sig.output().kind() { *deref = OverloadedDeref { region, mutbl, span: deref.span }; } // If this is a union field, also throw an error for `DerefMut` of `ManuallyDrop` (see RFC 2514). @@ -391,8 +391,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // not the case today. allow_two_phase_borrow: AllowTwoPhase::No, }; - adjustment.kind = Adjust::Borrow(AutoBorrow::Ref(*region, mutbl)); - adjustment.target = Ty::new_ref(self.tcx, *region, source, mutbl.into()); + adjustment.kind = Adjust::Borrow(AutoBorrow::Ref(region, mutbl)); + adjustment.target = Ty::new_ref(self.tcx, region, source, mutbl.into()); } source = adjustment.target; } diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs index 4386e68ce8674..ef3881e5e8a47 100644 --- a/compiler/rustc_hir_typeck/src/upvar.rs +++ b/compiler/rustc_hir_typeck/src/upvar.rs @@ -169,7 +169,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) { // Extract the type of the closure. let ty = self.node_ty(closure_hir_id); - let (closure_def_id, args, infer_kind) = match *ty.kind() { + let (closure_def_id, args, infer_kind) = match ty.kind() { ty::Closure(def_id, args) => { (def_id, UpvarArgs::Closure(args), self.closure_kind(ty).is_none()) } @@ -462,7 +462,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // for the inner coroutine may actually be more restrictive. if infer_kind { let ty::Coroutine(_, coroutine_args) = - *self.typeck_results.borrow().expr_ty(body.value).kind() + self.typeck_results.borrow().expr_ty(body.value).kind() else { bug!(); }; diff --git a/compiler/rustc_hir_typeck/src/writeback.rs b/compiler/rustc_hir_typeck/src/writeback.rs index 8727c0f87dc80..6afb28a9bdf42 100644 --- a/compiler/rustc_hir_typeck/src/writeback.rs +++ b/compiler/rustc_hir_typeck/src/writeback.rs @@ -228,7 +228,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { assert!(self.tcx().dcx().has_errors().is_some(), "bad base: `{base:?}`"); } if let Some(base_ty) = base_ty - && let ty::Ref(_, base_ty_inner, _) = *base_ty.kind() + && let ty::Ref(_, base_ty_inner, _) = base_ty.kind() { let index_ty = self.typeck_results.expr_ty_adjusted_opt(index).unwrap_or_else(|| { diff --git a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs index bc2592b43f3d3..edb9270b16194 100644 --- a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs +++ b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs @@ -339,7 +339,7 @@ impl<'cx, 'tcx> TypeFolder> for Canonicalizer<'cx, 'tcx> { } fn fold_ty(&mut self, mut t: Ty<'tcx>) -> Ty<'tcx> { - match *t.kind() { + match t.kind() { ty::Infer(ty::TyVar(mut vid)) => { // We need to canonicalize the *root* of our ty var. // This is so that our canonical response correctly reflects diff --git a/compiler/rustc_infer/src/infer/canonical/query_response.rs b/compiler/rustc_infer/src/infer/canonical/query_response.rs index d7dd6a1e7cf53..95b3fc5a29903 100644 --- a/compiler/rustc_infer/src/infer/canonical/query_response.rs +++ b/compiler/rustc_infer/src/infer/canonical/query_response.rs @@ -431,7 +431,7 @@ impl<'tcx> InferCtxt<'tcx> { match result_value.unpack() { GenericArgKind::Type(result_value) => { // e.g., here `result_value` might be `?0` in the example above... - if let ty::Bound(debruijn, b) = *result_value.kind() { + if let ty::Bound(debruijn, b) = result_value.kind() { // ...in which case we would set `canonical_vars[0]` to `Some(?U)`. // We only allow a `ty::INNERMOST` index in generic parameters. diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index fe0a246abbc6c..451304e35d74d 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -398,7 +398,7 @@ pub fn unexpected_hidden_region_diagnostic<'tcx>( impl<'tcx> InferCtxt<'tcx> { pub fn get_impl_future_output_ty(&self, ty: Ty<'tcx>) -> Option> { - let (def_id, args) = match *ty.kind() { + let (def_id, args) = match ty.kind() { ty::Alias(_, ty::AliasTy { def_id, args, .. }) if matches!(self.tcx.def_kind(def_id), DefKind::OpaqueTy) => { @@ -733,7 +733,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { TypeError::Sorts(ref exp_found) => { // if they are both "path types", there's a chance of ambiguity // due to different versions of the same crate - if let (&ty::Adt(exp_adt, _), &ty::Adt(found_adt, _)) = + if let (ty::Adt(exp_adt, _), ty::Adt(found_adt, _)) = (exp_found.expected.kind(), exp_found.found.kind()) { report_path_match(err, exp_adt.did(), found_adt.did()); @@ -1069,11 +1069,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { /// Given two `fn` signatures highlight only sub-parts that are different. fn cmp_fn_sig( &self, - sig1: &ty::PolyFnSig<'tcx>, - sig2: &ty::PolyFnSig<'tcx>, + sig1: ty::PolyFnSig<'tcx>, // njn: removed `&` + sig2: ty::PolyFnSig<'tcx>, // njn: removed `&` ) -> (DiagStyledString, DiagStyledString) { - let sig1 = &(self.normalize_fn_sig)(*sig1); - let sig2 = &(self.normalize_fn_sig)(*sig2); + let sig1 = &(self.normalize_fn_sig)(sig1); + let sig2 = &(self.normalize_fn_sig)(sig2); let get_lifetimes = |sig| { use rustc_hir::def::Namespace; @@ -1252,7 +1252,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { // process starts here match (t1.kind(), t2.kind()) { - (&ty::Adt(def1, sub1), &ty::Adt(def2, sub2)) => { + (ty::Adt(def1, sub1), ty::Adt(def2, sub2)) => { let did1 = def1.did(); let did2 = def2.did(); @@ -1460,20 +1460,20 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } // When finding `&T != &T`, compare the references, then recurse into pointee type - (&ty::Ref(r1, ref_ty1, mutbl1), &ty::Ref(r2, ref_ty2, mutbl2)) => { + (ty::Ref(r1, ref_ty1, mutbl1), ty::Ref(r2, ref_ty2, mutbl2)) => { let mut values = (DiagStyledString::new(), DiagStyledString::new()); cmp_ty_refs(r1, mutbl1, r2, mutbl2, &mut values); recurse(ref_ty1, ref_ty2, &mut values); values } // When finding T != &T, highlight the borrow - (&ty::Ref(r1, ref_ty1, mutbl1), _) => { + (ty::Ref(r1, ref_ty1, mutbl1), _) => { let mut values = (DiagStyledString::new(), DiagStyledString::new()); push_ref(r1, mutbl1, &mut values.0); recurse(ref_ty1, t2, &mut values); values } - (_, &ty::Ref(r2, ref_ty2, mutbl2)) => { + (_, ty::Ref(r2, ref_ty2, mutbl2)) => { let mut values = (DiagStyledString::new(), DiagStyledString::new()); push_ref(r2, mutbl2, &mut values.1); recurse(t1, ref_ty2, &mut values); @@ -1481,7 +1481,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } // When encountering tuples of the same size, highlight only the differing types - (&ty::Tuple(args1), &ty::Tuple(args2)) if args1.len() == args2.len() => { + (ty::Tuple(args1), ty::Tuple(args2)) if args1.len() == args2.len() => { let mut values = (DiagStyledString::normal("("), DiagStyledString::normal("(")); let len = args1.len(); for (i, (left, right)) in args1.iter().zip(args2).enumerate() { @@ -1499,11 +1499,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } (ty::FnDef(did1, args1), ty::FnDef(did2, args2)) => { - let sig1 = self.tcx.fn_sig(*did1).instantiate(self.tcx, args1); - let sig2 = self.tcx.fn_sig(*did2).instantiate(self.tcx, args2); - let mut values = self.cmp_fn_sig(&sig1, &sig2); - let path1 = format!(" {{{}}}", self.tcx.def_path_str_with_args(*did1, args1)); - let path2 = format!(" {{{}}}", self.tcx.def_path_str_with_args(*did2, args2)); + let sig1 = self.tcx.fn_sig(did1).instantiate(self.tcx, args1); + let sig2 = self.tcx.fn_sig(did2).instantiate(self.tcx, args2); + let mut values = self.cmp_fn_sig(sig1, sig2); + let path1 = format!(" {{{}}}", self.tcx.def_path_str_with_args(did1, args1)); + let path2 = format!(" {{{}}}", self.tcx.def_path_str_with_args(did2, args2)); let same_path = path1 == path2; values.0.push(path1, !same_path); values.1.push(path2, !same_path); @@ -1511,21 +1511,21 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } (ty::FnDef(did1, args1), ty::FnPtr(sig2)) => { - let sig1 = self.tcx.fn_sig(*did1).instantiate(self.tcx, args1); - let mut values = self.cmp_fn_sig(&sig1, sig2); + let sig1 = self.tcx.fn_sig(did1).instantiate(self.tcx, args1); + let mut values = self.cmp_fn_sig(sig1, sig2); values.0.push_highlighted(format!( " {{{}}}", - self.tcx.def_path_str_with_args(*did1, args1) + self.tcx.def_path_str_with_args(did1, args1) )); values } (ty::FnPtr(sig1), ty::FnDef(did2, args2)) => { - let sig2 = self.tcx.fn_sig(*did2).instantiate(self.tcx, args2); - let mut values = self.cmp_fn_sig(sig1, &sig2); + let sig2 = self.tcx.fn_sig(did2).instantiate(self.tcx, args2); + let mut values = self.cmp_fn_sig(sig1, sig2); values .1 - .push_normal(format!(" {{{}}}", self.tcx.def_path_str_with_args(*did2, args2))); + .push_normal(format!(" {{{}}}", self.tcx.def_path_str_with_args(did2, args2))); values } @@ -1784,7 +1784,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let path = self.tcx.def_path(expected.did()).data; let name = path.last().unwrap().data.get_opt_name(); if name == Some(primitive) { - return Some(Similar::PrimitiveFound { expected: *expected, found }); + return Some(Similar::PrimitiveFound { expected, found }); } } else if let Some(primitive) = expected.primitive_symbol() && let ty::Adt(found, _) = found.kind() @@ -1792,7 +1792,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let path = self.tcx.def_path(found.did()).data; let name = path.last().unwrap().data.get_opt_name(); if name == Some(primitive) { - return Some(Similar::PrimitiveExpected { expected, found: *found }); + return Some(Similar::PrimitiveExpected { expected, found }); } } else if let ty::Adt(expected, _) = expected.kind() && let ty::Adt(found, _) = found.kind() @@ -1809,7 +1809,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { if let (Some(e_last), Some(f_last)) = (e_path.last(), f_path.last()) && e_last == f_last { - return Some(Similar::Adts { expected: *expected, found: *found }); + return Some(Similar::Adts { expected, found }); } } None @@ -1886,7 +1886,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let sort_string = |ty: Ty<'tcx>| match (extra, ty.kind()) { (true, ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. })) => { let sm = self.tcx.sess.source_map(); - let pos = sm.lookup_char_pos(self.tcx.def_span(*def_id).lo()); + let pos = sm.lookup_char_pos(self.tcx.def_span(def_id).lo()); format!( " (opaque type at <{}:{}:{}>)", sm.filename_for_diagnostics(&pos.file.name), @@ -2271,7 +2271,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { if exp_found.references_error() { return None; } - let (exp, fnd) = self.cmp_fn_sig(&exp_found.expected, &exp_found.found); + let (exp, fnd) = self.cmp_fn_sig(exp_found.expected, exp_found.found); Some((exp, fnd, None)) } } @@ -2993,7 +2993,7 @@ impl fmt::Display for TyCategory { impl TyCategory { pub fn from_ty(tcx: TyCtxt<'_>, ty: Ty<'_>) -> Option<(Self, DefId)> { - match *ty.kind() { + match ty.kind() { ty::Closure(def_id, _) => Some((Self::Closure, def_id)), ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) => { let kind = 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 cb0e13652e800..d68db9201bdff 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 @@ -299,7 +299,7 @@ impl<'tcx> InferCtxt<'tcx> { ) -> InferenceDiagnosticsData { match arg.unpack() { GenericArgKind::Type(ty) => { - if let ty::Infer(ty::TyVar(ty_vid)) = *ty.kind() { + if let ty::Infer(ty::TyVar(ty_vid)) = ty.kind() { let mut inner = self.inner.borrow_mut(); let ty_vars = &inner.type_variables(); let var_origin = ty_vars.var_origin(ty_vid); @@ -785,7 +785,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> { } } fn ty_cost(self, ty: Ty<'tcx>) -> usize { - match *ty.kind() { + match ty.kind() { ty::Closure(..) => 1000, ty::FnDef(..) => 150, ty::FnPtr(..) => 30, @@ -877,7 +877,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> { (GenericArgKind::Type(inner_ty), GenericArgKind::Type(target_ty)) => { use ty::{Infer, TyVar}; match (inner_ty.kind(), target_ty.kind()) { - (&Infer(TyVar(a_vid)), &Infer(TyVar(b_vid))) => { + (Infer(TyVar(a_vid)), Infer(TyVar(b_vid))) => { self.tecx.sub_relations.borrow_mut().unified(self.tecx, a_vid, b_vid) } _ => false, diff --git a/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs b/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs index 19ef2d61fca31..b66cc294082b9 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs @@ -28,7 +28,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { match err { ArgumentSorts(values, _) | Sorts(values) => { - match (*values.expected.kind(), *values.found.kind()) { + match (values.expected.kind(), values.found.kind()) { (ty::Closure(..), ty::Closure(..)) => { diag.note("no two closures, even if identical, have the same type"); diag.help("consider boxing your closure and/or using it as a trait object"); @@ -524,7 +524,7 @@ impl Trait for X { }; // Get the `DefId` for the type parameter corresponding to `A` in `::Foo`. // This will also work for `impl Trait`. - let ty::Param(param_ty) = *proj_ty.self_ty().kind() else { + let ty::Param(param_ty) = proj_ty.self_ty().kind() else { return false; }; let generics = tcx.generics_of(body_owner_def_id); @@ -695,7 +695,7 @@ fn foo(&self) -> Self::T { String::new() } let tcx = self.tcx; let assoc = tcx.associated_item(proj_ty.def_id); - if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = *proj_ty.self_ty().kind() { + if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = proj_ty.self_ty().kind() { let opaque_local_def_id = def_id.as_local(); let opaque_hir_ty = if let Some(opaque_local_def_id) = opaque_local_def_id { tcx.hir().expect_item(opaque_local_def_id).expect_opaque_ty() @@ -743,7 +743,7 @@ fn foo(&self) -> Self::T { String::new() } }) .filter_map(|item| { let method = tcx.fn_sig(item.def_id).instantiate_identity(); - match *method.output().skip_binder().kind() { + match method.output().skip_binder().kind() { ty::Alias(ty::Projection, ty::AliasTy { def_id: item_def_id, .. }) if item_def_id == proj_ty_item_def_id => { diff --git a/compiler/rustc_infer/src/infer/error_reporting/sub_relations.rs b/compiler/rustc_infer/src/infer/error_reporting/sub_relations.rs index ef26a8ff7b863..a15db36259ffe 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/sub_relations.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/sub_relations.rs @@ -63,7 +63,7 @@ impl SubRelations { }; match (a.kind(), b.kind()) { - (&ty::Infer(ty::TyVar(a_vid)), &ty::Infer(ty::TyVar(b_vid))) => { + (ty::Infer(ty::TyVar(a_vid)), ty::Infer(ty::TyVar(b_vid))) => { let a = self.get_id(infcx, a_vid); let b = self.get_id(infcx, b_vid); self.table.with_log(&mut NoUndo).unify_var_var(a, b).unwrap(); diff --git a/compiler/rustc_infer/src/infer/error_reporting/suggest.rs b/compiler/rustc_infer/src/infer/error_reporting/suggest.rs index 17fb760295aea..697f1db071202 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/suggest.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/suggest.rs @@ -482,8 +482,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { if let (ty::Adt(exp_def, exp_args), ty::Ref(_, found_ty, _)) = (expected.kind(), found.kind()) { - if let ty::Adt(found_def, found_args) = *found_ty.kind() { - if exp_def == &found_def { + if let ty::Adt(found_def, found_args) = found_ty.kind() { + if exp_def == found_def { let have_as_ref = &[ (sym::Option, SuggestAsRefKind::Option), (sym::Result, SuggestAsRefKind::Result), @@ -495,7 +495,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { for (exp_ty, found_ty) in std::iter::zip(exp_args.types(), found_args.types()) { - match *exp_ty.kind() { + match exp_ty.kind() { ty::Ref(_, exp_ty, _) => { match (exp_ty.kind(), found_ty.kind()) { (_, ty::Param(_)) diff --git a/compiler/rustc_infer/src/infer/freshen.rs b/compiler/rustc_infer/src/infer/freshen.rs index 4bb59bd9037c3..633e3f7c3c0e5 100644 --- a/compiler/rustc_infer/src/infer/freshen.rs +++ b/compiler/rustc_infer/src/infer/freshen.rs @@ -126,7 +126,7 @@ impl<'a, 'tcx> TypeFolder> for TypeFreshener<'a, 'tcx> { if !t.has_infer() && !t.has_erasable_regions() { t } else { - match *t.kind() { + match t.kind() { ty::Infer(v) => self.fold_infer_ty(v).unwrap_or(t), // This code is hot enough that a non-debug assertion here makes a noticeable diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index 4476611d9c820..8032d52c5947c 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -790,7 +790,7 @@ impl<'tcx> InferCtxt<'tcx> { /// /// No attempt is made to resolve `ty`. pub fn type_var_origin(&self, ty: Ty<'tcx>) -> Option { - match *ty.kind() { + match ty.kind() { ty::Infer(ty::TyVar(vid)) => { Some(self.inner.borrow_mut().type_variables().var_origin(vid)) } @@ -939,7 +939,7 @@ impl<'tcx> InferCtxt<'tcx> { let r_a = self.shallow_resolve(predicate.skip_binder().a); let r_b = self.shallow_resolve(predicate.skip_binder().b); match (r_a.kind(), r_b.kind()) { - (&ty::Infer(ty::TyVar(a_vid)), &ty::Infer(ty::TyVar(b_vid))) => { + (ty::Infer(ty::TyVar(a_vid)), ty::Infer(ty::TyVar(b_vid))) => { return Err((a_vid, b_vid)); } _ => {} @@ -1235,7 +1235,7 @@ impl<'tcx> InferCtxt<'tcx> { } pub fn shallow_resolve(&self, ty: Ty<'tcx>) -> Ty<'tcx> { - if let ty::Infer(v) = *ty.kind() { + if let ty::Infer(v) = ty.kind() { match v { ty::TyVar(v) => { // Not entirely obvious: if `typ` is a type variable, @@ -1485,7 +1485,7 @@ impl<'tcx> InferCtxt<'tcx> { /// closure in the current function, in which case its /// `ClosureKind` may not yet be known. pub fn closure_kind(&self, closure_ty: Ty<'tcx>) -> Option { - let unresolved_kind_ty = match *closure_ty.kind() { + let unresolved_kind_ty = match closure_ty.kind() { ty::Closure(_, args) => args.as_closure().kind_ty(), ty::CoroutineClosure(_, args) => args.as_coroutine_closure().kind_ty(), _ => bug!("unexpected type {closure_ty}"), @@ -1762,7 +1762,7 @@ impl<'tcx> TyOrConstInferVar { /// Tries to extract an inference variable from a type, returns `None` /// for types other than `ty::Infer(_)` (or `InferTy::Fresh*`). fn maybe_from_ty(ty: Ty<'tcx>) -> Option { - match *ty.kind() { + match ty.kind() { ty::Infer(ty::TyVar(v)) => Some(TyOrConstInferVar::Ty(v)), ty::Infer(ty::IntVar(v)) => Some(TyOrConstInferVar::TyInt(v)), ty::Infer(ty::FloatVar(v)) => Some(TyOrConstInferVar::TyFloat(v)), diff --git a/compiler/rustc_infer/src/infer/opaque_types/mod.rs b/compiler/rustc_infer/src/infer/opaque_types/mod.rs index 8eb3185673b4a..930c5aa3ba68d 100644 --- a/compiler/rustc_infer/src/infer/opaque_types/mod.rs +++ b/compiler/rustc_infer/src/infer/opaque_types/mod.rs @@ -56,7 +56,7 @@ impl<'tcx> InferCtxt<'tcx> { tcx: self.tcx, lt_op: |lt| lt, ct_op: |ct| ct, - ty_op: |ty| match *ty.kind() { + ty_op: |ty| match ty.kind() { ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) if self.can_define_opaque_ty(def_id) && !ty.has_escaping_bound_vars() => { @@ -83,7 +83,7 @@ impl<'tcx> InferCtxt<'tcx> { cause: &ObligationCause<'tcx>, param_env: ty::ParamEnv<'tcx>, ) -> InferResult<'tcx, ()> { - let process = |a: Ty<'tcx>, b: Ty<'tcx>| match *a.kind() { + let process = |a: Ty<'tcx>, b: Ty<'tcx>| match a.kind() { ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) if def_id.is_local() => { let def_id = def_id.expect_local(); if self.intercrate { @@ -133,7 +133,7 @@ impl<'tcx> InferCtxt<'tcx> { return None; } - if let ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }) = *b.kind() { + if let ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }) = b.kind() { // We could accept this, but there are various ways to handle this situation, and we don't // want to make a decision on it right now. Likely this case is so super rare anyway, that // no one encounters it in practice. @@ -429,7 +429,7 @@ where ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => { // Skip lifetime parameters that are not captures. - let variances = self.tcx.variances_of(*def_id); + let variances = self.tcx.variances_of(def_id); for (v, s) in std::iter::zip(variances, args.iter()) { if *v != ty::Variance::Bivariant { @@ -578,7 +578,7 @@ impl<'tcx> InferCtxt<'tcx> { for (predicate, _) in item_bounds.iter_instantiated_copied(tcx, args) { let predicate = predicate.fold_with(&mut BottomUpFolder { tcx, - ty_op: |ty| match *ty.kind() { + ty_op: |ty| match ty.kind() { // We can't normalize associated types from `rustc_infer`, // but we can eagerly register inference variables for them. // FIXME(RPITIT): Don't replace RPITITs with inference vars. diff --git a/compiler/rustc_infer/src/infer/outlives/components.rs b/compiler/rustc_infer/src/infer/outlives/components.rs index 6bab3ad6ba3c8..733e2eb743a4e 100644 --- a/compiler/rustc_infer/src/infer/outlives/components.rs +++ b/compiler/rustc_infer/src/infer/outlives/components.rs @@ -71,7 +71,7 @@ fn compute_components<'tcx>( // with `collect()` because of the need to sometimes skip subtrees // in the `subtys` iterator (e.g., when encountering a // projection). - match *ty.kind() { + match ty.kind() { ty::FnDef(_, args) => { // HACK(eddyb) ignore lifetimes found shallowly in `args`. // This is inconsistent with `ty::Adt` (including all args) @@ -212,7 +212,7 @@ pub(super) fn compute_alias_components_recursive<'tcx>( let ty::Alias(kind, alias_ty) = alias_ty.kind() else { unreachable!("can only call `compute_alias_components_recursive` on an alias type") }; - let opt_variances = if *kind == ty::Opaque { tcx.variances_of(alias_ty.def_id) } else { &[] }; + let opt_variances = if kind == ty::Opaque { tcx.variances_of(alias_ty.def_id) } else { &[] }; for (index, child) in alias_ty.args.iter().enumerate() { if opt_variances.get(index) == Some(&ty::Bivariant) { continue; diff --git a/compiler/rustc_infer/src/infer/outlives/for_liveness.rs b/compiler/rustc_infer/src/infer/outlives/for_liveness.rs index 488f435994d4d..d15ac35592624 100644 --- a/compiler/rustc_infer/src/infer/outlives/for_liveness.rs +++ b/compiler/rustc_infer/src/infer/outlives/for_liveness.rs @@ -97,7 +97,7 @@ where } else { // Skip lifetime parameters that are not captures. let variances = match kind { - ty::Opaque => Some(self.tcx.variances_of(*def_id)), + ty::Opaque => Some(self.tcx.variances_of(def_id)), _ => None, }; diff --git a/compiler/rustc_infer/src/infer/outlives/obligations.rs b/compiler/rustc_infer/src/infer/outlives/obligations.rs index 32c790523b64c..3f525bccde564 100644 --- a/compiler/rustc_infer/src/infer/outlives/obligations.rs +++ b/compiler/rustc_infer/src/infer/outlives/obligations.rs @@ -406,7 +406,7 @@ where // will be invoked with `['b => ^1]` and so we will get `^1` returned. let bound = bound_outlives.skip_binder(); let ty::Alias(_, alias_ty) = bound.0.kind() else { bug!("expected AliasTy") }; - self.verify_bound.declared_bounds_from_definition(*alias_ty).all(|r| r != bound.1) + self.verify_bound.declared_bounds_from_definition(alias_ty).all(|r| r != bound.1) }); // If declared bounds list is empty, the only applicable rule is diff --git a/compiler/rustc_infer/src/infer/outlives/verify.rs b/compiler/rustc_infer/src/infer/outlives/verify.rs index 7e977b9b95455..1a3de66c032f7 100644 --- a/compiler/rustc_infer/src/infer/outlives/verify.rs +++ b/compiler/rustc_infer/src/infer/outlives/verify.rs @@ -241,7 +241,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> { (r, p) ); // Fast path for the common case. - match (&p, erased_ty.kind()) { + match (p, erased_ty.kind()) { // In outlive routines, all types are expected to be fully normalized. // And therefore we can safely use structural equality for alias types. (GenericKind::Param(p1), ty::Param(p2)) if p1 == p2 => {} diff --git a/compiler/rustc_infer/src/infer/relate/combine.rs b/compiler/rustc_infer/src/infer/relate/combine.rs index b193f4bcede66..c426a8ca62c57 100644 --- a/compiler/rustc_infer/src/infer/relate/combine.rs +++ b/compiler/rustc_infer/src/infer/relate/combine.rs @@ -67,37 +67,37 @@ impl<'tcx> InferCtxt<'tcx> { match (a.kind(), b.kind()) { // Relate integral variables to other types - (&ty::Infer(ty::IntVar(a_id)), &ty::Infer(ty::IntVar(b_id))) => { + (ty::Infer(ty::IntVar(a_id)), ty::Infer(ty::IntVar(b_id))) => { self.inner.borrow_mut().int_unification_table().union(a_id, b_id); Ok(a) } - (&ty::Infer(ty::IntVar(v_id)), &ty::Int(v)) => { + (ty::Infer(ty::IntVar(v_id)), ty::Int(v)) => { self.unify_integral_variable(v_id, IntType(v)); Ok(b) } - (&ty::Int(v), &ty::Infer(ty::IntVar(v_id))) => { + (ty::Int(v), ty::Infer(ty::IntVar(v_id))) => { self.unify_integral_variable(v_id, IntType(v)); Ok(a) } - (&ty::Infer(ty::IntVar(v_id)), &ty::Uint(v)) => { + (ty::Infer(ty::IntVar(v_id)), ty::Uint(v)) => { self.unify_integral_variable(v_id, UintType(v)); Ok(b) } - (&ty::Uint(v), &ty::Infer(ty::IntVar(v_id))) => { + (ty::Uint(v), ty::Infer(ty::IntVar(v_id))) => { self.unify_integral_variable(v_id, UintType(v)); Ok(a) } // Relate floating-point variables to other types - (&ty::Infer(ty::FloatVar(a_id)), &ty::Infer(ty::FloatVar(b_id))) => { + (ty::Infer(ty::FloatVar(a_id)), ty::Infer(ty::FloatVar(b_id))) => { self.inner.borrow_mut().float_unification_table().union(a_id, b_id); Ok(a) } - (&ty::Infer(ty::FloatVar(v_id)), &ty::Float(v)) => { + (ty::Infer(ty::FloatVar(v_id)), ty::Float(v)) => { self.unify_float_variable(v_id, ty::FloatVarValue::Known(v)); Ok(b) } - (&ty::Float(v), &ty::Infer(ty::FloatVar(v_id))) => { + (ty::Float(v), ty::Infer(ty::FloatVar(v_id))) => { self.unify_float_variable(v_id, ty::FloatVarValue::Known(v)); Ok(a) } @@ -131,7 +131,7 @@ impl<'tcx> InferCtxt<'tcx> { } // All other cases of inference are errors - (&ty::Infer(_), _) | (_, &ty::Infer(_)) => { + (ty::Infer(_), _) | (_, ty::Infer(_)) => { Err(TypeError::Sorts(ty::relate::expected_found(a, b))) } @@ -139,7 +139,7 @@ impl<'tcx> InferCtxt<'tcx> { // equal to any other type (except for possibly itself). This is an // extremely heavy hammer, but can be relaxed in a fowards-compatible // way later. - (&ty::Alias(ty::Opaque, _), _) | (_, &ty::Alias(ty::Opaque, _)) if self.intercrate => { + (ty::Alias(ty::Opaque, _), _) | (_, ty::Alias(ty::Opaque, _)) if self.intercrate => { relation.register_predicates([ty::Binder::dummy(ty::PredicateKind::Ambiguous)]); Ok(a) } diff --git a/compiler/rustc_infer/src/infer/relate/generalize.rs b/compiler/rustc_infer/src/infer/relate/generalize.rs index 225c126fcf819..3f7c19bc1a394 100644 --- a/compiler/rustc_infer/src/infer/relate/generalize.rs +++ b/compiler/rustc_infer/src/infer/relate/generalize.rs @@ -57,7 +57,7 @@ impl<'tcx> InferCtxt<'tcx> { )?; // Constrain `b_vid` to the generalized type `generalized_ty`. - if let &ty::Infer(ty::TyVar(generalized_vid)) = generalized_ty.kind() { + if let ty::Infer(ty::TyVar(generalized_vid)) = generalized_ty.kind() { self.inner.borrow_mut().type_variables().equate(target_vid, generalized_vid); } else { self.inner.borrow_mut().type_variables().instantiate(target_vid, generalized_ty); @@ -97,7 +97,7 @@ impl<'tcx> InferCtxt<'tcx> { relation.register_predicates([ty::PredicateKind::AliasRelate(lhs, rhs, direction)]); } else { match source_ty.kind() { - &ty::Alias(ty::Projection, data) => { + ty::Alias(ty::Projection, data) => { // FIXME: This does not handle subtyping correctly, we could // instead create a new inference variable `?normalized_source`, emitting // `Projection(normalized_source, ?ty_normalized)` and `?normalized_source <: generalized_ty`. @@ -459,7 +459,7 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> { // any other type variable related to `vid` via // subtyping. This is basically our "occurs check", preventing // us from creating infinitely sized types. - let g = match *t.kind() { + let g = match t.kind() { ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => { bug!("unexpected infer type: {t}") } diff --git a/compiler/rustc_infer/src/infer/relate/lattice.rs b/compiler/rustc_infer/src/infer/relate/lattice.rs index c0c51a2820b3d..4eb1eb6f8259f 100644 --- a/compiler/rustc_infer/src/infer/relate/lattice.rs +++ b/compiler/rustc_infer/src/infer/relate/lattice.rs @@ -86,24 +86,24 @@ where // is (e.g.) `Box`. A more obvious solution might be to // iterate on the subtype obligations that are returned, but I // think this suffices. -nmatsakis - (&ty::Infer(TyVar(..)), _) => { + (ty::Infer(TyVar(..)), _) => { let v = infcx.next_ty_var(this.cause().span); this.relate_bound(v, b, a)?; Ok(v) } - (_, &ty::Infer(TyVar(..))) => { + (_, ty::Infer(TyVar(..))) => { let v = infcx.next_ty_var(this.cause().span); this.relate_bound(v, a, b)?; Ok(v) } ( - &ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, .. }), - &ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }), + ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, .. }), + ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }), ) if a_def_id == b_def_id => infcx.super_combine_tys(this, a, b), - (&ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }), _) - | (_, &ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. })) + (ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }), _) + | (_, ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. })) if this.define_opaque_types() == DefineOpaqueTypes::Yes && def_id.is_local() && !this.infcx().next_trait_solver() => diff --git a/compiler/rustc_infer/src/infer/relate/type_relating.rs b/compiler/rustc_infer/src/infer/relate/type_relating.rs index e55a587882123..3e59a46a12dc5 100644 --- a/compiler/rustc_infer/src/infer/relate/type_relating.rs +++ b/compiler/rustc_infer/src/infer/relate/type_relating.rs @@ -84,7 +84,7 @@ impl<'tcx> TypeRelation<'tcx> for TypeRelating<'_, '_, 'tcx> { let b = infcx.shallow_resolve(b); match (a.kind(), b.kind()) { - (&ty::Infer(TyVar(a_id)), &ty::Infer(TyVar(b_id))) => { + (ty::Infer(TyVar(a_id)), ty::Infer(TyVar(b_id))) => { match self.ambient_variance { ty::Covariant => { // can't make progress on `A <: B` if both A and B are @@ -123,10 +123,10 @@ impl<'tcx> TypeRelation<'tcx> for TypeRelating<'_, '_, 'tcx> { } } - (&ty::Infer(TyVar(a_vid)), _) => { + (ty::Infer(TyVar(a_vid)), _) => { infcx.instantiate_ty_var(self, true, a_vid, self.ambient_variance, b)?; } - (_, &ty::Infer(TyVar(b_vid))) => { + (_, ty::Infer(TyVar(b_vid))) => { infcx.instantiate_ty_var( self, false, @@ -136,20 +136,20 @@ impl<'tcx> TypeRelation<'tcx> for TypeRelating<'_, '_, 'tcx> { )?; } - (&ty::Error(e), _) | (_, &ty::Error(e)) => { + (ty::Error(e), _) | (_, ty::Error(e)) => { infcx.set_tainted_by_errors(e); return Ok(Ty::new_error(self.tcx(), e)); } ( - &ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, .. }), - &ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }), + ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, .. }), + ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }), ) if a_def_id == b_def_id => { infcx.super_combine_tys(self, a, b)?; } - (&ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }), _) - | (_, &ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. })) + (ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }), _) + | (_, ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. })) if self.fields.define_opaque_types == DefineOpaqueTypes::Yes && def_id.is_local() && !infcx.next_trait_solver() => diff --git a/compiler/rustc_infer/src/infer/resolve.rs b/compiler/rustc_infer/src/infer/resolve.rs index 830d79f52b945..7645b45d59c38 100644 --- a/compiler/rustc_infer/src/infer/resolve.rs +++ b/compiler/rustc_infer/src/infer/resolve.rs @@ -130,7 +130,7 @@ impl<'a, 'tcx> FallibleTypeFolder> for FullTypeResolver<'a, 'tcx> { Ok(t) // micro-optimize -- if there is nothing in this type that this fold affects... } else { let t = self.infcx.shallow_resolve(t); - match *t.kind() { + match t.kind() { ty::Infer(ty::TyVar(vid)) => Err(FixupError::UnresolvedTy(vid)), ty::Infer(ty::IntVar(vid)) => Err(FixupError::UnresolvedIntTy(vid)), ty::Infer(ty::FloatVar(vid)) => Err(FixupError::UnresolvedFloatTy(vid)), diff --git a/compiler/rustc_infer/src/infer/snapshot/fudge.rs b/compiler/rustc_infer/src/infer/snapshot/fudge.rs index a086c82c92e8a..3325891217cd6 100644 --- a/compiler/rustc_infer/src/infer/snapshot/fudge.rs +++ b/compiler/rustc_infer/src/infer/snapshot/fudge.rs @@ -188,7 +188,7 @@ impl<'a, 'tcx> TypeFolder> for InferenceFudger<'a, 'tcx> { } fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { - match *ty.kind() { + match ty.kind() { ty::Infer(ty::InferTy::TyVar(vid)) => { if self.type_vars.0.contains(&vid) { // This variable was created during the fudging. diff --git a/compiler/rustc_infer/src/infer/type_variable.rs b/compiler/rustc_infer/src/infer/type_variable.rs index b56b39e61f0c8..74e87b38feb86 100644 --- a/compiler/rustc_infer/src/infer/type_variable.rs +++ b/compiler/rustc_infer/src/infer/type_variable.rs @@ -187,7 +187,7 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> { /// instantiated, then return the with which it was /// instantiated. Otherwise, returns `t`. pub fn replace_if_possible(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { - match *t.kind() { + match t.kind() { ty::Infer(ty::TyVar(v)) => match self.probe(v) { TypeVariableValue::Unknown { .. } => t, TypeVariableValue::Known { value } => value, diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 87c433a5dc0bb..f8a7c68536df2 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -565,7 +565,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc { let impl_ty = cx.tcx.type_of(parent).instantiate_identity(); let outerdef = match impl_ty.kind() { ty::Adt(def, _) => Some(def.did()), - ty::Foreign(def_id) => Some(*def_id), + ty::Foreign(def_id) => Some(def_id), _ => None, }; let is_hidden = match outerdef { @@ -1204,7 +1204,7 @@ declare_lint_pass!(MutableTransmutes => [MUTABLE_TRANSMUTES]); impl<'tcx> LateLintPass<'tcx> for MutableTransmutes { fn check_expr(&mut self, cx: &LateContext<'_>, expr: &hir::Expr<'_>) { - if let Some((&ty::Ref(_, _, from_mutbl), &ty::Ref(_, _, to_mutbl))) = + if let Some((ty::Ref(_, _, from_mutbl), ty::Ref(_, _, to_mutbl))) = get_transmute_from_to(cx, expr).map(|(ty1, ty2)| (ty1.kind(), ty2.kind())) { if from_mutbl < to_mutbl { @@ -2583,7 +2583,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue { let span = cx.tcx.def_span(adt_def.did()); let mut potential_variants = adt_def.variants().iter().filter_map(|variant| { let definitely_inhabited = match variant - .inhabited_predicate(cx.tcx, *adt_def) + .inhabited_predicate(cx.tcx, adt_def) .instantiate(cx.tcx, args) .apply_any_module(cx.tcx, cx.param_env) { @@ -2640,7 +2640,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue { Array(ty, len) => { if matches!(len.try_eval_target_usize(cx.tcx, cx.param_env), Some(v) if v > 0) { // Array length known at array non-empty -- recurse. - ty_find_init_error(cx, *ty, init) + ty_find_init_error(cx, ty, init) } else { // Empty array or size unknown. None diff --git a/compiler/rustc_lint/src/for_loops_over_fallibles.rs b/compiler/rustc_lint/src/for_loops_over_fallibles.rs index aa00fb4573d80..fa30e84e91891 100644 --- a/compiler/rustc_lint/src/for_loops_over_fallibles.rs +++ b/compiler/rustc_lint/src/for_loops_over_fallibles.rs @@ -53,9 +53,9 @@ impl<'tcx> LateLintPass<'tcx> for ForLoopsOverFallibles { let ty = cx.typeck_results().expr_ty(arg); let (adt, args, ref_mutability) = match ty.kind() { - &ty::Adt(adt, args) => (adt, args, None), - &ty::Ref(_, ty, mutability) => match ty.kind() { - &ty::Adt(adt, args) => (adt, args, Some(mutability)), + ty::Adt(adt, args) => (adt, args, None), + ty::Ref(_, ty, mutability) => match ty.kind() { + ty::Adt(adt, args) => (adt, args, Some(mutability)), _ => return, }, _ => return, diff --git a/compiler/rustc_lint/src/foreign_modules.rs b/compiler/rustc_lint/src/foreign_modules.rs index 5da1cbc2283b6..89fee7da95654 100644 --- a/compiler/rustc_lint/src/foreign_modules.rs +++ b/compiler/rustc_lint/src/foreign_modules.rs @@ -229,7 +229,7 @@ fn structurally_same_type_impl<'tcx>( // type unless the newtype makes the type non-null. let non_transparent_ty = |mut ty: Ty<'tcx>| -> Ty<'tcx> { loop { - if let ty::Adt(def, args) = *ty.kind() { + if let ty::Adt(def, args) = ty.kind() { let is_transparent = def.repr().transparent(); let is_non_null = types::nonnull_optimization_guaranteed(tcx, def); debug!( @@ -283,7 +283,7 @@ fn structurally_same_type_impl<'tcx>( #[allow(rustc::usage_of_ty_tykind)] let is_primitive_or_pointer = - |kind: &ty::TyKind<'_>| kind.is_primitive() || matches!(kind, RawPtr(..) | Ref(..)); + |kind: ty::TyKind<'_>| kind.is_primitive() || matches!(kind, RawPtr(..) | Ref(..)); ensure_sufficient_stack(|| { match (a_kind, b_kind) { @@ -318,23 +318,23 @@ fn structurally_same_type_impl<'tcx>( // For arrays, we also check the constness of the type. a_const.kind() == b_const.kind() && structurally_same_type_impl( - seen_types, tcx, param_env, *a_ty, *b_ty, ckind, + seen_types, tcx, param_env, a_ty, b_ty, ckind, ) } (Slice(a_ty), Slice(b_ty)) => { - structurally_same_type_impl(seen_types, tcx, param_env, *a_ty, *b_ty, ckind) + structurally_same_type_impl(seen_types, tcx, param_env, a_ty, b_ty, ckind) } (RawPtr(a_ty, a_mutbl), RawPtr(b_ty, b_mutbl)) => { a_mutbl == b_mutbl && structurally_same_type_impl( - seen_types, tcx, param_env, *a_ty, *b_ty, ckind, + seen_types, tcx, param_env, a_ty, b_ty, ckind, ) } (Ref(_a_region, a_ty, a_mut), Ref(_b_region, b_ty, b_mut)) => { // For structural sameness, we don't need the region to be same. a_mut == b_mut && structurally_same_type_impl( - seen_types, tcx, param_env, *a_ty, *b_ty, ckind, + seen_types, tcx, param_env, a_ty, b_ty, ckind, ) } (FnDef(..), FnDef(..)) => { diff --git a/compiler/rustc_lint/src/impl_trait_overcaptures.rs b/compiler/rustc_lint/src/impl_trait_overcaptures.rs index a311c274a6bae..53c6b804e04ed 100644 --- a/compiler/rustc_lint/src/impl_trait_overcaptures.rs +++ b/compiler/rustc_lint/src/impl_trait_overcaptures.rs @@ -193,7 +193,7 @@ impl<'tcx> TypeVisitor> for VisitOpaqueTypes<'tcx> { return; } - if let ty::Alias(ty::Projection, opaque_ty) = *t.kind() + if let ty::Alias(ty::Projection, opaque_ty) = t.kind() && self.tcx.is_impl_trait_in_trait(opaque_ty.def_id) { // visit the opaque of the RPITIT @@ -201,7 +201,7 @@ impl<'tcx> TypeVisitor> for VisitOpaqueTypes<'tcx> { .type_of(opaque_ty.def_id) .instantiate(self.tcx, opaque_ty.args) .visit_with(self) - } else if let ty::Alias(ty::Opaque, opaque_ty) = *t.kind() + } else if let ty::Alias(ty::Opaque, opaque_ty) = t.kind() && let Some(opaque_def_id) = opaque_ty.def_id.as_local() // Don't recurse infinitely on an opaque && self.seen.insert(opaque_def_id) @@ -399,7 +399,7 @@ fn extract_def_id_from_arg<'tcx>( _ => unreachable!(), }, ty::GenericArgKind::Type(ty) => { - let ty::Param(param_ty) = *ty.kind() else { + let ty::Param(param_ty) = ty.kind() else { bug!(); }; generics.type_param(param_ty, tcx).def_id diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index 9110cccdc46f0..855618f0808f4 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -64,7 +64,7 @@ fn typeck_results_of_method_fn<'tcx>( Some((segment.ident.span, def_id, cx.typeck_results().node_args(expr.hir_id))) } _ => match cx.typeck_results().node_type(expr.hir_id).kind() { - &ty::FnDef(def_id, args) => Some((expr.span, def_id, args)), + ty::FnDef(def_id, args) => Some((expr.span, def_id, args)), _ => None, }, } @@ -371,7 +371,7 @@ impl LateLintPass<'_> for Diagnostics { let (span, def_id, fn_gen_args, call_tys) = match expr.kind { ExprKind::Call(callee, args) => { match cx.typeck_results().node_type(callee.hir_id).kind() { - &ty::FnDef(def_id, fn_gen_args) => { + ty::FnDef(def_id, fn_gen_args) => { let call_tys: Vec<_> = args.iter().map(|arg| cx.typeck_results().expr_ty(arg)).collect(); (callee.span, def_id, fn_gen_args, call_tys) diff --git a/compiler/rustc_lint/src/map_unit_fn.rs b/compiler/rustc_lint/src/map_unit_fn.rs index e355604e2068c..168d3d06436eb 100644 --- a/compiler/rustc_lint/src/map_unit_fn.rs +++ b/compiler/rustc_lint/src/map_unit_fn.rs @@ -66,10 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for MapUnitFn { MAP_UNIT_FN, span, MappingToUnit { - function_label: cx - .tcx - .span_of_impl(*id) - .unwrap_or(default_span), + function_label: cx.tcx.span_of_impl(id).unwrap_or(default_span), argument_label: args[0].span, map_label: arg_ty.default_span(cx.tcx), suggestion: path.ident.span, @@ -85,10 +82,7 @@ impl<'tcx> LateLintPass<'tcx> for MapUnitFn { MAP_UNIT_FN, span, MappingToUnit { - function_label: cx - .tcx - .span_of_impl(*id) - .unwrap_or(default_span), + function_label: cx.tcx.span_of_impl(id).unwrap_or(default_span), argument_label: args[0].span, map_label: arg_ty.default_span(cx.tcx), suggestion: path.ident.span, diff --git a/compiler/rustc_lint/src/non_fmt_panic.rs b/compiler/rustc_lint/src/non_fmt_panic.rs index c9d6785411237..f38e663dd3d48 100644 --- a/compiler/rustc_lint/src/non_fmt_panic.rs +++ b/compiler/rustc_lint/src/non_fmt_panic.rs @@ -50,7 +50,7 @@ declare_lint_pass!(NonPanicFmt => [NON_FMT_PANICS]); impl<'tcx> LateLintPass<'tcx> for NonPanicFmt { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) { if let hir::ExprKind::Call(f, [arg]) = &expr.kind { - if let &ty::FnDef(def_id, _) = cx.typeck_results().expr_ty(f).kind() { + if let ty::FnDef(def_id, _) = cx.typeck_results().expr_ty(f).kind() { let f_diagnostic_name = cx.tcx.get_diagnostic_name(def_id); if Some(def_id) == cx.tcx.lang_items().begin_panic_fn() diff --git a/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs b/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs index 6098da990c043..3ae93428804e1 100644 --- a/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs +++ b/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs @@ -86,7 +86,7 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound { let Some(proj_term) = proj.term.as_type() else { return }; // HACK: `impl Trait` from an RPIT is "ok"... - if let ty::Alias(ty::Opaque, opaque_ty) = *proj_term.kind() + if let ty::Alias(ty::Opaque, opaque_ty) = proj_term.kind() && cx.tcx.parent(opaque_ty.def_id) == def_id && matches!( opaque.origin, @@ -99,7 +99,7 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound { // HACK: `async fn() -> Self` in traits is "ok"... // This is not really that great, but it's similar to why the `-> Self` // return type is well-formed in traits even when `Self` isn't sized. - if let ty::Param(param_ty) = *proj_term.kind() + if let ty::Param(param_ty) = proj_term.kind() && param_ty.name == kw::SelfUpper && matches!(opaque.origin, hir::OpaqueTyOrigin::AsyncFn(_)) && opaque.in_trait @@ -155,7 +155,7 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound { ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }), ty::ClauseKind::Trait(trait_pred), ) => Some(AddBound { - suggest_span: cx.tcx.def_span(*def_id).shrink_to_hi(), + suggest_span: cx.tcx.def_span(def_id).shrink_to_hi(), trait_ref: trait_pred.print_modifiers_and_trait_path(), }), _ => None, diff --git a/compiler/rustc_lint/src/reference_casting.rs b/compiler/rustc_lint/src/reference_casting.rs index 34153e3a220d3..9100e3a939f5e 100644 --- a/compiler/rustc_lint/src/reference_casting.rs +++ b/compiler/rustc_lint/src/reference_casting.rs @@ -217,7 +217,7 @@ fn is_cast_to_bigger_memory_layout<'tcx>( return None; } - let from_layout = cx.layout_of(*inner_start_ty).ok()?; + let from_layout = cx.layout_of(inner_start_ty).ok()?; // if the type isn't sized, we bail out, instead of potentially giving // the user a meaningless warning. @@ -226,7 +226,7 @@ fn is_cast_to_bigger_memory_layout<'tcx>( } let alloc_layout = cx.layout_of(alloc_ty).ok()?; - let to_layout = cx.layout_of(*inner_end_ty).ok()?; + let to_layout = cx.layout_of(inner_end_ty).ok()?; if to_layout.layout.size() > from_layout.layout.size() && to_layout.layout.size() > alloc_layout.layout.size() diff --git a/compiler/rustc_lint/src/shadowed_into_iter.rs b/compiler/rustc_lint/src/shadowed_into_iter.rs index 41ec84faa7833..04ffd4ab4ca77 100644 --- a/compiler/rustc_lint/src/shadowed_into_iter.rs +++ b/compiler/rustc_lint/src/shadowed_into_iter.rs @@ -91,13 +91,13 @@ impl<'tcx> LateLintPass<'tcx> for ShadowedIntoIter { [receiver_ty].into_iter().chain(adjustments.iter().map(|adj| adj.target)).collect(); fn is_ref_to_array(ty: Ty<'_>) -> bool { - if let ty::Ref(_, pointee_ty, _) = *ty.kind() { pointee_ty.is_array() } else { false } + if let ty::Ref(_, pointee_ty, _) = ty.kind() { pointee_ty.is_array() } else { false } } fn is_boxed_slice(ty: Ty<'_>) -> bool { ty.is_box() && ty.boxed_ty().is_slice() } fn is_ref_to_boxed_slice(ty: Ty<'_>) -> bool { - if let ty::Ref(_, pointee_ty, _) = *ty.kind() { + if let ty::Ref(_, pointee_ty, _) = ty.kind() { is_boxed_slice(pointee_ty) } else { false diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index 9d3a838666aff..643f4c76636b7 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -550,7 +550,7 @@ fn lint_literal<'tcx>( e: &'tcx hir::Expr<'tcx>, lit: &hir::Lit, ) { - match *cx.typeck_results().node_type(e.hir_id).kind() { + match cx.typeck_results().node_type(e.hir_id).kind() { ty::Int(t) => { match lit.node { ast::LitKind::Int(v, ast::LitIntType::Signed(_) | ast::LitIntType::Unsuffixed) => { @@ -681,14 +681,14 @@ fn lint_wide_pointer<'tcx>( // here we remove any "implicit" references and count the number // of them to correctly suggest the right number of deref while let ty::Ref(_, inner_ty, _) = ty.kind() { - ty = *inner_ty; + ty = inner_ty; refs += 1; } // get the inner type of a pointer (or akin) let mut modifiers = String::new(); ty = match ty.kind() { - ty::RawPtr(ty, _) => *ty, + ty::RawPtr(ty, _) => ty, ty::Adt(def, args) if cx.tcx.is_diagnostic_item(sym::NonNull, def.did()) => { modifiers.push_str(".as_ptr()"); args.type_at(0) @@ -864,7 +864,7 @@ impl<'tcx> LateLintPass<'tcx> for TypeLimits { // Normalize the binop so that the literal is always on the RHS in // the comparison let norm_binop = if swap { rev_binop(binop) } else { binop }; - match *cx.typeck_results().node_type(expr.hir_id).kind() { + match cx.typeck_results().node_type(expr.hir_id).kind() { ty::Int(int_ty) => { let (min, max) = int_ty_range(int_ty); let lit_val: i128 = match lit.kind { @@ -1034,7 +1034,7 @@ fn ty_is_known_nonnull<'tcx>( ty::Ref(..) => true, ty::Adt(def, _) if def.is_box() && matches!(mode, CItemKind::Definition) => true, ty::Adt(def, args) if def.repr().transparent() && !def.is_union() => { - let marked_non_null = nonnull_optimization_guaranteed(tcx, *def); + let marked_non_null = nonnull_optimization_guaranteed(tcx, def); if marked_non_null { return true; @@ -1063,7 +1063,7 @@ fn get_nullable_type<'tcx>( ) -> Option> { let ty = tcx.try_normalize_erasing_regions(param_env, ty).unwrap_or(ty); - Some(match *ty.kind() { + Some(match ty.kind() { ty::Adt(field_def, field_args) => { let inner_field_ty = { let mut first_non_zst_ty = @@ -1298,7 +1298,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { return FfiSafe; } - match *ty.kind() { + match ty.kind() { ty::Adt(def, args) => { if def.is_box() && matches!(self.mode, CItemKind::Definition) { if ty.boxed_ty().is_sized(tcx, self.cx.param_env) { diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index c8da9f179e711..3184a2ce598fd 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -117,7 +117,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { && 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) + && let async_fn_def_id = cx.tcx.parent(future_def_id) && matches!(cx.tcx.def_kind(async_fn_def_id), DefKind::Fn | DefKind::AssocFn) // Check that this `impl Future` actually comes from an `async fn` && cx.tcx.asyncness(async_fn_def_id).is_async() @@ -283,7 +283,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { return Some(MustUsePath::Suppressed); } - match *ty.kind() { + match ty.kind() { ty::Adt(..) if ty.is_box() => { let boxed_ty = ty.boxed_ty(); is_ty_must_use(cx, boxed_ty, expr, span) diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index c91b67297ee80..ebb59b27a5655 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -1275,7 +1275,7 @@ impl<'tcx> ExtraComments<'tcx> { } fn use_verbose(ty: Ty<'_>, fn_def: bool) -> bool { - match *ty.kind() { + match ty.kind() { ty::Int(_) | ty::Uint(_) | ty::Bool | ty::Char | ty::Float(_) => false, // Unit type ty::Tuple(g_args) if g_args.is_empty() => false, @@ -1741,13 +1741,13 @@ fn pretty_print_const_value_tcx<'tcx>( return Ok(()); } } - (_, ty::Ref(_, inner_ty, _)) if matches!(inner_ty.kind(), ty::Slice(t) if *t == u8_type) => { + (_, ty::Ref(_, inner_ty, _)) if matches!(inner_ty.kind(), ty::Slice(t) if t == u8_type) => { if let Some(data) = ct.try_get_slice_bytes_for_diagnostics(tcx) { pretty_print_byte_str(fmt, data)?; return Ok(()); } } - (ConstValue::Indirect { alloc_id, offset }, ty::Array(t, n)) if *t == u8_type => { + (ConstValue::Indirect { alloc_id, offset }, ty::Array(t, n)) if t == u8_type => { let n = n.try_to_target_usize(tcx).unwrap(); let alloc = tcx.global_alloc(alloc_id).unwrap_memory(); // cast is ok because we already checked for pointer size (32 or 64 bit) above @@ -1769,7 +1769,7 @@ fn pretty_print_const_value_tcx<'tcx>( let ty = tcx.lift(ty).unwrap(); if let Some(contents) = tcx.try_destructure_mir_constant_for_user_output(ct, ty) { let fields: Vec<(ConstValue<'_>, Ty<'_>)> = contents.fields.to_vec(); - match *ty.kind() { + match ty.kind() { ty::Array(..) => { fmt.write_str("[")?; comma_sep(tcx, fmt, fields)?; @@ -1836,7 +1836,7 @@ fn pretty_print_const_value_tcx<'tcx>( (ConstValue::ZeroSized, ty::FnDef(d, s)) => { let mut cx = FmtPrinter::new(tcx, Namespace::ValueNS); cx.print_alloc_ids = true; - cx.print_value_path(*d, s)?; + cx.print_value_path(d, s)?; fmt.write_str(&cx.into_buffer())?; return Ok(()); } diff --git a/compiler/rustc_middle/src/mir/statement.rs b/compiler/rustc_middle/src/mir/statement.rs index 4d9a931d69791..06c9386d58d4e 100644 --- a/compiler/rustc_middle/src/mir/statement.rs +++ b/compiler/rustc_middle/src/mir/statement.rs @@ -379,7 +379,7 @@ impl<'tcx> Operand<'tcx> { /// find as the `func` in a [`TerminatorKind::Call`]. pub fn const_fn_def(&self) -> Option<(DefId, GenericArgsRef<'tcx>)> { let const_ty = self.constant()?.const_.ty(); - if let ty::FnDef(def_id, args) = *const_ty.kind() { Some((def_id, args)) } else { None } + if let ty::FnDef(def_id, args) = const_ty.kind() { Some((def_id, args)) } else { None } } } diff --git a/compiler/rustc_middle/src/mir/tcx.rs b/compiler/rustc_middle/src/mir/tcx.rs index 126387db1d9c5..3efe239028c98 100644 --- a/compiler/rustc_middle/src/mir/tcx.rs +++ b/compiler/rustc_middle/src/mir/tcx.rs @@ -90,11 +90,11 @@ impl<'tcx> PlaceTy<'tcx> { ProjectionElem::Subslice { from, to, from_end } => { PlaceTy::from_ty(match self.ty.kind() { ty::Slice(..) => self.ty, - ty::Array(inner, _) if !from_end => Ty::new_array(tcx, *inner, to - from), + ty::Array(inner, _) if !from_end => Ty::new_array(tcx, inner, to - from), ty::Array(inner, size) if from_end => { let size = size.eval_target_usize(tcx, param_env); let len = size - from - to; - Ty::new_array(tcx, *inner, len) + Ty::new_array(tcx, inner, len) } _ => bug!("cannot subslice non-array type: `{:?}`", self), }) diff --git a/compiler/rustc_middle/src/query/keys.rs b/compiler/rustc_middle/src/query/keys.rs index faa137019cb92..fd99d82539bd3 100644 --- a/compiler/rustc_middle/src/query/keys.rs +++ b/compiler/rustc_middle/src/query/keys.rs @@ -408,7 +408,7 @@ impl<'tcx> Key for Ty<'tcx> { } fn ty_def_id(&self) -> Option { - match *self.kind() { + match self.kind() { ty::Adt(adt, _) => Some(adt.did()), ty::Coroutine(def_id, ..) => Some(def_id), _ => None, diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index 454897aa67207..d83fb48016a0e 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -862,7 +862,7 @@ impl<'tcx> PatRange<'tcx> { /// Whether this range covers the full extent of possible values (best-effort, we ignore floats). #[inline] pub fn is_full_range(&self, tcx: TyCtxt<'tcx>) -> Option { - let (min, max, size, bias) = match *self.ty.kind() { + let (min, max, size, bias) = match self.ty.kind() { ty::Char => (0, std::char::MAX as u128, Size::from_bits(32), 0), ty::Int(ity) => { let size = Integer::from_int_ty(&tcx, ity).size(); @@ -1060,7 +1060,7 @@ impl<'tcx> PatRangeBoundary<'tcx> { a.partial_cmp(&b) } ty::Int(ity) => { - let size = rustc_target::abi::Integer::from_int_ty(&tcx, *ity).size(); + let size = rustc_target::abi::Integer::from_int_ty(&tcx, ity).size(); let a = size.sign_extend(a) as i128; let b = size.sign_extend(b) as i128; Some(a.cmp(&b)) diff --git a/compiler/rustc_middle/src/ty/_match.rs b/compiler/rustc_middle/src/ty/_match.rs index f30270abd5c1e..c269b00154b0d 100644 --- a/compiler/rustc_middle/src/ty/_match.rs +++ b/compiler/rustc_middle/src/ty/_match.rs @@ -66,16 +66,16 @@ impl<'tcx> TypeRelation<'tcx> for MatchAgainstFreshVars<'tcx> { match (a.kind(), b.kind()) { ( _, - &ty::Infer(ty::FreshTy(_)) - | &ty::Infer(ty::FreshIntTy(_)) - | &ty::Infer(ty::FreshFloatTy(_)), + ty::Infer(ty::FreshTy(_)) + | ty::Infer(ty::FreshIntTy(_)) + | ty::Infer(ty::FreshFloatTy(_)), ) => Ok(a), - (&ty::Infer(_), _) | (_, &ty::Infer(_)) => { + (ty::Infer(_), _) | (_, ty::Infer(_)) => { Err(TypeError::Sorts(relate::expected_found(a, b))) } - (&ty::Error(guar), _) | (_, &ty::Error(guar)) => Ok(Ty::new_error(self.tcx(), guar)), + (ty::Error(guar), _) | (_, ty::Error(guar)) => Ok(Ty::new_error(self.tcx(), guar)), _ => relate::structurally_relate_tys(self, a, b), } diff --git a/compiler/rustc_middle/src/ty/cast.rs b/compiler/rustc_middle/src/ty/cast.rs index 26c5a865fdc22..1a3aaa43830cb 100644 --- a/compiler/rustc_middle/src/ty/cast.rs +++ b/compiler/rustc_middle/src/ty/cast.rs @@ -60,7 +60,7 @@ impl<'tcx> CastTy<'tcx> { /// Returns `Some` for integral/pointer casts. /// Casts like unsizing casts will return `None`. pub fn from_ty(t: Ty<'tcx>) -> Option> { - match *t.kind() { + match t.kind() { ty::Bool => Some(CastTy::Int(IntTy::Bool)), ty::Char => Some(CastTy::Int(IntTy::Char)), ty::Int(_) => Some(CastTy::Int(IntTy::I)), diff --git a/compiler/rustc_middle/src/ty/codec.rs b/compiler/rustc_middle/src/ty/codec.rs index 33f564e9b59c3..e67ff7c53cc30 100644 --- a/compiler/rustc_middle/src/ty/codec.rs +++ b/compiler/rustc_middle/src/ty/codec.rs @@ -34,7 +34,7 @@ pub const SHORTHAND_OFFSET: usize = 0x80; pub trait EncodableWithShorthand: Copy + Eq + Hash { type Variant: Encodable; - fn variant(&self) -> &Self::Variant; + fn variant(&self) -> Self::Variant; // njn: removed `&` } #[allow(rustc::usage_of_ty_tykind)] @@ -42,7 +42,7 @@ impl<'tcx, E: TyEncoder>> EncodableWithShorthand for Ty<'tcx type Variant = ty::TyKind<'tcx>; #[inline] - fn variant(&self) -> &Self::Variant { + fn variant(&self) -> Self::Variant { self.kind() } } @@ -51,8 +51,8 @@ impl<'tcx, E: TyEncoder>> EncodableWithShorthand for ty::Pre type Variant = ty::PredicateKind<'tcx>; #[inline] - fn variant(&self) -> &Self::Variant { - self + fn variant(&self) -> Self::Variant { + *self // njn: added `*` } } @@ -93,7 +93,7 @@ where // The shorthand encoding uses the same usize as the // discriminant, with an offset so they can't conflict. - let discriminant = intrinsics::discriminant_value(variant); + let discriminant = intrinsics::discriminant_value(&variant); assert!(SHORTHAND_OFFSET > discriminant as usize); let shorthand = start + SHORTHAND_OFFSET; diff --git a/compiler/rustc_middle/src/ty/consts/valtree.rs b/compiler/rustc_middle/src/ty/consts/valtree.rs index 96bc5515a5695..de1662da88565 100644 --- a/compiler/rustc_middle/src/ty/consts/valtree.rs +++ b/compiler/rustc_middle/src/ty/consts/valtree.rs @@ -90,12 +90,12 @@ impl<'tcx> ValTree<'tcx> { // `&str` can be interpreted as raw bytes ty::Str => {} // `&[u8]` can be interpreted as raw bytes - ty::Slice(slice_ty) if *slice_ty == tcx.types.u8 => {} + ty::Slice(slice_ty) if slice_ty == tcx.types.u8 => {} // other `&_` can't be interpreted as raw bytes _ => return None, }, // `[u8; N]` can be interpreted as raw bytes - ty::Array(array_ty, _) if *array_ty == tcx.types.u8 => {} + ty::Array(array_ty, _) if array_ty == tcx.types.u8 => {} // Otherwise, type cannot be interpreted as raw bytes _ => return None, } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index f9a22aa72bee9..c1fe1abea2358 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -2095,7 +2095,7 @@ impl<'tcx> TyCtxt<'tcx> { pub fn signature_unclosure(self, sig: PolyFnSig<'tcx>, safety: hir::Safety) -> PolyFnSig<'tcx> { sig.map_bound(|s| { let params = match s.inputs()[0].kind() { - ty::Tuple(params) => *params, + ty::Tuple(params) => params, _ => bug!(), }; self.mk_fn_sig(params, s.output(), s.c_variadic, safety, abi::Abi::Rust) diff --git a/compiler/rustc_middle/src/ty/diagnostics.rs b/compiler/rustc_middle/src/ty/diagnostics.rs index 8c3ee6955f5d2..5614bde0b40c0 100644 --- a/compiler/rustc_middle/src/ty/diagnostics.rs +++ b/compiler/rustc_middle/src/ty/diagnostics.rs @@ -499,7 +499,7 @@ impl<'tcx> TypeVisitor> for IsSuggestableVisitor<'tcx> { type Result = ControlFlow<()>; fn visit_ty(&mut self, t: Ty<'tcx>) -> Self::Result { - match *t.kind() { + match t.kind() { Infer(InferTy::TyVar(_)) if self.infer_suggestable => {} FnDef(..) @@ -518,7 +518,7 @@ impl<'tcx> TypeVisitor> for IsSuggestableVisitor<'tcx> { let parent_ty = self.tcx.type_of(parent).instantiate_identity(); if let DefKind::TyAlias | DefKind::AssocTy = self.tcx.def_kind(parent) && let Alias(Opaque, AliasTy { def_id: parent_opaque_def_id, .. }) = - *parent_ty.kind() + parent_ty.kind() && parent_opaque_def_id == def_id { // Okay @@ -584,7 +584,7 @@ impl<'tcx> FallibleTypeFolder> for MakeSuggestableFolder<'tcx> { } fn try_fold_ty(&mut self, t: Ty<'tcx>) -> Result, Self::Error> { - let t = match *t.kind() { + let t = match t.kind() { Infer(InferTy::TyVar(_)) if self.infer_suggestable => t, FnDef(def_id, args) if self.placeholder.is_none() => { @@ -613,7 +613,7 @@ impl<'tcx> FallibleTypeFolder> for MakeSuggestableFolder<'tcx> { if let hir::def::DefKind::TyAlias | hir::def::DefKind::AssocTy = self.tcx.def_kind(parent) && let Alias(Opaque, AliasTy { def_id: parent_opaque_def_id, .. }) = - *parent_ty.kind() + parent_ty.kind() && parent_opaque_def_id == def_id { t diff --git a/compiler/rustc_middle/src/ty/error.rs b/compiler/rustc_middle/src/ty/error.rs index 9e2c626478ac6..68fa571629492 100644 --- a/compiler/rustc_middle/src/ty/error.rs +++ b/compiler/rustc_middle/src/ty/error.rs @@ -208,7 +208,7 @@ impl<'tcx> TypeError<'tcx> { impl<'tcx> Ty<'tcx> { pub fn sort_string(self, tcx: TyCtxt<'tcx>) -> Cow<'static, str> { - match *self.kind() { + match self.kind() { ty::Foreign(def_id) => format!("extern type `{}`", tcx.def_path_str(def_id)).into(), ty::FnDef(def_id, ..) => match tcx.def_kind(def_id) { DefKind::Ctor(CtorOf::Struct, _) => "struct constructor".into(), @@ -252,7 +252,7 @@ impl<'tcx> Ty<'tcx> { } pub fn prefix_string(self, tcx: TyCtxt<'_>) -> Cow<'static, str> { - match *self.kind() { + match self.kind() { ty::Infer(_) | ty::Error(_) | ty::Bool diff --git a/compiler/rustc_middle/src/ty/fast_reject.rs b/compiler/rustc_middle/src/ty/fast_reject.rs index 923667e609be4..8049c6e2c6ff2 100644 --- a/compiler/rustc_middle/src/ty/fast_reject.rs +++ b/compiler/rustc_middle/src/ty/fast_reject.rs @@ -87,7 +87,7 @@ pub fn simplify_type<'tcx>( ty: Ty<'tcx>, treat_params: TreatParams, ) -> Option { - match *ty.kind() { + match ty.kind() { ty::Bool => Some(SimplifiedType::Bool), ty::Char => Some(SimplifiedType::Char), ty::Int(int_type) => Some(SimplifiedType::Int(int_type)), @@ -222,7 +222,7 @@ impl DeepRejectCtxt { } let k = impl_ty.kind(); - match *obligation_ty.kind() { + match obligation_ty.kind() { // Purely rigid types, use structural equivalence. ty::Bool | ty::Char @@ -233,39 +233,39 @@ impl DeepRejectCtxt { | ty::Never | ty::Foreign(_) => obligation_ty == impl_ty, ty::Ref(_, obl_ty, obl_mutbl) => match k { - &ty::Ref(_, impl_ty, impl_mutbl) => { + ty::Ref(_, impl_ty, impl_mutbl) => { obl_mutbl == impl_mutbl && self.types_may_unify(obl_ty, impl_ty) } _ => false, }, ty::Adt(obl_def, obl_args) => match k { - &ty::Adt(impl_def, impl_args) => { + ty::Adt(impl_def, impl_args) => { obl_def == impl_def && self.args_may_unify(obl_args, impl_args) } _ => false, }, ty::Pat(obl_ty, _) => { // FIXME(pattern_types): take pattern into account - matches!(k, &ty::Pat(impl_ty, _) if self.types_may_unify(obl_ty, impl_ty)) + matches!(k, ty::Pat(impl_ty, _) if self.types_may_unify(obl_ty, impl_ty)) } ty::Slice(obl_ty) => { - matches!(k, &ty::Slice(impl_ty) if self.types_may_unify(obl_ty, impl_ty)) + matches!(k, ty::Slice(impl_ty) if self.types_may_unify(obl_ty, impl_ty)) } ty::Array(obl_ty, obl_len) => match k { - &ty::Array(impl_ty, impl_len) => { + ty::Array(impl_ty, impl_len) => { self.types_may_unify(obl_ty, impl_ty) && self.consts_may_unify(obl_len, impl_len) } _ => false, }, ty::Tuple(obl) => match k { - &ty::Tuple(imp) => { + ty::Tuple(imp) => { obl.len() == imp.len() && iter::zip(obl, imp).all(|(obl, imp)| self.types_may_unify(obl, imp)) } _ => false, }, - ty::RawPtr(obl_ty, obl_mutbl) => match *k { + ty::RawPtr(obl_ty, obl_mutbl) => match k { ty::RawPtr(imp_ty, imp_mutbl) => { obl_mutbl == imp_mutbl && self.types_may_unify(obl_ty, imp_ty) } diff --git a/compiler/rustc_middle/src/ty/fold.rs b/compiler/rustc_middle/src/ty/fold.rs index 9b5b1430c27f7..b919ac8217487 100644 --- a/compiler/rustc_middle/src/ty/fold.rs +++ b/compiler/rustc_middle/src/ty/fold.rs @@ -191,7 +191,7 @@ where } fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { - match *t.kind() { + match t.kind() { ty::Bound(debruijn, bound_ty) if debruijn == self.current_index => { let ty = self.delegate.replace_ty(bound_ty); debug_assert!(!ty.has_vars_bound_above(ty::INNERMOST)); diff --git a/compiler/rustc_middle/src/ty/inhabitedness/mod.rs b/compiler/rustc_middle/src/ty/inhabitedness/mod.rs index afdf2cbc72667..5b4647eb7e139 100644 --- a/compiler/rustc_middle/src/ty/inhabitedness/mod.rs +++ b/compiler/rustc_middle/src/ty/inhabitedness/mod.rs @@ -202,7 +202,7 @@ impl<'tcx> Ty<'tcx> { /// N.B. this query should only be called through `Ty::inhabited_predicate` fn inhabited_predicate_type<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> InhabitedPredicate<'tcx> { - match *ty.kind() { + match ty.kind() { Adt(adt, args) => tcx.inhabited_predicate_adt(adt.did()).instantiate(tcx, args), Tuple(tys) => { diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs index a887047f62f21..c19c2d1da256a 100644 --- a/compiler/rustc_middle/src/ty/instance.rs +++ b/compiler/rustc_middle/src/ty/instance.rs @@ -694,7 +694,7 @@ impl<'tcx> Instance<'tcx> { trait_id: DefId, rcvr_args: ty::GenericArgsRef<'tcx>, ) -> Option> { - let ty::Coroutine(coroutine_def_id, args) = *rcvr_args.type_at(0).kind() else { + let ty::Coroutine(coroutine_def_id, args) = rcvr_args.type_at(0).kind() else { return None; }; let coroutine_kind = tcx.coroutine_kind(coroutine_def_id).unwrap(); @@ -726,7 +726,7 @@ impl<'tcx> Instance<'tcx> { }; if tcx.lang_items().get(coroutine_callable_item) == Some(trait_item_id) { - let ty::Coroutine(_, id_args) = *tcx.type_of(coroutine_def_id).skip_binder().kind() + let ty::Coroutine(_, id_args) = tcx.type_of(coroutine_def_id).skip_binder().kind() else { bug!() }; @@ -871,7 +871,7 @@ fn polymorphize<'tcx>( fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { debug!("fold_ty: ty={:?}", ty); - match *ty.kind() { + match ty.kind() { ty::Closure(def_id, args) => { let polymorphized_args = polymorphize(self.tcx, ty::InstanceDef::Item(def_id), args); diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 142872009bf21..4a0970c801211 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -350,7 +350,7 @@ impl<'tcx> SizeSkeleton<'tcx> { ) => return Err(e), }; - match *ty.kind() { + match ty.kind() { ty::Ref(_, pointee, _) | ty::RawPtr(pointee, _) => { let non_zero = !ty.is_unsafe_ptr(); @@ -377,7 +377,7 @@ impl<'tcx> SizeSkeleton<'tcx> { } ty::Error(guar) => { // Fixes ICE #124031 - return Err(tcx.arena.alloc(LayoutError::ReferencesError(*guar))); + return Err(tcx.arena.alloc(LayoutError::ReferencesError(guar))); } _ => bug!( "SizeSkeleton::compute({ty}): layout errored ({err:?}), yet \ @@ -784,7 +784,7 @@ where } }; - match *this.ty.kind() { + match this.ty.kind() { ty::Bool | ty::Char | ty::Int(_) @@ -967,7 +967,7 @@ where let tcx = cx.tcx(); let param_env = cx.param_env(); - let pointee_info = match *this.ty.kind() { + let pointee_info = match this.ty.kind() { ty::RawPtr(p_ty, _) if offset.bytes() == 0 => { tcx.layout_of(param_env.and(p_ty)).ok().map(|layout| PointeeInfo { size: layout.size, @@ -1091,7 +1091,7 @@ where } fn is_never(this: TyAndLayout<'tcx>) -> bool { - this.ty.kind() == &ty::Never + this.ty.kind() == ty::Never } fn is_tuple(this: TyAndLayout<'tcx>) -> bool { diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index e0fbf127e7089..5625ccf21fba2 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -479,7 +479,7 @@ impl<'tcx> rustc_type_ir::inherent::IntoKind for Ty<'tcx> { type Kind = TyKind<'tcx>; fn kind(self) -> TyKind<'tcx> { - *self.kind() + self.kind() } } @@ -649,7 +649,7 @@ impl<'tcx> Term<'tcx> { pub fn to_alias_term(self) -> Option> { match self.unpack() { - TermKind::Ty(ty) => match *ty.kind() { + TermKind::Ty(ty) => match ty.kind() { ty::Alias(_kind, alias_ty) => Some(alias_ty.into()), _ => None, }, @@ -1893,7 +1893,7 @@ impl<'tcx> TyCtxt<'tcx> { // If we have a `Coroutine` that comes from an coroutine-closure, // then it may be a by-move or by-ref body. let ty::Coroutine(_, identity_args) = - *self.type_of(def_id).instantiate_identity().kind() + self.type_of(def_id).instantiate_identity().kind() else { unreachable!(); }; diff --git a/compiler/rustc_middle/src/ty/opaque_types.rs b/compiler/rustc_middle/src/ty/opaque_types.rs index 52902aadd7c7b..4a3f199bb465f 100644 --- a/compiler/rustc_middle/src/ty/opaque_types.rs +++ b/compiler/rustc_middle/src/ty/opaque_types.rs @@ -148,7 +148,7 @@ impl<'tcx> TypeFolder> for ReverseMapper<'tcx> { } fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { - match *ty.kind() { + match ty.kind() { ty::Closure(def_id, args) => { let args = self.fold_closure_args(def_id, args); Ty::new_closure(self.tcx, def_id, args) diff --git a/compiler/rustc_middle/src/ty/print/mod.rs b/compiler/rustc_middle/src/ty/print/mod.rs index 3c27df9529aa1..8c4466f34a781 100644 --- a/compiler/rustc_middle/src/ty/print/mod.rs +++ b/compiler/rustc_middle/src/ty/print/mod.rs @@ -258,7 +258,7 @@ fn characteristic_def_id_of_type_cached<'a>( ty: Ty<'a>, visited: &mut SsoHashSet>, ) -> Option { - match *ty.kind() { + match ty.kind() { ty::Adt(adt_def, _) => Some(adt_def.did()), ty::Dynamic(data, ..) => data.principal_def_id(), diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 3cfebaa6b57e5..32439e9f6610e 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -662,7 +662,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { fn pretty_print_type(&mut self, ty: Ty<'tcx>) -> Result<(), PrintError> { define_scoped_cx!(self); - match *ty.kind() { + match ty.kind() { ty::Bool => p!("bool"), ty::Char => p!("char"), ty::Int(t) => p!(write("{}", t.name_str())), @@ -777,7 +777,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { // NOTE: I know we should check for NO_QUERIES here, but it's alright. // `type_of` on a type alias or assoc type should never cause a cycle. if let ty::Alias(ty::Opaque, ty::AliasTy { def_id: d, .. }) = - *self.tcx().type_of(parent).instantiate_identity().kind() + self.tcx().type_of(parent).instantiate_identity().kind() { if d == def_id { // If the type alias directly starts with the `impl` of the @@ -1798,7 +1798,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { let u8_type = self.tcx().types.u8; match (valtree, ty.kind()) { (ty::ValTree::Branch(_), ty::Ref(_, inner_ty, _)) => match inner_ty.kind() { - ty::Slice(t) if *t == u8_type => { + ty::Slice(t) if t == u8_type => { let bytes = valtree.try_to_raw_bytes(self.tcx(), ty).unwrap_or_else(|| { bug!( "expected to convert valtree {:?} to raw bytes for type {:?}", @@ -1817,11 +1817,11 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { } _ => { p!("&"); - p!(pretty_print_const_valtree(valtree, *inner_ty, print_ty)); + p!(pretty_print_const_valtree(valtree, inner_ty, print_ty)); return Ok(()); } }, - (ty::ValTree::Branch(_), ty::Array(t, _)) if *t == u8_type => { + (ty::ValTree::Branch(_), ty::Array(t, _)) if t == u8_type => { let bytes = valtree.try_to_raw_bytes(self.tcx(), ty).unwrap_or_else(|| { bug!("expected to convert valtree to raw bytes for type {:?}", t) }); @@ -1834,7 +1834,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { let contents = self.tcx().destructure_const(ty::Const::new_value(self.tcx(), valtree, ty)); let fields = contents.fields.iter().copied(); - match *ty.kind() { + match ty.kind() { ty::Array(..) => { p!("[", comma_sep(fields), "]"); } @@ -1885,7 +1885,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { } (ty::ValTree::Leaf(leaf), ty::Ref(_, inner_ty, _)) => { p!(write("&")); - return self.pretty_print_const_scalar_int(leaf, *inner_ty, print_ty); + return self.pretty_print_const_scalar_int(leaf, inner_ty, print_ty); } (ty::ValTree::Leaf(leaf), _) => { return self.pretty_print_const_scalar_int(leaf, ty, print_ty); @@ -2536,7 +2536,7 @@ impl<'a, 'tcx> ty::TypeFolder> for RegionFolder<'a, 'tcx> { } fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { - match *t.kind() { + match t.kind() { _ if t.has_vars_bound_at_or_above(self.current_index) || t.has_placeholders() => { return t.super_fold_with(self); } diff --git a/compiler/rustc_middle/src/ty/relate.rs b/compiler/rustc_middle/src/ty/relate.rs index e24e64b23013a..51ba40e00bf58 100644 --- a/compiler/rustc_middle/src/ty/relate.rs +++ b/compiler/rustc_middle/src/ty/relate.rs @@ -427,7 +427,7 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>( ) -> RelateResult<'tcx, Ty<'tcx>> { let tcx = relation.tcx(); match (a.kind(), b.kind()) { - (&ty::Infer(_), _) | (_, &ty::Infer(_)) => { + (ty::Infer(_), _) | (_, ty::Infer(_)) => { // The caller should handle these cases! bug!("var types encountered in structurally_relate_tys") } @@ -436,15 +436,15 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>( bug!("bound types encountered in structurally_relate_tys") } - (&ty::Error(guar), _) | (_, &ty::Error(guar)) => Ok(Ty::new_error(tcx, guar)), + (ty::Error(guar), _) | (_, ty::Error(guar)) => Ok(Ty::new_error(tcx, guar)), - (&ty::Never, _) - | (&ty::Char, _) - | (&ty::Bool, _) - | (&ty::Int(_), _) - | (&ty::Uint(_), _) - | (&ty::Float(_), _) - | (&ty::Str, _) + (ty::Never, _) + | (ty::Char, _) + | (ty::Bool, _) + | (ty::Int(_), _) + | (ty::Uint(_), _) + | (ty::Float(_), _) + | (ty::Str, _) if a == b => { Ok(a) @@ -457,14 +457,14 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>( (ty::Placeholder(p1), ty::Placeholder(p2)) if p1 == p2 => Ok(a), - (&ty::Adt(a_def, a_args), &ty::Adt(b_def, b_args)) if a_def == b_def => { + (ty::Adt(a_def, a_args), ty::Adt(b_def, b_args)) if a_def == b_def => { let args = relation.relate_item_args(a_def.did(), a_args, b_args)?; Ok(Ty::new_adt(tcx, a_def, args)) } - (&ty::Foreign(a_id), &ty::Foreign(b_id)) if a_id == b_id => Ok(Ty::new_foreign(tcx, a_id)), + (ty::Foreign(a_id), ty::Foreign(b_id)) if a_id == b_id => Ok(Ty::new_foreign(tcx, a_id)), - (&ty::Dynamic(a_obj, a_region, a_repr), &ty::Dynamic(b_obj, b_region, b_repr)) + (ty::Dynamic(a_obj, a_region, a_repr), ty::Dynamic(b_obj, b_region, b_repr)) if a_repr == b_repr => { Ok(Ty::new_dynamic( @@ -475,7 +475,7 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>( )) } - (&ty::Coroutine(a_id, a_args), &ty::Coroutine(b_id, b_args)) if a_id == b_id => { + (ty::Coroutine(a_id, a_args), ty::Coroutine(b_id, b_args)) if a_id == b_id => { // All Coroutine types with the same id represent // the (anonymous) type of the same coroutine expression. So // all of their regions should be equated. @@ -483,7 +483,7 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>( Ok(Ty::new_coroutine(tcx, a_id, args)) } - (&ty::CoroutineWitness(a_id, a_args), &ty::CoroutineWitness(b_id, b_args)) + (ty::CoroutineWitness(a_id, a_args), ty::CoroutineWitness(b_id, b_args)) if a_id == b_id => { // All CoroutineWitness types with the same id represent @@ -493,7 +493,7 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>( Ok(Ty::new_coroutine_witness(tcx, a_id, args)) } - (&ty::Closure(a_id, a_args), &ty::Closure(b_id, b_args)) if a_id == b_id => { + (ty::Closure(a_id, a_args), ty::Closure(b_id, b_args)) if a_id == b_id => { // All Closure types with the same id represent // the (anonymous) type of the same closure expression. So // all of their regions should be equated. @@ -501,14 +501,14 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>( Ok(Ty::new_closure(tcx, a_id, args)) } - (&ty::CoroutineClosure(a_id, a_args), &ty::CoroutineClosure(b_id, b_args)) + (ty::CoroutineClosure(a_id, a_args), ty::CoroutineClosure(b_id, b_args)) if a_id == b_id => { let args = relate_args_invariantly(relation, a_args, b_args)?; Ok(Ty::new_coroutine_closure(tcx, a_id, args)) } - (&ty::RawPtr(a_ty, a_mutbl), &ty::RawPtr(b_ty, b_mutbl)) => { + (ty::RawPtr(a_ty, a_mutbl), ty::RawPtr(b_ty, b_mutbl)) => { if a_mutbl != b_mutbl { return Err(TypeError::Mutability); } @@ -525,7 +525,7 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>( Ok(Ty::new_ptr(tcx, ty, a_mutbl)) } - (&ty::Ref(a_r, a_ty, a_mutbl), &ty::Ref(b_r, b_ty, b_mutbl)) => { + (ty::Ref(a_r, a_ty, a_mutbl), ty::Ref(b_r, b_ty, b_mutbl)) => { if a_mutbl != b_mutbl { return Err(TypeError::Mutability); } @@ -543,7 +543,7 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>( Ok(Ty::new_ref(tcx, r, ty, a_mutbl)) } - (&ty::Array(a_t, sz_a), &ty::Array(b_t, sz_b)) => { + (ty::Array(a_t, sz_a), ty::Array(b_t, sz_b)) => { let t = relation.relate(a_t, b_t)?; match relation.relate(sz_a, sz_b) { Ok(sz) => Ok(Ty::new_array_with_const_len(tcx, t, sz)), @@ -563,12 +563,12 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>( } } - (&ty::Slice(a_t), &ty::Slice(b_t)) => { + (ty::Slice(a_t), ty::Slice(b_t)) => { let t = relation.relate(a_t, b_t)?; Ok(Ty::new_slice(tcx, t)) } - (&ty::Tuple(as_), &ty::Tuple(bs)) => { + (ty::Tuple(as_), ty::Tuple(bs)) => { if as_.len() == bs.len() { Ok(Ty::new_tup_from_iter( tcx, @@ -581,24 +581,24 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>( } } - (&ty::FnDef(a_def_id, a_args), &ty::FnDef(b_def_id, b_args)) if a_def_id == b_def_id => { + (ty::FnDef(a_def_id, a_args), ty::FnDef(b_def_id, b_args)) if a_def_id == b_def_id => { let args = relation.relate_item_args(a_def_id, a_args, b_args)?; Ok(Ty::new_fn_def(tcx, a_def_id, args)) } - (&ty::FnPtr(a_fty), &ty::FnPtr(b_fty)) => { + (ty::FnPtr(a_fty), ty::FnPtr(b_fty)) => { let fty = relation.relate(a_fty, b_fty)?; Ok(Ty::new_fn_ptr(tcx, fty)) } // Alias tend to mostly already be handled downstream due to normalization. - (&ty::Alias(a_kind, a_data), &ty::Alias(b_kind, b_data)) => { + (ty::Alias(a_kind, a_data), ty::Alias(b_kind, b_data)) => { let alias_ty = relation.relate(a_data, b_data)?; assert_eq!(a_kind, b_kind); Ok(Ty::new_alias(tcx, a_kind, alias_ty)) } - (&ty::Pat(a_ty, a_pat), &ty::Pat(b_ty, b_pat)) => { + (ty::Pat(a_ty, a_pat), ty::Pat(b_ty, b_pat)) => { let ty = relation.relate(a_ty, b_ty)?; let pat = relation.relate(a_pat, b_pat)?; Ok(Ty::new_pat(tcx, ty, pat)) diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index cf4854d13646a..da4af52076ba2 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -93,7 +93,7 @@ impl<'tcx> ty::DebugWithInfcx> for Ty<'tcx> { } impl<'tcx> fmt::Debug for Ty<'tcx> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - with_no_trimmed_paths!(fmt::Debug::fmt(self.kind(), f)) + with_no_trimmed_paths!(fmt::Debug::fmt(&self.kind(), f)) // njn: added `&` } } @@ -444,7 +444,7 @@ impl<'tcx> TypeSuperFoldable> for Ty<'tcx> { self, folder: &mut F, ) -> Result { - let kind = match *self.kind() { + let kind = match self.kind() { ty::RawPtr(ty, mutbl) => ty::RawPtr(ty.try_fold_with(folder)?, mutbl), ty::Array(typ, sz) => ty::Array(typ.try_fold_with(folder)?, sz.try_fold_with(folder)?), ty::Slice(typ) => ty::Slice(typ.try_fold_with(folder)?), @@ -486,7 +486,7 @@ impl<'tcx> TypeSuperFoldable> for Ty<'tcx> { | ty::Foreign(..) => return Ok(self), }; - Ok(if *self.kind() == kind { self } else { folder.interner().mk_ty_from_kind(kind) }) + Ok(if self.kind() == kind { self } else { folder.interner().mk_ty_from_kind(kind) }) } } diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index c83f6b0b9ec6d..136cb59564ee8 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -849,8 +849,9 @@ impl<'tcx> rustc_type_ir::inherent::Ty> for Ty<'tcx> { /// Type utilities impl<'tcx> Ty<'tcx> { #[inline(always)] - pub fn kind(self) -> &'tcx TyKind<'tcx> { - self.0.0 + // njn: removed `&'tcx` + pub fn kind(self) -> TyKind<'tcx> { + **self.0.0 // njn: added `**` } // FIXME(compiler-errors): Think about removing this. @@ -895,7 +896,7 @@ impl<'tcx> Ty<'tcx> { #[inline] pub fn ty_vid(self) -> Option { match self.kind() { - &Infer(TyVar(vid)) => Some(vid), + Infer(TyVar(vid)) => Some(vid), _ => None, } } @@ -912,13 +913,13 @@ impl<'tcx> Ty<'tcx> { #[inline] pub fn is_bool(self) -> bool { - *self.kind() == Bool + self.kind() == Bool } /// Returns `true` if this type is a `str`. #[inline] pub fn is_str(self) -> bool { - *self.kind() == Str + self.kind() == Str } #[inline] @@ -958,7 +959,7 @@ impl<'tcx> Ty<'tcx> { pub fn sequence_element_type(self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { match self.kind() { - Array(ty, _) | Slice(ty) => *ty, + Array(ty, _) | Slice(ty) => ty, Str => tcx.types.u8, _ => bug!("`sequence_element_type` called on non-sequence value: {}", self), } @@ -979,7 +980,7 @@ impl<'tcx> Ty<'tcx> { // The way we evaluate the `N` in `[T; N]` here only works since we use // `simd_size_and_type` post-monomorphization. It will probably start to ICE // if we use it in generic code. See the `simd-array-trait` ui test. - (f0_len.eval_target_usize(tcx, ParamEnv::empty()), *f0_elem_ty) + (f0_len.eval_target_usize(tcx, ParamEnv::empty()), f0_elem_ty) } // Otherwise, the fields of this Adt are the SIMD components (and we assume they // all have the same type). @@ -999,7 +1000,7 @@ impl<'tcx> Ty<'tcx> { #[inline] pub fn ref_mutability(self) -> Option { match self.kind() { - Ref(_, _, mutability) => Some(*mutability), + Ref(_, _, mutability) => Some(mutability), _ => None, } } @@ -1193,7 +1194,7 @@ impl<'tcx> Ty<'tcx> { /// The parameter `explicit` indicates if this is an *explicit* dereference. /// Some types -- notably unsafe ptrs -- can only be dereferenced explicitly. pub fn builtin_deref(self, explicit: bool) -> Option> { - match *self.kind() { + match self.kind() { Adt(def, _) if def.is_box() => Some(self.boxed_ty()), Ref(_, ty, _) => Some(ty), RawPtr(ty, _) if explicit => Some(ty), @@ -1204,15 +1205,15 @@ impl<'tcx> Ty<'tcx> { /// Returns the type of `ty[i]`. pub fn builtin_index(self) -> Option> { match self.kind() { - Array(ty, _) | Slice(ty) => Some(*ty), + Array(ty, _) | Slice(ty) => Some(ty), _ => None, } } pub fn fn_sig(self, tcx: TyCtxt<'tcx>) -> PolyFnSig<'tcx> { match self.kind() { - FnDef(def_id, args) => tcx.fn_sig(*def_id).instantiate(tcx, args), - FnPtr(f) => *f, + FnDef(def_id, args) => tcx.fn_sig(def_id).instantiate(tcx, args), + FnPtr(f) => f, Error(_) => { // ignore errors (#54954) Binder::dummy(ty::FnSig { @@ -1247,7 +1248,7 @@ impl<'tcx> Ty<'tcx> { #[inline] pub fn ty_adt_def(self) -> Option> { match self.kind() { - Adt(adt, _) => Some(*adt), + Adt(adt, _) => Some(adt), _ => None, } } @@ -1269,9 +1270,7 @@ impl<'tcx> Ty<'tcx> { pub fn variant_range(self, tcx: TyCtxt<'tcx>) -> Option> { match self.kind() { TyKind::Adt(adt, _) => Some(adt.variant_range()), - TyKind::Coroutine(def_id, args) => { - Some(args.as_coroutine().variant_range(*def_id, tcx)) - } + TyKind::Coroutine(def_id, args) => Some(args.as_coroutine().variant_range(def_id, tcx)), _ => None, } } @@ -1291,7 +1290,7 @@ impl<'tcx> Ty<'tcx> { Some(adt.discriminant_for_variant(tcx, variant_index)) } TyKind::Coroutine(def_id, args) => { - Some(args.as_coroutine().discriminant_for_variant(*def_id, tcx, variant_index)) + Some(args.as_coroutine().discriminant_for_variant(def_id, tcx, variant_index)) } _ => None, } @@ -1360,7 +1359,7 @@ impl<'tcx> Ty<'tcx> { AsyncDropGlueMorphology::Custom => (), } - match *self.kind() { + match self.kind() { ty::Param(_) | ty::Alias(..) | ty::Infer(ty::TyVar(_)) => { let assoc_items = tcx .associated_item_def_ids(tcx.require_lang_item(LangItem::AsyncDestruct, None)); diff --git a/compiler/rustc_middle/src/ty/typeck_results.rs b/compiler/rustc_middle/src/ty/typeck_results.rs index 69ea9c9843a08..97c20fb7d7bc0 100644 --- a/compiler/rustc_middle/src/ty/typeck_results.rs +++ b/compiler/rustc_middle/src/ty/typeck_results.rs @@ -754,7 +754,7 @@ impl<'tcx> IsIdentity for CanonicalUserType<'tcx> { GenericArgKind::Type(ty) => match ty.kind() { ty::Bound(debruijn, b) => { // We only allow a `ty::INNERMOST` index in generic parameters. - assert_eq!(*debruijn, ty::INNERMOST); + assert_eq!(debruijn, ty::INNERMOST); cvar == b.var } _ => false, diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index 52a0e72e17e28..b7009a90fa824 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -55,7 +55,7 @@ pub enum NotUniqueParam<'tcx> { impl<'tcx> fmt::Display for Discr<'tcx> { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { - match *self.ty.kind() { + match self.ty.kind() { ty::Int(ity) => { let size = ty::tls::with(|tcx| Integer::from_int_ty(&tcx, ity).size()); let x = self.val; @@ -225,7 +225,7 @@ impl<'tcx> TyCtxt<'tcx> { .emit_err(crate::error::RecursionLimitReached { ty, suggested_limit }); return Ty::new_error(self, reported); } - match *ty.kind() { + match ty.kind() { ty::Adt(def, args) => { if !def.is_struct() { break; @@ -480,7 +480,7 @@ impl<'tcx> TyCtxt<'tcx> { // , and then look up which of the impl args refer to // parameters marked as pure. - let impl_args = match *self.type_of(impl_def_id).instantiate_identity().kind() { + let impl_args = match self.type_of(impl_def_id).instantiate_identity().kind() { ty::Adt(def_, args) if def_ == def => args, _ => span_bug!(self.def_span(impl_def_id), "expected ADT for self type of `Drop` impl"), }; @@ -497,7 +497,7 @@ impl<'tcx> TyCtxt<'tcx> { // Error: not a region param _ => false, }, - GenericArgKind::Type(ty) => match *ty.kind() { + GenericArgKind::Type(ty) => match ty.kind() { ty::Param(pt) => !impl_generics.type_param(pt, self).pure_wrt_drop, // Error: not a type param _ => false, @@ -1124,7 +1124,7 @@ impl<'tcx> TypeFolder> for OpaqueTypeExpander<'tcx> { } fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { - let mut t = if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) = *t.kind() { + let mut t = if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) = t.kind() { self.expand_opaque_ty(def_id, args).unwrap_or(t) } else if t.has_opaque_types() || t.has_coroutines() { t.super_fold_with(self) @@ -1132,7 +1132,7 @@ impl<'tcx> TypeFolder> for OpaqueTypeExpander<'tcx> { t }; if self.expand_coroutines { - if let ty::CoroutineWitness(def_id, args) = *t.kind() { + if let ty::CoroutineWitness(def_id, args) = t.kind() { t = self.expand_coroutine(def_id, args).unwrap_or(t); } } @@ -1211,7 +1211,7 @@ pub enum AsyncDropGlueMorphology { impl<'tcx> Ty<'tcx> { /// Returns the `Size` for primitive types (bool, uint, int, char, float). pub fn primitive_size(self, tcx: TyCtxt<'tcx>) -> Size { - match *self.kind() { + match self.kind() { ty::Bool => Size::from_bytes(1), ty::Char => Size::from_bytes(4), ty::Int(ity) => Integer::from_int_ty(&tcx, ity).size(), @@ -1222,7 +1222,7 @@ impl<'tcx> Ty<'tcx> { } pub fn int_size_and_signed(self, tcx: TyCtxt<'tcx>) -> (Size, bool) { - match *self.kind() { + match self.kind() { ty::Int(ity) => (Integer::from_int_ty(&tcx, ity).size(), true), ty::Uint(uty) => (Integer::from_uint_ty(&tcx, uty).size(), false), _ => bug!("non integer discriminant"), @@ -1425,7 +1425,7 @@ impl<'tcx> Ty<'tcx> { ty::Closure(did, _) | ty::CoroutineClosure(did, _) | ty::Coroutine(did, _) - | ty::CoroutineWitness(did, _) => tcx.async_drop_glue_morphology(*did), + | ty::CoroutineWitness(did, _) => tcx.async_drop_glue_morphology(did), ty::Alias(..) | ty::Param(_) | ty::Bound(..) | ty::Placeholder(..) | ty::Infer(_) => { // No specifics, but would usually mean forwarding async drop glue @@ -1616,7 +1616,7 @@ impl<'tcx> Ty<'tcx> { pub fn peel_refs(self) -> Ty<'tcx> { let mut ty = self; while let ty::Ref(_, inner_ty, _) = ty.kind() { - ty = *inner_ty; + ty = inner_ty; } ty } @@ -1667,7 +1667,7 @@ impl<'tcx> ExplicitSelf<'tcx> { { use self::ExplicitSelf::*; - match *self_arg_ty.kind() { + match self_arg_ty.kind() { _ if is_self_ty(self_arg_ty) => ByValue, ty::Ref(region, ty, mutbl) if is_self_ty(ty) => ByReference(region, mutbl), ty::RawPtr(ty, mutbl) if is_self_ty(ty) => ByRawPointer(mutbl), @@ -1699,7 +1699,7 @@ pub fn needs_drop_components_with_async<'tcx>( ty: Ty<'tcx>, asyncness: Asyncness, ) -> Result; 2]>, AlwaysRequiresDrop> { - match *ty.kind() { + match ty.kind() { ty::Infer(ty::FreshIntTy(_)) | ty::Infer(ty::FreshFloatTy(_)) | ty::Bool @@ -1763,7 +1763,7 @@ pub fn needs_drop_components_with_async<'tcx>( } pub fn is_trivially_const_drop(ty: Ty<'_>) -> bool { - match *ty.kind() { + match ty.kind() { ty::Bool | ty::Char | ty::Int(_) diff --git a/compiler/rustc_middle/src/ty/walk.rs b/compiler/rustc_middle/src/ty/walk.rs index e0f204a687f6e..b0bbb22918d60 100644 --- a/compiler/rustc_middle/src/ty/walk.rs +++ b/compiler/rustc_middle/src/ty/walk.rs @@ -137,7 +137,7 @@ impl<'tcx> ty::Const<'tcx> { /// types as they are written). fn push_inner<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent: GenericArg<'tcx>) { match parent.unpack() { - GenericArgKind::Type(parent_ty) => match *parent_ty.kind() { + GenericArgKind::Type(parent_ty) => match parent_ty.kind() { ty::Bool | ty::Char | ty::Int(_) diff --git a/compiler/rustc_middle/src/util/find_self_call.rs b/compiler/rustc_middle/src/util/find_self_call.rs index 027e2703e98d6..9e195248a699a 100644 --- a/compiler/rustc_middle/src/util/find_self_call.rs +++ b/compiler/rustc_middle/src/util/find_self_call.rs @@ -20,7 +20,7 @@ pub fn find_self_call<'tcx>( { debug!("find_self_call: func={:?}", func); if let Operand::Constant(box ConstOperand { const_, .. }) = func { - if let ty::FnDef(def_id, fn_args) = *const_.ty().kind() { + if let ty::FnDef(def_id, fn_args) = const_.ty().kind() { if let Some(ty::AssocItem { fn_has_self_parameter: true, .. }) = tcx.opt_associated_item(def_id) { diff --git a/compiler/rustc_mir_build/src/build/custom/parse.rs b/compiler/rustc_mir_build/src/build/custom/parse.rs index 9607022c6df04..f52b716734ea9 100644 --- a/compiler/rustc_mir_build/src/build/custom/parse.rs +++ b/compiler/rustc_mir_build/src/build/custom/parse.rs @@ -45,7 +45,7 @@ macro_rules! parse_by_kind { ExprKind::Call { ty, fun: _, args: $args, .. } if { match ty.kind() { ty::FnDef(did, _) => { - $self.tcx.is_diagnostic_item(rustc_span::sym::$name, *did) + $self.tcx.is_diagnostic_item(rustc_span::sym::$name, did) } _ => false, } 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 4b62afa61bbd5..2d4ffe4f8732e 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_place.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_place.rs @@ -436,7 +436,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { unpack!(block = this.expr_as_place(block, lhs, mutability, fake_borrow_temps,)); if let ty::Adt(adt_def, _) = lhs_expr.ty.kind() { if adt_def.is_enum() { - place_builder = place_builder.downcast(*adt_def, variant_index); + place_builder = place_builder.downcast(adt_def, variant_index); } } block.and(place_builder.field(name, expr.ty)) diff --git a/compiler/rustc_mir_build/src/build/matches/test.rs b/compiler/rustc_mir_build/src/build/matches/test.rs index 2040071e76eb2..2bcf83989fee0 100644 --- a/compiler/rustc_mir_build/src/build/matches/test.rs +++ b/compiler/rustc_mir_build/src/build/matches/test.rs @@ -400,7 +400,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { (Some((region, elem_ty, _)), _) | (None, Some((region, elem_ty, _))) => { let tcx = self.tcx; // make both a slice - ty = Ty::new_imm_ref(tcx, *region, Ty::new_slice(tcx, *elem_ty)); + ty = Ty::new_imm_ref(tcx, region, Ty::new_slice(tcx, elem_ty)); if opt_ref_ty.is_some() { let temp = self.temp(ty, source_info.span); self.cfg.push_assign( @@ -432,7 +432,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - match *ty.kind() { + match ty.kind() { ty::Ref(_, deref_ty, _) => ty = deref_ty, _ => { // non_scalar_compare called on non-reference type diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs index 14d1b502474fd..5defd2b7a25cb 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/build/mod.rs @@ -665,7 +665,7 @@ fn construct_error(tcx: TyCtxt<'_>, def_id: LocalDefId, guar: ErrorGuaranteed) - tcx, args.parent_args(), args.kind_ty(), - tcx.coroutine_for_closure(*did), + tcx.coroutine_for_closure(did), Ty::new_error(tcx, guar), ), None, @@ -811,7 +811,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let mut closure_env_projs = vec![]; if let ty::Ref(_, ty, _) = closure_ty.kind() { closure_env_projs.push(ProjectionElem::Deref); - closure_ty = *ty; + closure_ty = ty; } let upvar_args = match closure_ty.kind() { diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs index 9a19445e3779b..bc2231ac838b7 100644 --- a/compiler/rustc_mir_build/src/check_unsafety.rs +++ b/compiler/rustc_mir_build/src/check_unsafety.rs @@ -426,12 +426,12 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> { ExprKind::Call { fun, ty: _, args: _, from_hir_call: _, fn_span: _ } => { if self.thir[fun].ty.fn_sig(self.tcx).safety() == hir::Safety::Unsafe { let func_id = if let ty::FnDef(func_id, _) = self.thir[fun].ty.kind() { - Some(*func_id) + Some(func_id) } else { None }; self.requires_unsafe(expr.span, CallToUnsafeFunction(func_id)); - } else if let &ty::FnDef(func_did, _) = self.thir[fun].ty.kind() { + } else if let ty::FnDef(func_did, _) = self.thir[fun].ty.kind() { // If the called function has target features the calling function hasn't, // the call requires `unsafe`. Don't check this on wasm // targets, though. For more information on wasm see the diff --git a/compiler/rustc_mir_build/src/lints.rs b/compiler/rustc_mir_build/src/lints.rs index 2c817d605af2a..3a653605d53eb 100644 --- a/compiler/rustc_mir_build/src/lints.rs +++ b/compiler/rustc_mir_build/src/lints.rs @@ -81,7 +81,7 @@ pub fn check_drop_recursion<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) { if let ty::Ref(_, dropped_ty, _) = tcx.liberate_late_bound_regions(def_id.to_def_id(), sig.input(0)).kind() { - check_recursion(tcx, body, RecursiveDrop { drop_for: *dropped_ty }); + check_recursion(tcx, body, RecursiveDrop { drop_for: dropped_ty }); } } } @@ -136,7 +136,7 @@ impl<'tcx> TerminatorClassifier<'tcx> for CallRecursion<'tcx> { let param_env = tcx.param_env(caller); let func_ty = func.ty(body, tcx); - if let ty::FnDef(callee, args) = *func_ty.kind() { + if let ty::FnDef(callee, args) = func_ty.kind() { let Ok(normalized_args) = tcx.try_normalize_erasing_regions(param_env, args) else { return false; }; diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index bd66257e6b687..47230c2915d9b 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -503,7 +503,7 @@ impl<'tcx> Cx<'tcx> { let user_ty = user_provided_types.get(expr.hir_id).copied().map(Box::new); debug!("make_mirror_unadjusted: (struct/union) user_ty={:?}", user_ty); ExprKind::Adt(Box::new(AdtExpr { - adt_def: *adt, + adt_def: adt, variant_index: FIRST_VARIANT, args, user_ty, @@ -530,7 +530,7 @@ impl<'tcx> Cx<'tcx> { user_provided_types.get(expr.hir_id).copied().map(Box::new); debug!("make_mirror_unadjusted: (variant) user_ty={:?}", user_ty); ExprKind::Adt(Box::new(AdtExpr { - adt_def: *adt, + adt_def: adt, variant_index: index, args, user_ty, @@ -551,7 +551,7 @@ impl<'tcx> Cx<'tcx> { hir::ExprKind::Closure { .. } => { let closure_ty = self.typeck_results().expr_ty(expr); - let (def_id, args, movability) = match *closure_ty.kind() { + let (def_id, args, movability) = match closure_ty.kind() { ty::Closure(def_id, args) => (def_id, UpvarArgs::Closure(args), None), ty::Coroutine(def_id, args) => { (def_id, UpvarArgs::Coroutine(args), Some(tcx.coroutine_movability(def_id))) @@ -688,7 +688,7 @@ impl<'tcx> Cx<'tcx> { span_bug!(expr.span, "unexpected repeat expr ty: {:?}", ty); }; - ExprKind::Repeat { value: self.mirror_expr(v), count: *count } + ExprKind::Repeat { value: self.mirror_expr(v), count } } hir::ExprKind::Ret(v) => ExprKind::Return { value: v.map(|v| self.mirror_expr(v)) }, hir::ExprKind::Become(call) => ExprKind::Become { value: self.mirror_expr(call) }, @@ -928,7 +928,7 @@ impl<'tcx> Cx<'tcx> { // A unit struct/variant which is used as a value. // We return a completely different ExprKind here to account for this special case. ty::Adt(adt_def, args) => ExprKind::Adt(Box::new(AdtExpr { - adt_def: *adt_def, + adt_def, variant_index: adt_def.variant_index_with_ctor_id(def_id), args, user_ty, @@ -1017,7 +1017,7 @@ impl<'tcx> Cx<'tcx> { // Reconstruct the output assuming it's a reference with the // same region and mutability as the receiver. This holds for // `Deref(Mut)::Deref(_mut)` and `Index(Mut)::index(_mut)`. - let ty::Ref(region, _, mutbl) = *self.thir[args[0]].ty.kind() else { + let ty::Ref(region, _, mutbl) = self.thir[args[0]].ty.kind() else { span_bug!(span, "overloaded_place: receiver is not a reference"); }; let ref_ty = Ty::new_ref(self.tcx, region, place_ty, mutbl); diff --git a/compiler/rustc_mir_build/src/thir/cx/mod.rs b/compiler/rustc_mir_build/src/thir/cx/mod.rs index bd9e34ae80fc4..3357b7a09bbaf 100644 --- a/compiler/rustc_mir_build/src/thir/cx/mod.rs +++ b/compiler/rustc_mir_build/src/thir/cx/mod.rs @@ -125,7 +125,7 @@ impl<'tcx> Cx<'tcx> { } let closure_ty = self.typeck_results.node_type(expr_id); - Some(match *closure_ty.kind() { + Some(match closure_ty.kind() { ty::Coroutine(..) => { Param { ty: closure_ty, pat: None, ty_span: None, self_kind: None, hir_id: None } } 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 30f57c8c622f7..3c081308e9206 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -697,7 +697,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> { && let Constructor::Variant(variant_index) = witness_1.ctor() { let variant = adt.variant(*variant_index); - let inhabited = variant.inhabited_predicate(self.tcx, *adt).instantiate(self.tcx, args); + let inhabited = variant.inhabited_predicate(self.tcx, adt).instantiate(self.tcx, args); assert!(inhabited.apply(self.tcx, cx.param_env, cx.module)); !inhabited.apply_ignore_module(self.tcx, cx.param_env) } else { @@ -1205,7 +1205,7 @@ fn report_adt_defined_here<'tcx>( }; let mut variants = vec![]; - for span in maybe_point_at_variant(tcx, *def, witnesses.iter().take(5)) { + for span in maybe_point_at_variant(tcx, def, witnesses.iter().take(5)) { variants.push(Variant { span }); } Some(AdtDefinedHere { adt_def_span, ty, variants }) diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs index 36495101d3f48..d7ded34c28abe 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs @@ -285,7 +285,7 @@ impl<'tcx> ConstToPat<'tcx> { let variant_index = VariantIdx::from_u32(variant_index.unwrap_leaf().try_to_u32().ok().unwrap()); PatKind::Variant { - adt_def: *adt_def, + adt_def, args, variant_index, subpatterns: self.field_pats( @@ -319,7 +319,7 @@ impl<'tcx> ConstToPat<'tcx> { prefix: cv .unwrap_branch() .iter() - .map(|val| self.recur(*val, *elem_ty)) + .map(|val| self.recur(*val, elem_ty)) .collect::>()?, slice: None, suffix: Box::new([]), @@ -328,12 +328,12 @@ impl<'tcx> ConstToPat<'tcx> { prefix: cv .unwrap_branch() .iter() - .map(|val| self.recur(*val, *elem_ty)) + .map(|val| self.recur(*val, elem_ty)) .collect::>()?, slice: None, suffix: Box::new([]), }, - ty::Ref(_, pointee_ty, ..) => match *pointee_ty.kind() { + ty::Ref(_, pointee_ty, ..) => match pointee_ty.kind() { // `&str` is represented as a valtree, let's keep using this // optimization for now. ty::Str => PatKind::Constant { @@ -344,7 +344,7 @@ impl<'tcx> ConstToPat<'tcx> { // deref pattern. _ => { if !pointee_ty.is_sized(tcx, param_env) && !pointee_ty.is_slice() { - let err = UnsizedPattern { span, non_sm_ty: *pointee_ty }; + let err = UnsizedPattern { span, non_sm_ty: pointee_ty }; let e = tcx.dcx().emit_err(err); // We errored. Signal that in the pattern, so that follow up errors can be silenced. PatKind::Error(e) @@ -355,11 +355,11 @@ impl<'tcx> ConstToPat<'tcx> { // as slices. This means we turn `&[T; N]` constants into slice patterns, which // has no negative effects on pattern matching, even if we're actually matching on // arrays. - let pointee_ty = match *pointee_ty.kind() { + let pointee_ty = match pointee_ty.kind() { ty::Array(elem_ty, _) if self.treat_byte_string_as_slice => { Ty::new_slice(tcx, elem_ty) } - _ => *pointee_ty, + _ => pointee_ty, }; // References have the same valtree representation as their pointee. let subpattern = self.recur(cv, pointee_ty)?; diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs index 145a40ca3cd6a..cddf8e9606326 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs @@ -113,7 +113,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { let suggestion_str: String = adjustments .iter() .map(|ref_ty| { - let &ty::Ref(_, _, mutbl) = ref_ty.kind() else { + let ty::Ref(_, _, mutbl) = ref_ty.kind() else { span_bug!(pat.span, "pattern implicitly dereferences a non-ref type"); }; @@ -195,11 +195,11 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { }; let (min, max): (i128, u128) = match ty.kind() { ty::Int(ity) => { - let size = Integer::from_int_ty(&self.tcx, *ity).size(); + let size = Integer::from_int_ty(&self.tcx, ity).size(); (size.signed_int_min(), size.signed_int_max() as u128) } ty::Uint(uty) => { - let size = Integer::from_uint_ty(&self.tcx, *uty).size(); + let size = Integer::from_uint_ty(&self.tcx, uty).size(); (0, size.unsigned_int_max()) } _ => { @@ -357,7 +357,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { let var_ty = ty; if let hir::ByRef::Yes(_) = mode.0 { if let ty::Ref(_, rty, _) = ty.kind() { - ty = *rty; + ty = rty; } else { bug!("`ref {}` has wrong type {}", ident, ty); } @@ -476,7 +476,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { ty::Adt(_, args) | ty::FnDef(_, args) => args, ty::Error(e) => { // Avoid ICE (#50585) - return PatKind::Error(*e); + return PatKind::Error(e); } _ => bug!("inappropriate type for def: {:?}", ty), }; diff --git a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs index bdc59e843563b..8812eca1bb91f 100644 --- a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs +++ b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs @@ -869,13 +869,13 @@ where // See librustc_body/transform/coroutine.rs for more details. 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::Adt(def, args) => self.open_drop_for_adt(def, args), ty::Dynamic(..) => self.complete_drop(self.succ, self.unwind), ty::Array(ety, size) => { let size = size.try_eval_target_usize(self.tcx(), self.elaborator.param_env()); - self.open_drop_for_array(*ety, size) + self.open_drop_for_array(ety, size) } - ty::Slice(ety) => self.drop_loop_pair(*ety), + ty::Slice(ety) => self.drop_loop_pair(ety), _ => span_bug!(self.source_info.span, "open drop from non-ADT `{:?}`", ty), } diff --git a/compiler/rustc_mir_dataflow/src/impls/initialized.rs b/compiler/rustc_mir_dataflow/src/impls/initialized.rs index f0b79dab0c974..bb44e47ac05aa 100644 --- a/compiler/rustc_mir_dataflow/src/impls/initialized.rs +++ b/compiler/rustc_mir_dataflow/src/impls/initialized.rs @@ -760,7 +760,7 @@ fn switch_on_enum_discriminant<'mir, 'tcx>( if *lhs == switch_on => { match discriminated.ty(body, tcx).ty.kind() { - ty::Adt(def, _) => return Some((*discriminated, *def)), + ty::Adt(def, _) => return Some((*discriminated, def)), // `Rvalue::Discriminant` is also used to get the active yield point for a // coroutine, but we do not need edge-specific effects in that case. This may diff --git a/compiler/rustc_mir_dataflow/src/rustc_peek.rs b/compiler/rustc_mir_dataflow/src/rustc_peek.rs index 1de9055273b73..3a94eca89b6dc 100644 --- a/compiler/rustc_mir_dataflow/src/rustc_peek.rs +++ b/compiler/rustc_mir_dataflow/src/rustc_peek.rs @@ -202,7 +202,7 @@ impl PeekCall { if let mir::TerminatorKind::Call { func: Operand::Constant(func), args, .. } = &terminator.kind { - if let ty::FnDef(def_id, fn_args) = *func.const_.ty().kind() { + if let ty::FnDef(def_id, fn_args) = func.const_.ty().kind() { if tcx.intrinsic(def_id)?.name != sym::rustc_peek { return None; } diff --git a/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs b/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs index d43fca3dc7efe..b2af140a0f715 100644 --- a/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs +++ b/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs @@ -66,7 +66,7 @@ impl<'tcx> MirPass<'tcx> for AbortUnwindingCalls { let sig = ty.fn_sig(tcx); let fn_def_id = match ty.kind() { ty::FnPtr(_) => None, - &ty::FnDef(def_id, _) => Some(def_id), + ty::FnDef(def_id, _) => Some(def_id), _ => span_bug!(span, "invalid callee of type {:?}", ty), }; layout::fn_can_unwind(tcx, fn_def_id, sig.abi()) diff --git a/compiler/rustc_mir_transform/src/add_retag.rs b/compiler/rustc_mir_transform/src/add_retag.rs index f880476cec2f2..eb16d5f369311 100644 --- a/compiler/rustc_mir_transform/src/add_retag.rs +++ b/compiler/rustc_mir_transform/src/add_retag.rs @@ -31,7 +31,7 @@ fn may_contain_reference<'tcx>(ty: Ty<'tcx>, depth: u32, tcx: TyCtxt<'tcx>) -> b // Compound types: recurse ty::Array(ty, _) | ty::Slice(ty) => { // This does not branch so we keep the depth the same. - may_contain_reference(*ty, depth, tcx) + may_contain_reference(ty, depth, tcx) } ty::Tuple(tys) => { depth == 0 || tys.iter().any(|ty| may_contain_reference(ty, depth - 1, tcx)) diff --git a/compiler/rustc_mir_transform/src/check_alignment.rs b/compiler/rustc_mir_transform/src/check_alignment.rs index 5199c41c58cd4..8e286d884d3cc 100644 --- a/compiler/rustc_mir_transform/src/check_alignment.rs +++ b/compiler/rustc_mir_transform/src/check_alignment.rs @@ -116,7 +116,7 @@ impl<'tcx, 'a> Visitor<'tcx> for PointerFinder<'tcx, 'a> { // Try to detect types we are sure have an alignment of 1 and skip the check // We don't need to look for str and slices, we already rejected unsized types above let element_ty = match pointee_ty.kind() { - ty::Array(ty, _) => *ty, + ty::Array(ty, _) => ty, _ => pointee_ty, }; if [self.tcx.types.bool, self.tcx.types.i8, self.tcx.types.u8].contains(&element_ty) { diff --git a/compiler/rustc_mir_transform/src/coroutine.rs b/compiler/rustc_mir_transform/src/coroutine.rs index 84512e81637e5..a0f41e82fac9d 100644 --- a/compiler/rustc_mir_transform/src/coroutine.rs +++ b/compiler/rustc_mir_transform/src/coroutine.rs @@ -282,8 +282,8 @@ impl<'tcx> TransformVisitor<'tcx> { } // `async gen` continues to return `Poll::Ready(None)` CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _) => { - let ty::Adt(_poll_adt, args) = *self.old_yield_ty.kind() else { bug!() }; - let ty::Adt(_option_adt, args) = *args.type_at(0).kind() else { bug!() }; + let ty::Adt(_poll_adt, args) = self.old_yield_ty.kind() else { bug!() }; + let ty::Adt(_option_adt, args) = args.type_at(0).kind() else { bug!() }; let yield_ty = args.type_at(0); Rvalue::Use(Operand::Constant(Box::new(ConstOperand { span: source_info.span, @@ -386,8 +386,8 @@ impl<'tcx> TransformVisitor<'tcx> { } CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _) => { if is_return { - let ty::Adt(_poll_adt, args) = *self.old_yield_ty.kind() else { bug!() }; - let ty::Adt(_option_adt, args) = *args.type_at(0).kind() else { bug!() }; + let ty::Adt(_poll_adt, args) = self.old_yield_ty.kind() else { bug!() }; + let ty::Adt(_option_adt, args) = args.type_at(0).kind() else { bug!() }; let yield_ty = args.type_at(0); Rvalue::Use(Operand::Constant(Box::new(ConstOperand { span: source_info.span, @@ -658,7 +658,7 @@ fn transform_async_context<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { match &bb_data.terminator().kind { TerminatorKind::Call { func, .. } => { let func_ty = func.ty(body, tcx); - if let ty::FnDef(def_id, _) = *func_ty.kind() { + if let ty::FnDef(def_id, _) = func_ty.kind() { if def_id == get_context_def_id { let local = eliminate_get_context_call(&mut body[bb]); replace_resume_ty_local(tcx, body, local, context_mut_ref); @@ -711,7 +711,7 @@ fn replace_resume_ty_local<'tcx>( { if let ty::Adt(resume_ty_adt, _) = local_ty.kind() { let expected_adt = tcx.adt_def(tcx.require_lang_item(LangItem::ResumeTy, None)); - assert_eq!(*resume_ty_adt, expected_adt); + assert_eq!(resume_ty_adt, expected_adt); } else { panic!("expected `ResumeTy`, found `{:?}`", local_ty); }; @@ -1572,7 +1572,7 @@ pub(crate) fn mir_coroutine_witnesses<'tcx>( // The first argument is the coroutine type passed by value let coroutine_ty = body.local_decls[ty::CAPTURE_STRUCT_LOCAL].ty; - let movable = match *coroutine_ty.kind() { + let movable = match coroutine_ty.kind() { ty::Coroutine(def_id, _) => tcx.coroutine_movability(def_id) == hir::Movability::Movable, ty::Error(_) => return None, _ => span_bug!(body.span, "unexpected coroutine type {}", coroutine_ty), @@ -1644,7 +1644,7 @@ impl<'tcx> MirPass<'tcx> for StateTransform { let coroutine_kind = body.coroutine_kind().unwrap(); // Get the discriminant type and args which typeck computed - let (discr_ty, movable) = match *coroutine_ty.kind() { + let (discr_ty, movable) = match coroutine_ty.kind() { ty::Coroutine(_, args) => { let args = args.as_coroutine(); (args.discr_ty(tcx), coroutine_kind.movability() == hir::Movability::Movable) @@ -1998,7 +1998,7 @@ fn check_must_not_suspend_ty<'tcx>( debug!("Checking must_not_suspend for {}", ty); - match *ty.kind() { + match ty.kind() { ty::Adt(_, args) if ty.is_box() => { let boxed_ty = args.type_at(0); let allocator_ty = args.type_at(1); diff --git a/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs b/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs index 10c0567eb4b7b..bf7eac0848fd8 100644 --- a/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs +++ b/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs @@ -106,14 +106,14 @@ impl<'tcx> MirPass<'tcx> for ByMoveBody { return; } - let ty::Coroutine(_, args) = *coroutine_ty.kind() else { bug!("{body:#?}") }; + let ty::Coroutine(_, args) = coroutine_ty.kind() else { bug!("{body:#?}") }; let args = args.as_coroutine(); let coroutine_kind = args.kind_ty().to_opt_closure_kind().unwrap(); let parent_def_id = tcx.local_parent(coroutine_def_id); let ty::CoroutineClosure(_, parent_args) = - *tcx.type_of(parent_def_id).instantiate_identity().kind() + tcx.type_of(parent_def_id).instantiate_identity().kind() else { bug!(); }; diff --git a/compiler/rustc_mir_transform/src/cost_checker.rs b/compiler/rustc_mir_transform/src/cost_checker.rs index 2c692c9500303..92e4541526e6e 100644 --- a/compiler/rustc_mir_transform/src/cost_checker.rs +++ b/compiler/rustc_mir_transform/src/cost_checker.rs @@ -69,7 +69,7 @@ impl<'tcx> Visitor<'tcx> for CostChecker<'_, 'tcx> { } TerminatorKind::Call { func: Operand::Constant(ref f), unwind, .. } => { let fn_ty = self.instantiate_ty(f.const_.ty()); - self.cost += if let ty::FnDef(def_id, _) = *fn_ty.kind() + self.cost += if let ty::FnDef(def_id, _) = fn_ty.kind() && tcx.intrinsic(def_id).is_some() { // Don't give intrinsics the extra penalty for calls diff --git a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs index a8caead46f2f9..e827a860c3456 100644 --- a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs +++ b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs @@ -203,7 +203,7 @@ impl<'tcx> ValueAnalysis<'tcx> for ConstAnalysis<'_, 'tcx> { && let operand_ty = operand.ty(self.local_decls, self.tcx) && let Some(operand_ty) = operand_ty.builtin_deref(true) && let ty::Array(_, len) = operand_ty.kind() - && let Some(len) = Const::Ty(self.tcx.types.usize, *len) + && let Some(len) = Const::Ty(self.tcx.types.usize, len) .try_eval_scalar_int(self.tcx, self.param_env) { state.insert_value_idx(target_len, FlatSet::Elem(len.into()), self.map()); @@ -222,7 +222,7 @@ impl<'tcx> ValueAnalysis<'tcx> for ConstAnalysis<'_, 'tcx> { Rvalue::Len(place) => { let place_ty = place.ty(self.local_decls, self.tcx); if let ty::Array(_, len) = place_ty.ty.kind() { - Const::Ty(self.tcx.types.usize, *len) + Const::Ty(self.tcx.types.usize, len) .try_eval_scalar(self.tcx, self.param_env) .map_or(FlatSet::Top, FlatSet::Elem) } else if let [ProjectionElem::Deref] = place.projection[..] { diff --git a/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs b/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs index 5e3cd85367508..16af6d7abf757 100644 --- a/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs +++ b/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs @@ -92,7 +92,7 @@ fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool { let fn_def_id = match ty.kind() { ty::FnPtr(_) => None, - &ty::FnDef(def_id, _) => { + ty::FnDef(def_id, _) => { // Rust calls cannot themselves create foreign unwinds (even if they use a non-Rust ABI). // So the leak of the foreign unwind into Rust can only be elsewhere, not here. if !tcx.is_foreign_item(def_id) { diff --git a/compiler/rustc_mir_transform/src/function_item_references.rs b/compiler/rustc_mir_transform/src/function_item_references.rs index 434529ccff4bc..59f38b5064992 100644 --- a/compiler/rustc_mir_transform/src/function_item_references.rs +++ b/compiler/rustc_mir_transform/src/function_item_references.rs @@ -41,7 +41,7 @@ impl<'tcx> Visitor<'tcx> for FunctionItemRefChecker<'_, 'tcx> { { let source_info = *self.body.source_info(location); let func_ty = func.ty(self.body, self.tcx); - if let ty::FnDef(def_id, args_ref) = *func_ty.kind() { + if let ty::FnDef(def_id, args_ref) = func_ty.kind() { // Handle calls to `transmute` if self.tcx.is_diagnostic_item(sym::transmute, def_id) { let arg_ty = args[0].node.ty(self.body, self.tcx); @@ -126,7 +126,7 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> { }; referent_ty .map(|ref_ty| { - if let ty::FnDef(def_id, args_ref) = *ref_ty.kind() { + if let ty::FnDef(def_id, args_ref) = ref_ty.kind() { Some((def_id, args_ref)) } else { None diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index acde16fcb7579..13bb2f95cdad7 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -1118,11 +1118,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { // Trivial case: we are fetching a statically known length. let place_ty = place.ty(self.local_decls, self.tcx).ty; if let ty::Array(_, len) = place_ty.kind() { - return self.insert_constant(Const::from_ty_const( - *len, - self.tcx.types.usize, - self.tcx, - )); + return self.insert_constant(Const::from_ty_const(len, self.tcx.types.usize, self.tcx)); } let mut inner = self.simplify_place_value(place, location)?; @@ -1144,11 +1140,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { && let Some(to) = to.builtin_deref(true) && let ty::Slice(..) = to.kind() { - return self.insert_constant(Const::from_ty_const( - *len, - self.tcx.types.usize, - self.tcx, - )); + return self.insert_constant(Const::from_ty_const(len, self.tcx.types.usize, self.tcx)); } // Fallback: a symbolic `Len`. diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index fe2237dd2e97a..3aab76d5edfdb 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -253,7 +253,7 @@ impl<'tcx> Inliner<'tcx> { self_arg.map(|self_arg| self_arg.node.ty(&caller_body.local_decls, self.tcx)); let arg_tuple_ty = arg_tuple.node.ty(&caller_body.local_decls, self.tcx); - let ty::Tuple(arg_tuple_tys) = *arg_tuple_ty.kind() else { + let ty::Tuple(arg_tuple_tys) = arg_tuple_ty.kind() else { bug!("Closure arguments are not passed as a tuple"); }; @@ -381,7 +381,7 @@ impl<'tcx> Inliner<'tcx> { let terminator = bb_data.terminator(); if let TerminatorKind::Call { ref func, fn_span, .. } = terminator.kind { let func_ty = func.ty(caller_body, self.tcx); - if let ty::FnDef(def_id, args) = *func_ty.kind() { + if let ty::FnDef(def_id, args) = func_ty.kind() { // To resolve an instance its args have to be fully normalized. let args = self.tcx.try_normalize_erasing_regions(self.param_env, args).ok()?; let callee = diff --git a/compiler/rustc_mir_transform/src/inline/cycle.rs b/compiler/rustc_mir_transform/src/inline/cycle.rs index 8c5f965108bdc..5f44dfede14f3 100644 --- a/compiler/rustc_mir_transform/src/inline/cycle.rs +++ b/compiler/rustc_mir_transform/src/inline/cycle.rs @@ -172,15 +172,15 @@ pub(crate) fn mir_inliner_callees<'tcx>( let ty::FnDef(def_id, generic_args) = ty.kind() else { continue; }; - let call = if tcx.is_intrinsic(*def_id, sym::const_eval_select) { + let call = if tcx.is_intrinsic(def_id, sym::const_eval_select) { let func = &call_args[2].node; let ty = func.ty(&body.local_decls, tcx); let ty::FnDef(def_id, generic_args) = ty.kind() else { continue; }; - (*def_id, *generic_args) + (def_id, generic_args) } else { - (*def_id, *generic_args) + (def_id, generic_args) }; calls.insert(call); } diff --git a/compiler/rustc_mir_transform/src/instsimplify.rs b/compiler/rustc_mir_transform/src/instsimplify.rs index 6806c517c17de..1eac7ee507df5 100644 --- a/compiler/rustc_mir_transform/src/instsimplify.rs +++ b/compiler/rustc_mir_transform/src/instsimplify.rs @@ -145,7 +145,7 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> { fn simplify_len(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) { if let Rvalue::Len(ref place) = *rvalue { let place_ty = place.ty(self.local_decls, self.tcx).ty; - if let ty::Array(_, len) = *place_ty.kind() { + if let ty::Array(_, len) = place_ty.kind() { if !self.should_simplify(source_info, rvalue) { return; } @@ -264,7 +264,7 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> { // doing DefId lookups to figure out what we're actually calling. let arg_ty = args[0].node.ty(self.local_decls, self.tcx); - let ty::Ref(_region, inner_ty, Mutability::Not) = *arg_ty.kind() else { return }; + let ty::Ref(_region, inner_ty, Mutability::Not) = arg_ty.kind() else { return }; if !inner_ty.is_trivially_pure_clone_copy() { return; @@ -369,7 +369,7 @@ fn resolve_rust_intrinsic<'tcx>( tcx: TyCtxt<'tcx>, func_ty: Ty<'tcx>, ) -> Option<(Symbol, GenericArgsRef<'tcx>)> { - if let ty::FnDef(def_id, args) = *func_ty.kind() { + if let ty::FnDef(def_id, args) = func_ty.kind() { let intrinsic = tcx.intrinsic(def_id)?; return Some((intrinsic.name, args)); } diff --git a/compiler/rustc_mir_transform/src/large_enums.rs b/compiler/rustc_mir_transform/src/large_enums.rs index e407929c9a7fd..fd53471624f9e 100644 --- a/compiler/rustc_mir_transform/src/large_enums.rs +++ b/compiler/rustc_mir_transform/src/large_enums.rs @@ -75,7 +75,7 @@ impl EnumSizeOpt { return None; } if let Some(alloc_id) = alloc_cache.get(&ty) { - return Some((*adt_def, num_discrs, *alloc_id)); + return Some((adt_def, num_discrs, *alloc_id)); } let data_layout = tcx.data_layout(); @@ -114,7 +114,7 @@ impl EnumSizeOpt { Mutability::Not, ); let alloc = tcx.reserve_and_set_memory_alloc(tcx.mk_const_alloc(alloc)); - Some((*adt_def, num_discrs, *alloc_cache.entry(ty).or_insert(alloc))) + Some((adt_def, num_discrs, *alloc_cache.entry(ty).or_insert(alloc))) } fn optim<'tcx>(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { let mut alloc_cache = FxHashMap::default(); diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index a8741254ffbf7..f44b610760670 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -156,7 +156,7 @@ fn remap_mir_for_const_eval_select<'tcx>( unwind, fn_span, .. - } if let ty::FnDef(def_id, _) = *const_.ty().kind() + } if let ty::FnDef(def_id, _) = const_.ty().kind() && tcx.is_intrinsic(def_id, sym::const_eval_select) => { let [tupled_args, called_in_const, called_at_rt]: [_; 3] = diff --git a/compiler/rustc_mir_transform/src/lower_intrinsics.rs b/compiler/rustc_mir_transform/src/lower_intrinsics.rs index 3ffc447217d7d..26f37bd1a5a5e 100644 --- a/compiler/rustc_mir_transform/src/lower_intrinsics.rs +++ b/compiler/rustc_mir_transform/src/lower_intrinsics.rs @@ -14,7 +14,7 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics { let terminator = block.terminator.as_mut().unwrap(); if let TerminatorKind::Call { func, args, destination, target, .. } = &mut terminator.kind - && let ty::FnDef(def_id, generic_args) = *func.ty(local_decls, tcx).kind() + && let ty::FnDef(def_id, generic_args) = func.ty(local_decls, tcx).kind() && let Some(intrinsic) = tcx.intrinsic(def_id) { match intrinsic.name { @@ -298,7 +298,7 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics { let target = target.unwrap(); let pointer_ty = generic_args.type_at(0); let kind = if let ty::RawPtr(pointee_ty, mutability) = pointer_ty.kind() { - AggregateKind::RawPtr(*pointee_ty, *mutability) + AggregateKind::RawPtr(pointee_ty, mutability) } else { span_bug!( terminator.source_info.span, diff --git a/compiler/rustc_mir_transform/src/lower_slice_len.rs b/compiler/rustc_mir_transform/src/lower_slice_len.rs index 2267a621a834a..67c1b61c98225 100644 --- a/compiler/rustc_mir_transform/src/lower_slice_len.rs +++ b/compiler/rustc_mir_transform/src/lower_slice_len.rs @@ -52,7 +52,7 @@ fn lower_slice_len_call<'tcx>( && let [arg] = &args[..] && let Some(arg) = arg.node.place() && let ty::FnDef(fn_def_id, _) = func.ty(local_decls, tcx).kind() - && *fn_def_id == slice_len_fn_item_def_id + && fn_def_id == slice_len_fn_item_def_id { // perform modifications from something like: // _5 = core::slice::::len(move _6) -> bb1 diff --git a/compiler/rustc_mir_transform/src/normalize_array_len.rs b/compiler/rustc_mir_transform/src/normalize_array_len.rs index d5e727066614a..07a64d8dd1788 100644 --- a/compiler/rustc_mir_transform/src/normalize_array_len.rs +++ b/compiler/rustc_mir_transform/src/normalize_array_len.rs @@ -52,7 +52,7 @@ fn compute_slice_length<'tcx>( && let Some(cast_ty) = cast_ty.builtin_deref(true) && let ty::Slice(..) = cast_ty.kind() { - slice_lengths[local] = Some(*len); + slice_lengths[local] = Some(len); } } // The length information is stored in the fat pointer, so we treat `operand` as a value. diff --git a/compiler/rustc_mir_transform/src/promote_consts.rs b/compiler/rustc_mir_transform/src/promote_consts.rs index 7ec59cc983f53..920b4e58173c3 100644 --- a/compiler/rustc_mir_transform/src/promote_consts.rs +++ b/compiler/rustc_mir_transform/src/promote_consts.rs @@ -656,7 +656,7 @@ impl<'tcx> Validator<'_, 'tcx> { // Functions marked `#[rustc_promotable]` are explicitly allowed to be promoted, so we can // accept them at this point. let fn_ty = callee.ty(self.body, self.tcx); - if let ty::FnDef(def_id, _) = *fn_ty.kind() { + if let ty::FnDef(def_id, _) = fn_ty.kind() { if self.tcx.is_promotable_const_fn(def_id) { return Ok(()); } @@ -674,7 +674,7 @@ impl<'tcx> Validator<'_, 'tcx> { return Err(Unpromotable); } // Make sure the callee is a `const fn`. - let is_const_fn = match *fn_ty.kind() { + let is_const_fn = match fn_ty.kind() { ty::FnDef(def_id, _) => self.tcx.is_const_fn_raw(def_id), _ => false, }; diff --git a/compiler/rustc_mir_transform/src/shim.rs b/compiler/rustc_mir_transform/src/shim.rs index d03c2d18c0c35..2f4ad450cfe13 100644 --- a/compiler/rustc_mir_transform/src/shim.rs +++ b/compiler/rustc_mir_transform/src/shim.rs @@ -86,9 +86,9 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<' // FIXME(#91576): Drop shims for coroutines aren't subject to the MIR passes at the end // of this function. Is this intentional? if let Some(ty::Coroutine(coroutine_def_id, args)) = ty.map(Ty::kind) { - let coroutine_body = tcx.optimized_mir(*coroutine_def_id); + let coroutine_body = tcx.optimized_mir(coroutine_def_id); - let ty::Coroutine(_, id_args) = *tcx.type_of(coroutine_def_id).skip_binder().kind() + let ty::Coroutine(_, id_args) = tcx.type_of(coroutine_def_id).skip_binder().kind() else { bug!() }; @@ -434,8 +434,8 @@ fn build_clone_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, self_ty: Ty<'tcx>) - ty::Closure(_, args) => builder.tuple_like_shim(dest, src, args.as_closure().upvar_tys()), ty::Tuple(..) => builder.tuple_like_shim(dest, src, self_ty.tuple_fields()), ty::Coroutine(coroutine_def_id, args) => { - assert_eq!(tcx.coroutine_movability(*coroutine_def_id), hir::Movability::Movable); - builder.coroutine_shim(dest, src, *coroutine_def_id, args.as_coroutine()) + assert_eq!(tcx.coroutine_movability(coroutine_def_id), hir::Movability::Movable); + builder.coroutine_shim(dest, src, coroutine_def_id, args.as_coroutine()) } _ => bug!("clone shim for `{:?}` which is not `Copy` and is not an aggregate", self_ty), }; @@ -1017,7 +1017,7 @@ fn build_construct_coroutine_by_move_shim<'tcx>( receiver_by_ref: bool, ) -> Body<'tcx> { let mut self_ty = tcx.type_of(coroutine_closure_def_id).instantiate_identity(); - let ty::CoroutineClosure(_, args) = *self_ty.kind() else { + let ty::CoroutineClosure(_, args) = self_ty.kind() else { bug!(); }; @@ -1052,7 +1052,7 @@ fn build_construct_coroutine_by_move_shim<'tcx>( ) }); let sig = tcx.liberate_late_bound_regions(coroutine_closure_def_id, poly_sig); - let ty::Coroutine(coroutine_def_id, coroutine_args) = *sig.output().kind() else { + let ty::Coroutine(coroutine_def_id, coroutine_args) = sig.output().kind() else { bug!(); }; diff --git a/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs b/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs index aa9c87d8f80d9..15a9b8595e6da 100644 --- a/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs +++ b/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs @@ -142,8 +142,8 @@ impl<'tcx> AsyncDestructorCtorShimBuilder<'tcx> { }; match self_ty.kind() { - ty::Array(elem_ty, _) => self.build_slice(true, *elem_ty), - ty::Slice(elem_ty) => self.build_slice(false, *elem_ty), + ty::Array(elem_ty, _) => self.build_slice(true, elem_ty), + ty::Slice(elem_ty) => self.build_slice(false, elem_ty), ty::Tuple(elem_tys) => self.build_chain(None, elem_tys.iter()), ty::Adt(adt_def, args) if adt_def.is_struct() => { @@ -156,7 +156,7 @@ impl<'tcx> AsyncDestructorCtorShimBuilder<'tcx> { } ty::Adt(adt_def, args) if adt_def.is_enum() => { - self.build_enum(*adt_def, *args, surface_drop_kind()) + self.build_enum(adt_def, args, surface_drop_kind()) } ty::Adt(adt_def, _) => { @@ -561,7 +561,7 @@ impl<'tcx> AsyncDestructorCtorShimBuilder<'tcx> { // If projection of Discriminant then compare with `Ty::discriminant_ty` if let ty::Alias(ty::Projection, ty::AliasTy { args, def_id, .. }) = expected_ty.kind() - && Some(*def_id) == self.tcx.lang_items().discriminant_type() + && Some(def_id) == self.tcx.lang_items().discriminant_type() && args.first().unwrap().as_type().unwrap().discriminant_ty(self.tcx) == operand_ty { return; diff --git a/compiler/rustc_mir_transform/src/validate.rs b/compiler/rustc_mir_transform/src/validate.rs index 3b4d4c9387710..b153a6ab2e076 100644 --- a/compiler/rustc_mir_transform/src/validate.rs +++ b/compiler/rustc_mir_transform/src/validate.rs @@ -673,7 +673,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { }; let kind = match parent_ty.ty.kind() { - &ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => { + ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => { self.tcx.type_of(def_id).instantiate(self.tcx, args).kind() } kind => kind, @@ -722,7 +722,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { }; check_equal(self, location, f_ty); } - &ty::Coroutine(def_id, args) => { + ty::Coroutine(def_id, args) => { let f_ty = if let Some(var) = parent_ty.variant_index { // If we're currently validating an inlined copy of this body, // then it will no longer be parameterized over the original @@ -970,7 +970,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { let data_ptr_ty = fields.raw[0].ty(self.body, self.tcx); let metadata_ty = fields.raw[1].ty(self.body, self.tcx); if let ty::RawPtr(in_pointee, in_mut) = data_ptr_ty.kind() { - if *in_mut != mutability { + if in_mut != mutability { self.fail(location, "input and output mutability must match"); } diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 9487692662bb7..fefd101315a01 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -772,7 +772,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> { // *Before* monomorphizing, record that we already handled this mention. self.used_mentioned_items.insert(MentionedItem::Closure(source_ty)); let source_ty = self.monomorphize(source_ty); - if let ty::Closure(def_id, args) = *source_ty.kind() { + if let ty::Closure(def_id, args) = source_ty.kind() { let instance = Instance::resolve_closure(self.tcx, def_id, args, ty::ClosureKind::FnOnce); if should_codegen_locally(self.tcx, instance) { @@ -914,7 +914,7 @@ fn visit_fn_use<'tcx>( source: Span, output: &mut MonoItems<'tcx>, ) { - if let ty::FnDef(def_id, args) = *ty.kind() { + if let ty::FnDef(def_id, args) = ty.kind() { let instance = if is_direct_call { ty::Instance::expect_resolve(tcx, ty::ParamEnv::reveal_all(), def_id, args) } else { @@ -1097,7 +1097,7 @@ fn find_vtable_types_for_unsizing<'tcx>( match (&source_ty.kind(), &target_ty.kind()) { (&ty::Ref(_, a, _), &ty::Ref(_, b, _) | &ty::RawPtr(b, _)) - | (&ty::RawPtr(a, _), &ty::RawPtr(b, _)) => ptr_vtable(*a, *b), + | (&ty::RawPtr(a, _), &ty::RawPtr(b, _)) => ptr_vtable(a, b), (&ty::Adt(def_a, _), &ty::Adt(def_b, _)) if def_a.is_box() && def_b.is_box() => { ptr_vtable(source_ty.boxed_ty(), target_ty.boxed_ty()) } @@ -1317,7 +1317,7 @@ fn visit_mentioned_item<'tcx>( ) { match *item { MentionedItem::Fn(ty) => { - if let ty::FnDef(def_id, args) = *ty.kind() { + if let ty::FnDef(def_id, args) = ty.kind() { let instance = Instance::expect_resolve(tcx, ty::ParamEnv::reveal_all(), def_id, args); // `visit_instance_use` was written for "used" item collection but works just as well @@ -1343,7 +1343,7 @@ fn visit_mentioned_item<'tcx>( } } MentionedItem::Closure(source_ty) => { - if let ty::Closure(def_id, args) = *source_ty.kind() { + if let ty::Closure(def_id, args) = source_ty.kind() { let instance = Instance::resolve_closure(tcx, def_id, args, ty::ClosureKind::FnOnce); if should_codegen_locally(tcx, instance) { diff --git a/compiler/rustc_monomorphize/src/collector/move_check.rs b/compiler/rustc_monomorphize/src/collector/move_check.rs index 851f86e86b8e8..649193b463ad8 100644 --- a/compiler/rustc_monomorphize/src/collector/move_check.rs +++ b/compiler/rustc_monomorphize/src/collector/move_check.rs @@ -61,7 +61,7 @@ impl<'a, 'tcx> MirUsedCollector<'a, 'tcx> { } // Allow large moves into container types that themselves are cheap to move - let ty::FnDef(def_id, _) = *callee_ty.kind() else { + let ty::FnDef(def_id, _) = callee_ty.kind() else { return; }; if self diff --git a/compiler/rustc_monomorphize/src/polymorphize.rs b/compiler/rustc_monomorphize/src/polymorphize.rs index a3ca9e9f9cfe9..ae82bd4f9af6a 100644 --- a/compiler/rustc_monomorphize/src/polymorphize.rs +++ b/compiler/rustc_monomorphize/src/polymorphize.rs @@ -316,7 +316,7 @@ impl<'a, 'tcx> TypeVisitor> for MarkUsedGenericParams<'a, 'tcx> { return; } - match *ty.kind() { + match ty.kind() { ty::Closure(def_id, args) | ty::Coroutine(def_id, args, ..) => { debug!(?def_id); // Avoid cycle errors with coroutines. diff --git a/compiler/rustc_passes/src/abi_test.rs b/compiler/rustc_passes/src/abi_test.rs index 0c3dd649997ef..9294d864e12bc 100644 --- a/compiler/rustc_passes/src/abi_test.rs +++ b/compiler/rustc_passes/src/abi_test.rs @@ -134,7 +134,7 @@ fn dump_abi_of_fn_type(tcx: TyCtxt<'_>, item_def_id: LocalDefId, attr: &Attribut ); }; let abi = unwrap_fn_abi( - tcx.fn_abi_of_fn_ptr(param_env.and((*sig, /* extra_args */ ty::List::empty()))), + tcx.fn_abi_of_fn_ptr(param_env.and((sig, /* extra_args */ ty::List::empty()))), tcx, item_def_id, ); @@ -149,7 +149,7 @@ fn dump_abi_of_fn_type(tcx: TyCtxt<'_>, item_def_id: LocalDefId, attr: &Attribut "`#[rustc_abi(assert_eq)]` on a type alias requires pair type" ); }; - let [field1, field2] = ***fields else { + let [field1, field2] = **fields else { span_bug!( meta_item.span(), "`#[rustc_abi(assert_eq)]` on a type alias requires pair type" @@ -162,9 +162,7 @@ fn dump_abi_of_fn_type(tcx: TyCtxt<'_>, item_def_id: LocalDefId, attr: &Attribut ); }; let abi1 = unwrap_fn_abi( - tcx.fn_abi_of_fn_ptr( - param_env.and((*sig1, /* extra_args */ ty::List::empty())), - ), + tcx.fn_abi_of_fn_ptr(param_env.and((sig1, /* extra_args */ ty::List::empty()))), tcx, item_def_id, ); @@ -175,9 +173,7 @@ fn dump_abi_of_fn_type(tcx: TyCtxt<'_>, item_def_id: LocalDefId, attr: &Attribut ); }; let abi2 = unwrap_fn_abi( - tcx.fn_abi_of_fn_ptr( - param_env.and((*sig2, /* extra_args */ ty::List::empty())), - ), + tcx.fn_abi_of_fn_ptr(param_env.and((sig2, /* extra_args */ ty::List::empty()))), tcx, item_def_id, ); diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index 0049afff528ca..f9e4db51ece58 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -453,7 +453,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> { //// method of a private type is used, but the type itself is never //// called directly. let self_ty = self.tcx.type_of(item).instantiate_identity(); - match *self_ty.kind() { + match self_ty.kind() { ty::Adt(def, _) => self.check_def_id(def.did()), ty::Foreign(did) => self.check_def_id(did), ty::Dynamic(data, ..) => { @@ -578,7 +578,7 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> { 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() { - self.mark_as_used_if_union(*adt, fields); + self.mark_as_used_if_union(adt, fields); } } hir::ExprKind::Closure(cls) => { diff --git a/compiler/rustc_pattern_analysis/src/rustc.rs b/compiler/rustc_pattern_analysis/src/rustc.rs index 81c5f3552319a..c9fcf2e5376c9 100644 --- a/compiler/rustc_pattern_analysis/src/rustc.rs +++ b/compiler/rustc_pattern_analysis/src/rustc.rs @@ -100,7 +100,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { #[inline] pub fn reveal_opaque_ty(&self, ty: Ty<'tcx>) -> RevealedTy<'tcx> { fn reveal_inner<'tcx>(cx: &RustcPatCtxt<'_, 'tcx>, ty: Ty<'tcx>) -> RevealedTy<'tcx> { - let ty::Alias(ty::Opaque, alias_ty) = *ty.kind() else { bug!() }; + let ty::Alias(ty::Opaque, alias_ty) = ty.kind() else { bug!() }; if let Some(local_def_id) = alias_ty.def_id.as_local() { let key = ty::OpaqueTypeKey { def_id: local_def_id, args: alias_ty.args }; if let Some(ty) = cx.reveal_opaque_key(key) { @@ -213,8 +213,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { // patterns. If we're here we can assume this is a box pattern. reveal_and_alloc(cx, once(args.type_at(0))) } else { - let variant = - &adt.variant(RustcPatCtxt::variant_index_for_adt(&ctor, *adt)); + let variant = &adt.variant(RustcPatCtxt::variant_index_for_adt(&ctor, adt)); // In the cases of either a `#[non_exhaustive]` field list or a non-public // field, we skip uninhabited fields in order not to reveal the @@ -236,10 +235,10 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { _ => bug!("Unexpected type for constructor `{ctor:?}`: {ty:?}"), }, Ref => match ty.kind() { - ty::Ref(_, rty, _) => reveal_and_alloc(cx, once(*rty)), + ty::Ref(_, rty, _) => reveal_and_alloc(cx, once(rty)), _ => bug!("Unexpected type for `Ref` constructor: {ty:?}"), }, - Slice(slice) => match *ty.kind() { + Slice(slice) => match ty.kind() { ty::Slice(ty) | ty::Array(ty, _) => { let arity = slice.arity(); reveal_and_alloc(cx, (0..arity).map(|_| ty)) @@ -266,7 +265,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { // patterns. If we're here we can assume this is a box pattern. 1 } else { - let variant_idx = RustcPatCtxt::variant_index_for_adt(&ctor, *adt); + let variant_idx = RustcPatCtxt::variant_index_for_adt(&ctor, adt); adt.variant(variant_idx).fields.len() } } @@ -308,7 +307,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { range_2: Some(make_uint_range('\u{E000}' as u128, '\u{10FFFF}' as u128)), } } - &ty::Int(ity) => { + ty::Int(ity) => { let range = if ty.is_ptr_sized_integral() { // The min/max values of `isize` are not allowed to be observed. IntRange { @@ -325,7 +324,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { }; ConstructorSet::Integers { range_1: range, range_2: None } } - &ty::Uint(uty) => { + ty::Uint(uty) => { let range = if ty.is_ptr_sized_integral() { // The max value of `usize` is not allowed to be observed. let lo = MaybeInfiniteInt::new_finite_uint(0); @@ -339,13 +338,13 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { } ty::Slice(sub_ty) => ConstructorSet::Slice { array_len: None, - subtype_is_empty: cx.is_uninhabited(*sub_ty), + subtype_is_empty: cx.is_uninhabited(sub_ty), }, ty::Array(sub_ty, len) => { // We treat arrays of a constant but unknown length like slices. ConstructorSet::Slice { array_len: len.try_eval_target_usize(cx.tcx, cx.param_env).map(|l| l as usize), - subtype_is_empty: cx.is_uninhabited(*sub_ty), + subtype_is_empty: cx.is_uninhabited(sub_ty), } } ty::Adt(def, args) if def.is_enum() => { @@ -359,7 +358,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { let variant_def_id = def.variant(idx).def_id; // Visibly uninhabited variants. let is_inhabited = v - .inhabited_predicate(cx.tcx, *def) + .inhabited_predicate(cx.tcx, def) .instantiate(cx.tcx, args) .apply_revealing_opaque(cx.tcx, cx.param_env, cx.module, &|key| { cx.reveal_opaque_key(key) @@ -423,7 +422,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { PatRangeBoundary::NegInfinity => MaybeInfiniteInt::NegInfinity, PatRangeBoundary::Finite(value) => { let bits = value.eval_bits(self.tcx, self.param_env); - match *ty.kind() { + match ty.kind() { ty::Int(ity) => { let size = Integer::from_int_ty(&self.tcx, ity).size().bits(); MaybeInfiniteInt::new_finite_int(bits, size) @@ -507,8 +506,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { PatKind::Variant { variant_index, .. } => Variant(variant_index), _ => bug!(), }; - let variant = - &adt.variant(RustcPatCtxt::variant_index_for_adt(&ctor, *adt)); + let variant = &adt.variant(RustcPatCtxt::variant_index_for_adt(&ctor, adt)); arity = variant.fields.len(); fields = subpatterns .iter() @@ -531,7 +529,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { ty::Char | ty::Int(_) | ty::Uint(_) => { ctor = match value.try_eval_bits(cx.tcx, cx.param_env) { Some(bits) => { - let x = match *ty.kind() { + let x = match ty.kind() { ty::Int(ity) => { let size = Integer::from_int_ty(&cx.tcx, ity).size().bits(); MaybeInfiniteInt::new_finite_int(bits, size) @@ -577,7 +575,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { // `Ref`), and has one field. That field has constructor `Str(value)` and no // subfields. // Note: `t` is `str`, not `&str`. - let ty = self.reveal_opaque_ty(*t); + let ty = self.reveal_opaque_ty(t); let subpattern = DeconstructedPat::new(Str(*value), Vec::new(), 0, ty, pat); ctor = Ref; fields = vec![subpattern.at_index(0)]; @@ -697,7 +695,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { NegInfinity => PatRangeBoundary::NegInfinity, Finite(_) => { let size = ty.primitive_size(tcx); - let bits = match *ty.kind() { + let bits = match ty.kind() { ty::Int(_) => miint.as_finite_int(size.bits()).unwrap(), _ => miint.as_finite_uint().unwrap(), }; @@ -776,14 +774,14 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { PatKind::Deref { subpattern: subpatterns.next().unwrap() } } ty::Adt(adt_def, args) => { - let variant_index = RustcPatCtxt::variant_index_for_adt(&pat.ctor(), *adt_def); + let variant_index = RustcPatCtxt::variant_index_for_adt(&pat.ctor(), adt_def); let subpatterns = subpatterns .enumerate() .map(|(i, pattern)| FieldPat { field: FieldIdx::new(i), pattern }) .collect(); if adt_def.is_enum() { - PatKind::Variant { adt_def: *adt_def, args, variant_index, subpatterns } + PatKind::Variant { adt_def, args, variant_index, subpatterns } } else { PatKind::Leaf { subpatterns } } @@ -887,7 +885,7 @@ impl<'p, 'tcx: 'p> PatCx for RustcPatCtxt<'p, 'tcx> { if adt.is_box() { write!(f, "Box")? } else { - let variant = adt.variant(Self::variant_index_for_adt(ctor, *adt)); + let variant = adt.variant(Self::variant_index_for_adt(ctor, adt)); write!(f, "{}", variant.name)?; } } diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 698b28c626d0a..03e20dad10b97 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -175,7 +175,7 @@ where let tcx = self.def_id_visitor.tcx(); // GenericArgs are not visited here because they are visited below // in `super_visit_with`. - match *ty.kind() { + match ty.kind() { ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), ..) | ty::Foreign(def_id) | ty::FnDef(def_id, ..) diff --git a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs index 0be8b5d57187d..75f0746f2e043 100644 --- a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs +++ b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs @@ -134,7 +134,7 @@ fn encode_const<'tcx>( match ct_ty.kind() { ty::Int(ity) => { let bits = c.eval_bits(tcx, ty::ParamEnv::reveal_all()); - let val = Integer::from_int_ty(&tcx, *ity).size().sign_extend(bits) as i128; + let val = Integer::from_int_ty(&tcx, ity).size().sign_extend(bits) as i128; if val < 0 { s.push('n'); } @@ -416,7 +416,7 @@ pub fn encode_ty<'tcx>( let len = len.eval_target_usize(tcx, ty::ParamEnv::reveal_all()); let mut s = String::from("A"); let _ = write!(s, "{}", &len); - s.push_str(&encode_ty(tcx, *ty0, dict, options)); + s.push_str(&encode_ty(tcx, ty0, dict, options)); compress(dict, DictKey::Ty(ty, TyQ::None), &mut s); typeid.push_str(&s); } @@ -424,8 +424,8 @@ pub fn encode_ty<'tcx>( ty::Pat(ty0, pat) => { // u3patIE as vendor extended type let mut s = String::from("u3patI"); - s.push_str(&encode_ty(tcx, *ty0, dict, options)); - write!(s, "{:?}", **pat).unwrap(); + s.push_str(&encode_ty(tcx, ty0, dict, options)); + write!(s, "{:?}", pat).unwrap(); s.push('E'); compress(dict, DictKey::Ty(ty, TyQ::None), &mut s); typeid.push_str(&s); @@ -434,7 +434,7 @@ pub fn encode_ty<'tcx>( ty::Slice(ty0) => { // u5sliceIE as vendor extended type let mut s = String::from("u5sliceI"); - s.push_str(&encode_ty(tcx, *ty0, dict, options)); + s.push_str(&encode_ty(tcx, ty0, dict, options)); s.push('E'); compress(dict, DictKey::Ty(ty, TyQ::None), &mut s); typeid.push_str(&s); @@ -507,7 +507,7 @@ pub fn encode_ty<'tcx>( ty::Foreign(def_id) => { // , where is let mut s = String::new(); - if let Some(cfi_encoding) = tcx.get_attr(*def_id, sym::cfi_encoding) { + if let Some(cfi_encoding) = tcx.get_attr(def_id, sym::cfi_encoding) { // Use user-defined CFI encoding for type if let Some(value_str) = cfi_encoding.value_str() { if !value_str.to_string().trim().is_empty() { @@ -528,7 +528,7 @@ pub fn encode_ty<'tcx>( bug!("encode_ty: invalid `cfi_encoding` for `{:?}`", ty.kind()); } } else { - let name = tcx.item_name(*def_id).to_string(); + let name = tcx.item_name(def_id).to_string(); let _ = write!(s, "{}{}", name.len(), &name); } compress(dict, DictKey::Ty(ty, TyQ::None), &mut s); @@ -540,9 +540,9 @@ pub fn encode_ty<'tcx>( // u[IE], where is , // as vendor extended type. let mut s = String::new(); - let name = encode_ty_name(tcx, *def_id); + let name = encode_ty_name(tcx, def_id); let _ = write!(s, "u{}{}", name.len(), &name); - s.push_str(&encode_args(tcx, args, *def_id, false, dict, options)); + s.push_str(&encode_args(tcx, args, def_id, false, dict, options)); compress(dict, DictKey::Ty(ty, TyQ::None), &mut s); typeid.push_str(&s); } @@ -551,10 +551,10 @@ pub fn encode_ty<'tcx>( // u[IE], where is , // as vendor extended type. let mut s = String::new(); - let name = encode_ty_name(tcx, *def_id); + let name = encode_ty_name(tcx, def_id); let _ = write!(s, "u{}{}", name.len(), &name); let parent_args = tcx.mk_args(args.as_coroutine_closure().parent_args()); - s.push_str(&encode_args(tcx, parent_args, *def_id, false, dict, options)); + s.push_str(&encode_args(tcx, parent_args, def_id, false, dict, options)); compress(dict, DictKey::Ty(ty, TyQ::None), &mut s); typeid.push_str(&s); } @@ -563,13 +563,13 @@ pub fn encode_ty<'tcx>( // u[IE], where is , // as vendor extended type. let mut s = String::new(); - let name = encode_ty_name(tcx, *def_id); + let name = encode_ty_name(tcx, def_id); let _ = write!(s, "u{}{}", name.len(), &name); // Encode parent args only s.push_str(&encode_args( tcx, tcx.mk_args(args.as_coroutine().parent_args()), - *def_id, + def_id, false, dict, options, @@ -583,9 +583,9 @@ pub fn encode_ty<'tcx>( // [U3mut]u3refIE as vendor extended type qualifier and type let mut s = String::new(); s.push_str("u3refI"); - s.push_str(&encode_ty(tcx, *ty0, dict, options)); + s.push_str(&encode_ty(tcx, ty0, dict, options)); s.push('E'); - compress(dict, DictKey::Ty(Ty::new_imm_ref(tcx, *region, *ty0), TyQ::None), &mut s); + compress(dict, DictKey::Ty(Ty::new_imm_ref(tcx, region, ty0), TyQ::None), &mut s); if ty.is_mutable_ptr() { s = format!("{}{}", "U3mut", &s); compress(dict, DictKey::Ty(ty, TyQ::Mut), &mut s); @@ -597,10 +597,10 @@ pub fn encode_ty<'tcx>( // FIXME: This can definitely not be so spaghettified. // P[K] let mut s = String::new(); - s.push_str(&encode_ty(tcx, *ptr_ty, dict, options)); + s.push_str(&encode_ty(tcx, ptr_ty, dict, options)); if !ty.is_mutable_ptr() { s = format!("{}{}", "K", &s); - compress(dict, DictKey::Ty(*ptr_ty, TyQ::Const), &mut s); + compress(dict, DictKey::Ty(ptr_ty, TyQ::Const), &mut s); }; s = format!("{}{}", "P", &s); compress(dict, DictKey::Ty(ty, TyQ::None), &mut s); @@ -624,7 +624,7 @@ pub fn encode_ty<'tcx>( ty::DynStar => "u7dynstarI", }); s.push_str(&encode_predicates(tcx, predicates, dict, options)); - s.push_str(&encode_region(*region, dict)); + s.push_str(&encode_region(region, dict)); s.push('E'); compress(dict, DictKey::Ty(ty, TyQ::None), &mut s); typeid.push_str(&s); diff --git a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs index 2fbfb93150e7a..ee65308313502 100644 --- a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs +++ b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs @@ -335,7 +335,7 @@ pub fn transform_instance<'tcx>( tcx.mk_poly_existential_predicates_from_iter(preds.into_iter().filter(|pred| { !matches!(pred.skip_binder(), ty::ExistentialPredicate::AutoTrait(..)) })); - Ty::new_dynamic(tcx, filtered_preds, *lifetime, *kind) + Ty::new_dynamic(tcx, filtered_preds, lifetime, kind) } else { // If there's no principal type, re-encode it as a unit, since we don't know anything // about it. This technically discards the knowledge that it was a type that was made diff --git a/compiler/rustc_symbol_mangling/src/legacy.rs b/compiler/rustc_symbol_mangling/src/legacy.rs index 75cac6c7992a4..9f085563942db 100644 --- a/compiler/rustc_symbol_mangling/src/legacy.rs +++ b/compiler/rustc_symbol_mangling/src/legacy.rs @@ -222,7 +222,7 @@ impl<'tcx> Printer<'tcx> for SymbolPrinter<'tcx> { } fn print_type(&mut self, ty: Ty<'tcx>) -> Result<(), PrintError> { - match *ty.kind() { + match ty.kind() { // Print all nominal types as paths (unlike `pretty_print_type`). ty::FnDef(def_id, args) | ty::Alias(ty::Projection | ty::Opaque, ty::AliasTy { def_id, args, .. }) diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index 55479bce6fc82..476179831f312 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -340,7 +340,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> { } let start = self.out.len(); - match *ty.kind() { + match ty.kind() { // Basic types, handled above. ty::Bool | ty::Char | ty::Str | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Never => { unreachable!() @@ -576,8 +576,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> { // Negative integer values are mangled using `n` as a "sign prefix". if let ty::Int(ity) = ct_ty.kind() { - let val = - Integer::from_int_ty(&self.tcx, *ity).size().sign_extend(bits) as i128; + let val = Integer::from_int_ty(&self.tcx, ity).size().sign_extend(bits) as i128; if val < 0 { self.push("n"); } @@ -640,7 +639,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> { Ok(()) }; - match *ct_ty.kind() { + match ct_ty.kind() { ty::Array(..) | ty::Slice(_) => { self.push("A"); print_field_list(self)?; diff --git a/compiler/rustc_trait_selection/src/solve/assembly/mod.rs b/compiler/rustc_trait_selection/src/solve/assembly/mod.rs index b51efd339c4d8..fd42d2f83cd15 100644 --- a/compiler/rustc_trait_selection/src/solve/assembly/mod.rs +++ b/compiler/rustc_trait_selection/src/solve/assembly/mod.rs @@ -84,7 +84,7 @@ pub(super) trait GoalKind<'tcx>: ) -> Result, NoSolution> { Self::probe_and_match_goal_against_assumption(ecx, source, goal, assumption, |ecx| { let tcx = ecx.interner(); - let ty::Dynamic(bounds, _, _) = *goal.predicate.self_ty().kind() else { + let ty::Dynamic(bounds, _, _) = goal.predicate.self_ty().kind() else { bug!("expected object type in `probe_and_consider_object_bound_candidate`"); }; ecx.add_goals( @@ -591,7 +591,7 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> { goal: Goal<'tcx, G>, candidates: &mut Vec>, ) { - let (kind, alias_ty) = match *self_ty.kind() { + let (kind, alias_ty) = match self_ty.kind() { ty::Bool | ty::Char | ty::Int(_) @@ -681,7 +681,7 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> { } let self_ty = goal.predicate.self_ty(); - let bounds = match *self_ty.kind() { + let bounds = match self_ty.kind() { ty::Bool | ty::Char | ty::Int(_) 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 98f98d9992d30..c240089449592 100644 --- a/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs +++ b/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs @@ -22,7 +22,7 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_auto_trait<'tcx>( ty: Ty<'tcx>, ) -> Result>>, NoSolution> { let tcx = ecx.interner(); - match *ty.kind() { + match ty.kind() { ty::Uint(_) | ty::Int(_) | ty::Bool @@ -100,7 +100,7 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_sized_trait<'tcx>( ecx: &EvalCtxt<'_, InferCtxt<'tcx>>, ty: Ty<'tcx>, ) -> Result>>, NoSolution> { - match *ty.kind() { + match ty.kind() { // impl Sized for u*, i*, bool, f*, FnDef, FnPtr, *(const/mut) T, char, &mut? T, [T; N], dyn* Trait, ! // impl Sized for Coroutine, CoroutineWitness, Closure, CoroutineClosure ty::Infer(ty::IntVar(_) | ty::FloatVar(_)) @@ -164,7 +164,7 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_copy_clone_trait<'tcx>( ecx: &EvalCtxt<'_, InferCtxt<'tcx>>, ty: Ty<'tcx>, ) -> Result>>, NoSolution> { - match *ty.kind() { + match ty.kind() { // impl Copy/Clone for FnDef, FnPtr ty::FnDef(..) | ty::FnPtr(_) | ty::Error(_) => Ok(vec![]), @@ -239,7 +239,7 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable<'tcx>( self_ty: Ty<'tcx>, goal_kind: ty::ClosureKind, ) -> Result, Ty<'tcx>)>>, NoSolution> { - match *self_ty.kind() { + match self_ty.kind() { // keep this in sync with assemble_fn_pointer_candidates until the old solver is removed. ty::FnDef(def_id, args) => { let sig = tcx.fn_sig(def_id); @@ -394,7 +394,7 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_async_callable<'tc (ty::Binder<'tcx, AsyncCallableRelevantTypes<'tcx>>, Vec>), NoSolution, > { - match *self_ty.kind() { + match self_ty.kind() { ty::CoroutineClosure(def_id, args) => { let args = args.as_coroutine_closure(); let kind_ty = args.kind_ty(); @@ -709,7 +709,7 @@ impl<'tcx> TypeFolder> for ReplaceProjectionWith<'_, 'tcx> { } fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { - if let ty::Alias(ty::Projection, alias_ty) = *ty.kind() + if let ty::Alias(ty::Projection, alias_ty) = ty.kind() && let Some(replacement) = self.mapping.get(&alias_ty.def_id) { // We may have a case where our object type's projection bound is higher-ranked, diff --git a/compiler/rustc_trait_selection/src/solve/eval_ctxt/canonical.rs b/compiler/rustc_trait_selection/src/solve/eval_ctxt/canonical.rs index 0e0b9e983391c..c7eadb3e833a6 100644 --- a/compiler/rustc_trait_selection/src/solve/eval_ctxt/canonical.rs +++ b/compiler/rustc_trait_selection/src/solve/eval_ctxt/canonical.rs @@ -285,7 +285,7 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> { for (original_value, result_value) in iter::zip(original_values, var_values.var_values) { match result_value.unpack() { GenericArgKind::Type(t) => { - if let &ty::Bound(debruijn, b) = t.kind() { + if let ty::Bound(debruijn, b) = t.kind() { assert_eq!(debruijn, ty::INNERMOST); opt_values[b.var] = Some(*original_value); } diff --git a/compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs b/compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs index f90e47110376c..763aa6c53e595 100644 --- a/compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs +++ b/compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs @@ -635,7 +635,7 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> { ) -> bool { let universe_of_term = match goal.predicate.term.unpack() { ty::TermKind::Ty(ty) => { - if let &ty::Infer(ty::TyVar(vid)) = ty.kind() { + if let ty::Infer(ty::TyVar(vid)) = ty.kind() { self.infcx.universe_of_ty(vid).unwrap() } else { return false; @@ -669,7 +669,7 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> { impl<'tcx> TypeVisitor> for ContainsTermOrNotNameable<'_, 'tcx> { type Result = ControlFlow<()>; fn visit_ty(&mut self, t: Ty<'tcx>) -> Self::Result { - match *t.kind() { + match t.kind() { ty::Infer(ty::TyVar(vid)) => { if let ty::TermKind::Ty(term) = self.term.unpack() && let Some(term_vid) = term.ty_vid() @@ -1108,7 +1108,7 @@ impl<'tcx> TypeFolder> for ReplaceAliasWithInfer<'_, '_, 'tcx> { } fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { - match *ty.kind() { + match ty.kind() { ty::Alias(..) if !ty.has_escaping_bound_vars() => { let infer_ty = self.ecx.next_ty_infer(); let normalizes_to = ty::PredicateKind::AliasRelate( diff --git a/compiler/rustc_trait_selection/src/solve/normalize.rs b/compiler/rustc_trait_selection/src/solve/normalize.rs index f42edebfcc42e..5852a7d5a22fd 100644 --- a/compiler/rustc_trait_selection/src/solve/normalize.rs +++ b/compiler/rustc_trait_selection/src/solve/normalize.rs @@ -67,7 +67,7 @@ where let tcx = infcx.tcx; let recursion_limit = tcx.recursion_limit(); if !recursion_limit.value_within_limit(self.depth) { - let ty::Alias(_, data) = *alias_ty.kind() else { + let ty::Alias(_, data) = alias_ty.kind() else { unreachable!(); }; @@ -178,7 +178,7 @@ where return Ok(ty); } - let ty::Alias(..) = *ty.kind() else { return ty.try_super_fold_with(self) }; + let ty::Alias(..) = ty.kind() else { return ty.try_super_fold_with(self) }; if ty.has_escaping_bound_vars() { let (ty, mapped_regions, mapped_types, mapped_consts) = diff --git a/compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs b/compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs index 787f08a084ee6..2ec3922e766c2 100644 --- a/compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs +++ b/compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs @@ -534,7 +534,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> { | ty::Foreign(..) | ty::Dynamic(_, _, ty::DynStar) => tcx.types.unit, - ty::Error(e) => Ty::new_error(tcx, *e), + ty::Error(e) => Ty::new_error(tcx, e), ty::Str | ty::Slice(_) => tcx.types.usize, @@ -592,7 +592,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> { goal: Goal<'tcx, Self>, ) -> Result, NoSolution> { let self_ty = goal.predicate.self_ty(); - let ty::Coroutine(def_id, args) = *self_ty.kind() else { + let ty::Coroutine(def_id, args) = self_ty.kind() else { return Err(NoSolution); }; @@ -628,7 +628,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> { goal: Goal<'tcx, Self>, ) -> Result, NoSolution> { let self_ty = goal.predicate.self_ty(); - let ty::Coroutine(def_id, args) = *self_ty.kind() else { + let ty::Coroutine(def_id, args) = self_ty.kind() else { return Err(NoSolution); }; @@ -671,7 +671,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> { goal: Goal<'tcx, Self>, ) -> Result, NoSolution> { let self_ty = goal.predicate.self_ty(); - let ty::Coroutine(def_id, args) = *self_ty.kind() else { + let ty::Coroutine(def_id, args) = self_ty.kind() else { return Err(NoSolution); }; @@ -707,7 +707,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> { goal: Goal<'tcx, Self>, ) -> Result, NoSolution> { let self_ty = goal.predicate.self_ty(); - let ty::Coroutine(def_id, args) = *self_ty.kind() else { + let ty::Coroutine(def_id, args) = self_ty.kind() else { return Err(NoSolution); }; @@ -759,7 +759,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> { goal: Goal<'tcx, Self>, ) -> Result, NoSolution> { let self_ty = goal.predicate.self_ty(); - let discriminant_ty = match *self_ty.kind() { + let discriminant_ty = match self_ty.kind() { ty::Bool | ty::Char | ty::Int(..) @@ -811,7 +811,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> { goal: Goal<'tcx, Self>, ) -> Result, NoSolution> { let self_ty = goal.predicate.self_ty(); - let async_destructor_ty = match *self_ty.kind() { + let async_destructor_ty = match self_ty.kind() { ty::Bool | ty::Char | ty::Int(..) diff --git a/compiler/rustc_trait_selection/src/solve/trait_goals.rs b/compiler/rustc_trait_selection/src/solve/trait_goals.rs index a741f488901eb..eaa4d0c086157 100644 --- a/compiler/rustc_trait_selection/src/solve/trait_goals.rs +++ b/compiler/rustc_trait_selection/src/solve/trait_goals.rs @@ -440,7 +440,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> { return Err(NoSolution); } - let ty::Coroutine(def_id, _) = *goal.predicate.self_ty().kind() else { + let ty::Coroutine(def_id, _) = goal.predicate.self_ty().kind() else { return Err(NoSolution); }; @@ -466,7 +466,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> { return Err(NoSolution); } - let ty::Coroutine(def_id, _) = *goal.predicate.self_ty().kind() else { + let ty::Coroutine(def_id, _) = goal.predicate.self_ty().kind() else { return Err(NoSolution); }; @@ -492,7 +492,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> { return Err(NoSolution); } - let ty::Coroutine(def_id, _) = *goal.predicate.self_ty().kind() else { + let ty::Coroutine(def_id, _) = goal.predicate.self_ty().kind() else { return Err(NoSolution); }; @@ -516,7 +516,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> { return Err(NoSolution); } - let ty::Coroutine(def_id, _) = *goal.predicate.self_ty().kind() else { + let ty::Coroutine(def_id, _) = goal.predicate.self_ty().kind() else { return Err(NoSolution); }; @@ -543,7 +543,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> { } let self_ty = goal.predicate.self_ty(); - let ty::Coroutine(def_id, args) = *self_ty.kind() else { + let ty::Coroutine(def_id, args) = self_ty.kind() else { return Err(NoSolution); }; @@ -683,24 +683,24 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> { // Trait upcasting, or `dyn Trait + Auto + 'a` -> `dyn Trait + 'b`. ( - &ty::Dynamic(a_data, a_region, ty::Dyn), - &ty::Dynamic(b_data, b_region, ty::Dyn), + ty::Dynamic(a_data, a_region, ty::Dyn), + ty::Dynamic(b_data, b_region, ty::Dyn), ) => ecx.consider_builtin_dyn_upcast_candidates( goal, a_data, a_region, b_data, b_region, ), // `T` -> `dyn Trait` unsizing. - (_, &ty::Dynamic(b_region, b_data, ty::Dyn)) => result_to_single( + (_, ty::Dynamic(b_region, b_data, ty::Dyn)) => result_to_single( ecx.consider_builtin_unsize_to_dyn_candidate(goal, b_region, b_data), ), // `[T; N]` -> `[T]` unsizing - (&ty::Array(a_elem_ty, ..), &ty::Slice(b_elem_ty)) => { + (ty::Array(a_elem_ty, ..), ty::Slice(b_elem_ty)) => { result_to_single(ecx.consider_builtin_array_unsize(goal, a_elem_ty, b_elem_ty)) } // `Struct` -> `Struct` where `T: Unsize` - (&ty::Adt(a_def, a_args), &ty::Adt(b_def, b_args)) + (ty::Adt(a_def, a_args), ty::Adt(b_def, b_args)) if a_def.is_struct() && a_def == b_def => { result_to_single( @@ -709,7 +709,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> { } // `(A, B, T)` -> `(A, B, U)` where `T: Unsize` - (&ty::Tuple(a_tys), &ty::Tuple(b_tys)) + (ty::Tuple(a_tys), ty::Tuple(b_tys)) if a_tys.len() == b_tys.len() && !a_tys.is_empty() => { result_to_single(ecx.consider_builtin_tuple_unsize(goal, a_tys, b_tys)) @@ -1052,7 +1052,7 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> { goal: Goal<'tcx, TraitPredicate<'tcx>>, ) -> Option, NoSolution>> { let self_ty = goal.predicate.self_ty(); - match *self_ty.kind() { + match self_ty.kind() { // Stall int and float vars until they are resolved to a concrete // numerical type. That's because the check for impls below treats // int vars as matching any impl. Even if we filtered such impls, diff --git a/compiler/rustc_trait_selection/src/traits/auto_trait.rs b/compiler/rustc_trait_selection/src/traits/auto_trait.rs index 1d32ef2ccd94b..eabc9d088570c 100644 --- a/compiler/rustc_trait_selection/src/traits/auto_trait.rs +++ b/compiler/rustc_trait_selection/src/traits/auto_trait.rs @@ -554,7 +554,7 @@ impl<'tcx> AutoTraitFinder<'tcx> { fn is_self_referential_projection(&self, p: ty::PolyProjectionPredicate<'tcx>) -> bool { if let Some(ty) = p.term().skip_binder().as_type() { - matches!(ty.kind(), ty::Alias(ty::Projection, proj) if proj == &p.skip_binder().projection_term.expect_ty(self.tcx)) + matches!(ty.kind(), ty::Alias(ty::Projection, proj) if proj == p.skip_binder().projection_term.expect_ty(self.tcx)) } else { false } diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs index 1ef2f26cd09a9..bc855f54bc6a9 100644 --- a/compiler/rustc_trait_selection/src/traits/coherence.rs +++ b/compiler/rustc_trait_selection/src/traits/coherence.rs @@ -896,7 +896,7 @@ where Err(err) => return ControlFlow::Break(OrphanCheckEarlyExit::NormalizationFailure(err)), }; - let result = match *ty.kind() { + let result = match ty.kind() { ty::Bool | ty::Char | ty::Int(..) 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 6a96a03e047f7..25a887eeae715 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -147,7 +147,7 @@ pub fn suggest_restriction<'tcx, G: EmissionGuarantee>( let generics = tcx.generics_of(item_id); // Given `fn foo(t: impl Trait)` where `Trait` requires assoc type `A`... if let Some((param, bound_str, fn_sig)) = - fn_sig.zip(projection).and_then(|(sig, p)| match *p.self_ty().kind() { + fn_sig.zip(projection).and_then(|(sig, p)| match p.self_ty().kind() { // Shenanigans to get the `Trait` from the `impl Trait`. ty::Param(param) => { let param_def = generics.type_param(param, tcx); @@ -257,7 +257,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let trait_pred = self.resolve_numeric_literals_with_default(trait_pred); let self_ty = trait_pred.skip_binder().self_ty(); - let (param_ty, projection) = match *self_ty.kind() { + let (param_ty, projection) = match self_ty.kind() { ty::Param(_) => (true, None), ty::Alias(ty::Projection, projection) => (false, Some(projection)), _ => (false, None), @@ -480,7 +480,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { self.tcx.instantiate_bound_regions_with_erased(real_trait_pred.self_ty()); if self.can_eq(obligation.param_env, real_ty, arg_ty) - && let ty::Ref(region, base_ty, mutbl) = *real_ty.kind() + && let ty::Ref(region, base_ty, mutbl) = real_ty.kind() { let autoderef = (self.autoderef_steps)(base_ty); if let Some(steps) = @@ -1013,7 +1013,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { .. }) if ident.name == sym::clone && !call_span.from_expansion() - && !has_clone(*inner_ty) => + && !has_clone(inner_ty) => { // We only care about method calls corresponding to the real `Clone` trait. let Some(typeck_results) = self.typeck_results.as_ref() else { return false }; @@ -1031,7 +1031,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let new_obligation = self.mk_trait_obligation_with_new_self_ty( obligation.param_env, - trait_pred.map_bound(|trait_pred| (trait_pred, *inner_ty)), + trait_pred.map_bound(|trait_pred| (trait_pred, inner_ty)), ); if self.predicate_may_hold(&new_obligation) && has_clone(ty) { @@ -1081,7 +1081,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { // Autoderef is useful here because sometimes we box callables, etc. let Some((def_id_or_name, output, inputs)) = (self.autoderef_steps)(found).into_iter().find_map(|(found, _)| { - match *found.kind() { + match found.kind() { ty::FnPtr(fn_sig) => Some(( DefIdOrName::Name("function pointer"), fn_sig.output(), @@ -1275,7 +1275,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { && let ty::Ref(_, ty, mutability) = old_pred.self_ty().skip_binder().kind() { ( - mk_result(old_pred.map_bound(|trait_pred| (trait_pred, *ty))), + mk_result(old_pred.map_bound(|trait_pred| (trait_pred, ty))), mutability.is_mut(), ) } else { @@ -1522,7 +1522,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let ty::Ref(_, inner_ty, _) = suggested_ty.kind() else { break; }; - suggested_ty = *inner_ty; + suggested_ty = inner_ty; hir_ty = mut_ty.ty; @@ -1553,7 +1553,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let ty::Ref(_, inner_ty, _) = suggested_ty.kind() else { break 'outer; }; - suggested_ty = *inner_ty; + suggested_ty = inner_ty; expr = borrowed; @@ -1617,7 +1617,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { && let ty = typeck_results.expr_ty_adjusted(base) && let ty::FnDef(def_id, _args) = ty.kind() && let Some(hir::Node::Item(hir::Item { ident, span, vis_span, .. })) = - hir.get_if_local(*def_id) + hir.get_if_local(def_id) { let msg = format!("alternatively, consider making `fn {ident}` asynchronous"); if vis_span.is_empty() { @@ -1667,8 +1667,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } // Skipping binder here, remapping below - if let ty::Ref(region, t_type, mutability) = *trait_pred.skip_binder().self_ty().kind() - { + if let ty::Ref(region, t_type, mutability) = trait_pred.skip_binder().self_ty().kind() { let suggested_ty = match mutability { hir::Mutability::Mut => Ty::new_imm_ref(self.tcx, region, t_type), hir::Mutability::Not => Ty::new_mut_ref(self.tcx, region, t_type), @@ -1893,7 +1892,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let sig = match inputs.kind() { ty::Tuple(inputs) if infcx.tcx.is_fn_trait(trait_ref.def_id) => { infcx.tcx.mk_fn_sig( - *inputs, + inputs, infcx.next_ty_var(DUMMY_SP), false, hir::Safety::Safe, @@ -1970,8 +1969,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let hir::ExprKind::Path(path) = arg.kind else { return; }; - let expected_inputs = self.tcx.instantiate_bound_regions_with_erased(*expected).inputs(); - let found_inputs = self.tcx.instantiate_bound_regions_with_erased(*found).inputs(); + let expected_inputs = self.tcx.instantiate_bound_regions_with_erased(expected).inputs(); + let found_inputs = self.tcx.instantiate_bound_regions_with_erased(found).inputs(); let both_tys = expected_inputs.iter().copied().zip(found_inputs.iter().copied()); let arg_expr = |infcx: &InferCtxt<'tcx>, name, expected: Ty<'tcx>, found: Ty<'tcx>| { @@ -2274,7 +2273,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { "ImplDerived", ); - match *ty.kind() { + match ty.kind() { ty::Coroutine(did, ..) | ty::CoroutineWitness(did, _) => { coroutine = coroutine.or(Some(did)); outer_coroutine = Some(did); @@ -2303,7 +2302,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { self_ty.kind = ?ty.kind(), ); - match *ty.kind() { + match ty.kind() { ty::Coroutine(did, ..) | ty::CoroutineWitness(did, ..) => { coroutine = coroutine.or(Some(did)); outer_coroutine = Some(did); @@ -3226,7 +3225,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { if is_future && obligated_types.last().is_some_and(|ty| match ty.kind() { ty::Coroutine(last_def_id, ..) => { - tcx.coroutine_is_async(*last_def_id) + tcx.coroutine_is_async(last_def_id) } _ => false, }) @@ -3927,7 +3926,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } = fn_ty.fn_sig(tcx).skip_binder() // Extract first param of fn sig with peeled refs, e.g. `fn(&T)` -> `T` - && let Some(&ty::Ref(_, target_ty, needs_mut)) = fn_sig.inputs().first().map(|t| t.kind()) + && let Some(ty::Ref(_, target_ty, needs_mut)) = fn_sig.inputs().first().map(|t| t.kind()) && !target_ty.has_escaping_bound_vars() // Extract first tuple element out of fn trait, e.g. `FnOnce<(U,)>` -> `U` @@ -4042,7 +4041,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { trait_ref: ty::TraitRef::new( tcx, tcx.require_lang_item(LangItem::Clone, Some(span)), - [*ty], + [ty], ), polarity: ty::PredicatePolarity::Positive, }); @@ -4324,10 +4323,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { // 1. `[T; _]` (array of T) // 2. `&[T; _]` (reference to array of T) // 3. `&mut [T; _]` (mutable reference to array of T) - let (element_ty, mut mutability) = match *trait_ref.skip_binder().self_ty().kind() { + let (element_ty, mut mutability) = match trait_ref.skip_binder().self_ty().kind() { ty::Array(element_ty, _) => (element_ty, None), - ty::Ref(_, pointee_ty, mutability) => match *pointee_ty.kind() { + ty::Ref(_, pointee_ty, mutability) => match pointee_ty.kind() { ty::Array(element_ty, _) => (element_ty, Some(mutability)), _ => return, }, @@ -4337,9 +4336,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { // Go through all the candidate impls to see if any of them is for // slices of `element_ty` with `mutability`. - let mut is_slice = |candidate: Ty<'tcx>| match *candidate.kind() { + let mut is_slice = |candidate: Ty<'tcx>| match candidate.kind() { ty::RawPtr(t, m) | ty::Ref(_, t, m) => { - if matches!(*t.kind(), ty::Slice(e) if e == element_ty) + if matches!(t.kind(), ty::Slice(e) if e == element_ty) && m == mutability.unwrap_or(m) { // Use the candidate's mutability going forward. @@ -4535,7 +4534,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { self.type_implements_trait(default_trait, [ty], param_env).must_apply_modulo_regions() }; - Some(match *ty.kind() { + Some(match ty.kind() { ty::Never | ty::Error(_) => return None, ty::Bool => "false".to_string(), ty::Char => "\'x\'".to_string(), @@ -4604,13 +4603,13 @@ fn hint_missing_borrow<'tcx>( } let found_args = match found.kind() { - ty::FnPtr(f) => infcx.enter_forall(*f, |f| f.inputs().iter()), + ty::FnPtr(f) => infcx.enter_forall(f, |f| f.inputs().iter()), kind => { span_bug!(span, "found was converted to a FnPtr above but is now {:?}", kind) } }; let expected_args = match expected.kind() { - ty::FnPtr(f) => infcx.enter_forall(*f, |f| f.inputs().iter()), + ty::FnPtr(f) => infcx.enter_forall(f, |f| f.inputs().iter()), kind => { span_bug!(span, "expected was converted to a FnPtr above but is now {:?}", kind) } @@ -4875,7 +4874,7 @@ struct ReplaceImplTraitFolder<'tcx> { impl<'tcx> TypeFolder> for ReplaceImplTraitFolder<'tcx> { fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { if let ty::Param(ty::ParamTy { index, .. }) = t.kind() { - if self.param.index == *index { + if self.param.index == index { return self.replace_ty; } } @@ -5082,8 +5081,8 @@ fn get_deref_type_and_refs(mut ty: Ty<'_>) -> (Ty<'_>, Vec) { let mut refs = vec![]; while let ty::Ref(_, new_ty, mutbl) = ty.kind() { - ty = *new_ty; - refs.push(*mutbl); + ty = new_ty; + refs.push(mutbl); } (ty, refs) 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 46b137881866e..6a218adbb3d40 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 @@ -739,7 +739,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let is_fn_trait = tcx.is_fn_trait(trait_ref.def_id()); let is_target_feature_fn = if let ty::FnDef(def_id, _) = - *trait_ref.skip_binder().self_ty().kind() + trait_ref.skip_binder().self_ty().kind() { !self.tcx.codegen_fn_attrs(def_id).target_features.is_empty() } else { @@ -1029,7 +1029,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { obligation.cause.code() && let Some(typeck_results) = &self.typeck_results && let ty::Closure(closure_def_id, _) | ty::CoroutineClosure(closure_def_id, _) = - *typeck_results.node_type(arg_hir_id).kind() + typeck_results.node_type(arg_hir_id).kind() { // Otherwise, extract the closure kind from the obligation. let mut err = self.report_closure_error( @@ -1048,7 +1048,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let self_ty = trait_ref.self_ty().skip_binder(); if let Some(expected_kind) = self.tcx.fn_trait_kind_from_def_id(trait_ref.def_id()) { - let (closure_def_id, found_args, by_ref_captures) = match *self_ty.kind() { + let (closure_def_id, found_args, by_ref_captures) = match self_ty.kind() { ty::Closure(def_id, args) => { (def_id, args.as_closure().sig().map_bound(|sig| sig.inputs()[0]), None) } @@ -1743,7 +1743,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { if Some(pred.projection_term.def_id) == self.tcx.lang_items().fn_once_output() { let fn_kind = self_ty.prefix_string(self.tcx); let item = match self_ty.kind() { - ty::FnDef(def, _) => self.tcx.item_name(*def).to_string(), + ty::FnDef(def, _) => self.tcx.item_name(def).to_string(), _ => self_ty.to_string(), }; Some(format!( @@ -1809,7 +1809,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let strip_references = |mut t: Ty<'tcx>| -> Ty<'tcx> { loop { match t.kind() { - ty::Ref(_, inner, _) | ty::RawPtr(inner, _) => t = *inner, + ty::Ref(_, inner, _) | ty::RawPtr(inner, _) => t = inner, _ => break t, } } @@ -2832,7 +2832,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { - if let ty::Param(_) = *ty.kind() { + if let ty::Param(_) = ty.kind() { let infcx = self.infcx; *self.var_map.entry(ty).or_insert_with(|| infcx.next_ty_var(DUMMY_SP)) } else { @@ -3462,7 +3462,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { expected_trait_ref.self_ty().error_reported()?; let found_trait_ty = found_trait_ref.self_ty(); - let found_did = match *found_trait_ty.kind() { + let found_did = match found_trait_ty.kind() { ty::Closure(did, _) | ty::FnDef(did, _) | ty::Coroutine(did, ..) => Some(did), _ => None, }; diff --git a/compiler/rustc_trait_selection/src/traits/misc.rs b/compiler/rustc_trait_selection/src/traits/misc.rs index baec2268629dc..d58a850ec644f 100644 --- a/compiler/rustc_trait_selection/src/traits/misc.rs +++ b/compiler/rustc_trait_selection/src/traits/misc.rs @@ -54,7 +54,7 @@ pub fn type_allowed_to_implement_copy<'tcx>( | ty::Ref(_, _, hir::Mutability::Not) | ty::Array(..) => return Ok(()), - &ty::Adt(adt, args) => (adt, args), + ty::Adt(adt, args) => (adt, args), _ => return Err(CopyImplementationError::NotAnAdt), }; @@ -101,7 +101,7 @@ pub fn type_allowed_to_implement_const_param_ty<'tcx>( | ty::Ref(.., hir::Mutability::Not) | ty::Tuple(_) => return Ok(()), - &ty::Adt(adt, args) => (adt, args), + ty::Adt(adt, args) => (adt, args), _ => return Err(ConstParamTyImplementationError::NotAnAdtOrBuiltinAllowed), }; diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 7be2c4a85c563..e9b0165227bf8 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -557,7 +557,7 @@ fn is_impossible_associated_item( type Result = ControlFlow<()>; fn visit_ty(&mut self, t: Ty<'tcx>) -> Self::Result { // If this is a parameter from the trait item's own generics, then bail - if let ty::Param(param) = *t.kind() + if let ty::Param(param) = t.kind() && let param_def_id = self.generics.type_param(param, self.tcx).def_id && self.tcx.parent(param_def_id) == self.trait_item_def_id { diff --git a/compiler/rustc_trait_selection/src/traits/normalize.rs b/compiler/rustc_trait_selection/src/traits/normalize.rs index e7ab0b7791c43..b4fb25f78398a 100644 --- a/compiler/rustc_trait_selection/src/traits/normalize.rs +++ b/compiler/rustc_trait_selection/src/traits/normalize.rs @@ -181,7 +181,7 @@ impl<'a, 'b, 'tcx> TypeFolder> for AssocTypeNormalizer<'a, 'b, 'tcx return ty; } - let (kind, data) = match *ty.kind() { + let (kind, data) = match ty.kind() { ty::Alias(kind, data) => (kind, data), _ => return ty.super_fold_with(self), }; diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 2c9cb79664b34..3508ca77abda4 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -1513,10 +1513,10 @@ fn confirm_async_iterator_candidate<'cx, 'tcx>( debug_assert_eq!(tcx.associated_item(obligation.predicate.def_id).name, sym::Item); - let ty::Adt(_poll_adt, args) = *yield_ty.kind() else { + let ty::Adt(_poll_adt, args) = yield_ty.kind() else { bug!(); }; - let ty::Adt(_option_adt, args) = *args.type_at(0).kind() else { + let ty::Adt(_option_adt, args) = args.type_at(0).kind() else { bug!(); }; let item_ty = args.type_at(0); @@ -1617,7 +1617,7 @@ fn confirm_fn_pointer_candidate<'cx, 'tcx>( sig, ); - let host_effect_param = match *fn_type.kind() { + let host_effect_param = match fn_type.kind() { ty::FnDef(def_id, args) => tcx .generics_of(def_id) .host_effect_index @@ -1644,7 +1644,7 @@ fn confirm_closure_candidate<'cx, 'tcx>( ) -> Progress<'tcx> { let tcx = selcx.tcx(); let self_ty = selcx.infcx.shallow_resolve(obligation.predicate.self_ty()); - let closure_sig = match *self_ty.kind() { + let closure_sig = match self_ty.kind() { ty::Closure(_, args) => args.as_closure().sig(), // Construct a "normal" `FnOnce` signature for coroutine-closure. This is @@ -1776,7 +1776,7 @@ fn confirm_async_closure_candidate<'cx, 'tcx>( }; let item_name = tcx.item_name(obligation.predicate.def_id); - let poly_cache_entry = match *self_ty.kind() { + let poly_cache_entry = match self_ty.kind() { ty::CoroutineClosure(def_id, args) => { let args = args.as_coroutine_closure(); let kind_ty = args.kind_ty(); 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 326c68e01dbf7..0c2f274d7fe49 100644 --- a/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs +++ b/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs @@ -43,7 +43,7 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { | ty::Error(_) => true, // `T is PAT`, `[T; N]`, and `[T]` have same properties as T. - ty::Pat(ty, _) | ty::Array(ty, _) | ty::Slice(ty) => trivial_dropck_outlives(tcx, *ty), + ty::Pat(ty, _) | ty::Array(ty, _) | ty::Slice(ty) => trivial_dropck_outlives(tcx, ty), // (T1..Tn) and closures have same properties as T1..Tn -- // check if *all* of them are trivial. @@ -225,7 +225,7 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>( ty::Pat(ety, _) | ty::Array(ety, _) | ty::Slice(ety) => { // single-element containers, behave like their element rustc_data_structures::stack::ensure_sufficient_stack(|| { - dtorck_constraint_for_ty_inner(tcx, param_env, span, depth + 1, *ety, constraints) + dtorck_constraint_for_ty_inner(tcx, param_env, span, depth + 1, ety, constraints) })?; } diff --git a/compiler/rustc_trait_selection/src/traits/query/normalize.rs b/compiler/rustc_trait_selection/src/traits/query/normalize.rs index e170d7cae9379..4970578489a33 100644 --- a/compiler/rustc_trait_selection/src/traits/query/normalize.rs +++ b/compiler/rustc_trait_selection/src/traits/query/normalize.rs @@ -196,7 +196,7 @@ impl<'cx, 'tcx> FallibleTypeFolder> for QueryNormalizer<'cx, 'tcx> return Ok(*ty); } - let (kind, data) = match *ty.kind() { + let (kind, data) = match ty.kind() { ty::Alias(kind, data) => (kind, data), _ => { let res = ty.try_super_fold_with(self)?; 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 6db5fa0e4e552..8cc5f1dfd26d5 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -280,7 +280,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { match self_ty.kind() { // `async`/`gen` constructs get lowered to a special kind of coroutine that // should *not* `impl Coroutine`. - ty::Coroutine(did, ..) if self.tcx().is_general_coroutine(*did) => { + ty::Coroutine(did, ..) if self.tcx().is_general_coroutine(did) => { debug!(?self_ty, ?obligation, "assemble_coroutine_candidates",); candidates.vec.push(CoroutineCandidate); @@ -302,7 +302,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { if let ty::Coroutine(did, ..) = self_ty.kind() { // async constructs get lowered to a special kind of coroutine that // should directly `impl Future`. - if self.tcx().coroutine_is_async(*did) { + if self.tcx().coroutine_is_async(did) { debug!(?self_ty, ?obligation, "assemble_future_candidates",); candidates.vec.push(FutureCandidate); @@ -319,7 +319,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // gen constructs get lowered to a special kind of coroutine that // should directly `impl Iterator`. if let ty::Coroutine(did, ..) = self_ty.kind() - && self.tcx().coroutine_is_gen(*did) + && self.tcx().coroutine_is_gen(did) { debug!(?self_ty, ?obligation, "assemble_iterator_candidates",); @@ -336,7 +336,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // gen constructs get lowered to a special kind of coroutine that // should directly `impl FusedIterator`. if let ty::Coroutine(did, ..) = self_ty.kind() - && self.tcx().coroutine_is_gen(*did) + && self.tcx().coroutine_is_gen(did) { debug!(?self_ty, ?obligation, "assemble_fused_iterator_candidates",); @@ -350,7 +350,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { candidates: &mut SelectionCandidateSet<'tcx>, ) { let self_ty = obligation.self_ty().skip_binder(); - if let ty::Coroutine(did, args) = *self_ty.kind() { + if let ty::Coroutine(did, args) = self_ty.kind() { // gen constructs get lowered to a special kind of coroutine that // should directly `impl AsyncIterator`. if self.tcx().coroutine_is_async_gen(did) { @@ -358,11 +358,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // Can only confirm this candidate if we have constrained // the `Yield` type to at least `Poll>`.. - let ty::Adt(_poll_def, args) = *args.as_coroutine().yield_ty().kind() else { + let ty::Adt(_poll_def, args) = args.as_coroutine().yield_ty().kind() else { candidates.ambiguous = true; return; }; - let ty::Adt(_option_def, _) = *args.type_at(0).kind() else { + let ty::Adt(_option_def, _) = args.type_at(0).kind() else { candidates.ambiguous = true; return; }; @@ -391,7 +391,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // touch bound regions, they just capture the in-scope // type/region parameters let self_ty = obligation.self_ty().skip_binder(); - match *self_ty.kind() { + match self_ty.kind() { ty::Closure(def_id, _) => { let is_const = self.tcx().is_const_fn_raw(def_id); debug!(?kind, ?obligation, "assemble_unboxed_candidates"); @@ -455,7 +455,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { return; }; - match *obligation.self_ty().skip_binder().kind() { + match obligation.self_ty().skip_binder().kind() { ty::CoroutineClosure(_, args) => { if let Some(closure_kind) = args.as_coroutine_closure().kind_ty().to_opt_closure_kind() @@ -525,7 +525,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // Okay to skip binder because what we are inspecting doesn't involve bound regions. let self_ty = obligation.self_ty().skip_binder(); - match *self_ty.kind() { + match self_ty.kind() { ty::Infer(ty::TyVar(_)) => { debug!("assemble_fn_pointer_candidates: ambiguous self-type"); candidates.ambiguous = true; // Could wind up being a fn() type. @@ -719,7 +719,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let def_id = obligation.predicate.def_id(); if self.tcx().trait_is_auto(def_id) { - match *self_ty.kind() { + match self_ty.kind() { ty::Dynamic(..) => { // For object types, we don't know what the closed // over types are. This means we conservatively @@ -989,7 +989,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { match (source.kind(), target.kind()) { // Trait+Kx+'a -> Trait+Ky+'b (upcasts). - (&ty::Dynamic(a_data, a_region, ty::Dyn), &ty::Dynamic(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` @@ -1062,32 +1062,32 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { } // `T` -> `Trait` - (_, &ty::Dynamic(_, _, ty::Dyn)) => { + (_, ty::Dynamic(_, _, ty::Dyn)) => { candidates.vec.push(BuiltinUnsizeCandidate); } // Ambiguous handling is below `T` -> `Trait`, because inference // variables can still implement `Unsize` and nested // obligations will have the final say (likely deferred). - (&ty::Infer(ty::TyVar(_)), _) | (_, &ty::Infer(ty::TyVar(_))) => { + (ty::Infer(ty::TyVar(_)), _) | (_, ty::Infer(ty::TyVar(_))) => { debug!("assemble_candidates_for_unsizing: ambiguous"); candidates.ambiguous = true; } // `[T; n]` -> `[T]` - (&ty::Array(..), &ty::Slice(_)) => { + (ty::Array(..), ty::Slice(_)) => { candidates.vec.push(BuiltinUnsizeCandidate); } // `Struct` -> `Struct` - (&ty::Adt(def_id_a, _), &ty::Adt(def_id_b, _)) if def_id_a.is_struct() => { + (ty::Adt(def_id_a, _), ty::Adt(def_id_b, _)) if def_id_a.is_struct() => { if def_id_a == def_id_b { candidates.vec.push(BuiltinUnsizeCandidate); } } // `(.., T)` -> `(.., U)` - (&ty::Tuple(tys_a), &ty::Tuple(tys_b)) => { + (ty::Tuple(tys_a), ty::Tuple(tys_b)) => { if tys_a.len() == tys_b.len() { candidates.vec.push(BuiltinUnsizeCandidate); } diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index 749081006f392..5e1a0e7d3ec6d 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -532,7 +532,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let trait_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate); let self_ty = self.infcx.shallow_resolve(trait_predicate.self_ty()); - let ty::Dynamic(data, ..) = *self_ty.kind() else { + let ty::Dynamic(data, ..) = self_ty.kind() else { span_bug!(obligation.cause.span, "object candidate with non-object"); }; @@ -774,7 +774,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { ) -> Result>, SelectionError<'tcx>> { let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate); let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty()); - let ty::Coroutine(coroutine_def_id, args) = *self_ty.kind() else { + let ty::Coroutine(coroutine_def_id, args) = self_ty.kind() else { bug!("closure candidate for non-closure {:?}", obligation); }; @@ -804,7 +804,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { ) -> Result>, SelectionError<'tcx>> { let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate); let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty()); - let ty::Coroutine(coroutine_def_id, args) = *self_ty.kind() else { + let ty::Coroutine(coroutine_def_id, args) = self_ty.kind() else { bug!("closure candidate for non-closure {:?}", obligation); }; @@ -834,7 +834,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { ) -> Result>, SelectionError<'tcx>> { let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate); let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty()); - let ty::Coroutine(coroutine_def_id, args) = *self_ty.kind() else { + let ty::Coroutine(coroutine_def_id, args) = self_ty.kind() else { bug!("closure candidate for non-closure {:?}", obligation); }; @@ -864,7 +864,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { ) -> Result>, SelectionError<'tcx>> { let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate); let self_ty = self.infcx.shallow_resolve(placeholder_predicate.self_ty()); - let ty::Coroutine(coroutine_def_id, args) = *self_ty.kind() else { + let ty::Coroutine(coroutine_def_id, args) = self_ty.kind() else { bug!("closure candidate for non-closure {:?}", obligation); }; @@ -896,7 +896,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let placeholder_predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate); let self_ty: Ty<'_> = self.infcx.shallow_resolve(placeholder_predicate.self_ty()); - let trait_ref = match *self_ty.kind() { + let trait_ref = match self_ty.kind() { ty::Closure(..) => self.closure_trait_ref_unnormalized( self_ty, obligation.predicate.def_id(), @@ -930,7 +930,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let tcx = self.tcx(); let mut nested = vec![]; - let (trait_ref, kind_ty) = match *self_ty.kind() { + let (trait_ref, kind_ty) = match self_ty.kind() { ty::CoroutineClosure(_, args) => { let args = args.as_coroutine_closure(); let trait_ref = args.coroutine_closure_sig().map_bound(|sig| { @@ -1103,10 +1103,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let a_ty = self.infcx.shallow_resolve(predicate.self_ty()); let b_ty = self.infcx.shallow_resolve(predicate.trait_ref.args.type_at(1)); - let ty::Dynamic(a_data, a_region, ty::Dyn) = *a_ty.kind() else { + let ty::Dynamic(a_data, a_region, ty::Dyn) = a_ty.kind() else { bug!("expected `dyn` type in `confirm_trait_upcasting_unsize_candidate`") }; - let ty::Dynamic(b_data, b_region, ty::Dyn) = *b_ty.kind() else { + let ty::Dynamic(b_data, b_region, ty::Dyn) = b_ty.kind() else { bug!("expected `dyn` type in `confirm_trait_upcasting_unsize_candidate`") }; @@ -1172,7 +1172,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(data_a, r_a, dyn_a), &ty::Dynamic(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. @@ -1217,7 +1217,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { } // `T` -> `Trait` - (_, &ty::Dynamic(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.is_object_safe(*did)) { return Err(TraitNotObjectSafe(did)); @@ -1263,7 +1263,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { } // `[T; n]` -> `[T]` - (&ty::Array(a, _), &ty::Slice(b)) => { + (ty::Array(a, _), ty::Slice(b)) => { let InferOk { obligations, .. } = self .infcx .at(&obligation.cause, obligation.param_env) @@ -1274,7 +1274,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { } // `Struct` -> `Struct` - (&ty::Adt(def, args_a), &ty::Adt(_, args_b)) => { + (ty::Adt(def, args_a), ty::Adt(_, args_b)) => { let unsizing_params = tcx.unsizing_params_for_adt(def.did()); if unsizing_params.is_empty() { return Err(Unimplemented); @@ -1334,7 +1334,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { } // `(.., T)` -> `(.., U)` - (&ty::Tuple(tys_a), &ty::Tuple(tys_b)) => { + (ty::Tuple(tys_a), ty::Tuple(tys_b)) => { assert_eq!(tys_a.len(), tys_b.len()); // The last field of the tuple has to exist. @@ -1420,13 +1420,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { } // We want to confirm the ADT's fields if we have an ADT - let mut stack = match *self_ty.skip_binder().kind() { + let mut stack = match self_ty.skip_binder().kind() { ty::Adt(def, args) => def.all_fields().map(|f| f.ty(tcx, args)).collect(), _ => vec![self_ty.skip_binder()], }; while let Some(nested_ty) = stack.pop() { - match *nested_ty.kind() { + match nested_ty.kind() { // We know these types are trivially drop ty::Bool | ty::Char diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index ce4fa5fa47cbc..948d44f6ca188 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -1652,7 +1652,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let mut in_parent_alias_type = false; loop { - let (kind, alias_ty) = match *self_ty.kind() { + let (kind, alias_ty) = match self_ty.kind() { ty::Alias(kind @ (ty::Projection | ty::Opaque), alias_ty) => (kind, alias_ty), ty::Infer(ty::TyVar(_)) => { on_ambiguity(); @@ -2180,7 +2180,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> { obligation.predicate.rebind(tys.last().map_or_else(Vec::new, |&last| vec![last])), ), - ty::Pat(ty, _) => Where(obligation.predicate.rebind(vec![*ty])), + ty::Pat(ty, _) => Where(obligation.predicate.rebind(vec![ty])), ty::Adt(def, args) => { if let Some(sized_crit) = def.sized_constraint(self.tcx()) { @@ -2214,7 +2214,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> { use self::BuiltinImplConditions::{Ambiguous, None, Where}; - match *self_ty.kind() { + match self_ty.kind() { ty::FnDef(..) | ty::FnPtr(_) | ty::Error(_) => Where(ty::Binder::dummy(Vec::new())), ty::Uint(_) @@ -2333,7 +2333,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> { obligation: &PolyTraitObligation<'tcx>, ) -> BuiltinImplConditions<'tcx> { let self_ty = self.infcx.shallow_resolve(obligation.self_ty().skip_binder()); - if let ty::Coroutine(did, ..) = *self_ty.kind() + if let ty::Coroutine(did, ..) = self_ty.kind() && self.tcx().coroutine_is_gen(did) { BuiltinImplConditions::Where(ty::Binder::dummy(Vec::new())) @@ -2358,7 +2358,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> { &self, t: ty::Binder<'tcx, Ty<'tcx>>, ) -> Result>>, SelectionError<'tcx>> { - Ok(match *t.skip_binder().kind() { + Ok(match t.skip_binder().kind() { ty::Uint(_) | ty::Int(_) | ty::Bool @@ -2748,7 +2748,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> { fn_trait_def_id: DefId, fn_host_effect: ty::Const<'tcx>, ) -> ty::PolyTraitRef<'tcx> { - let ty::Closure(_, args) = *self_ty.kind() else { + let ty::Closure(_, args) = self_ty.kind() else { bug!("expected closure, found {self_ty}"); }; let closure_sig = args.as_closure().sig(); diff --git a/compiler/rustc_trait_selection/src/traits/structural_match.rs b/compiler/rustc_trait_selection/src/traits/structural_match.rs index d4535db951e25..bd8895b5daded 100644 --- a/compiler/rustc_trait_selection/src/traits/structural_match.rs +++ b/compiler/rustc_trait_selection/src/traits/structural_match.rs @@ -59,7 +59,7 @@ impl<'tcx> TypeVisitor> for Search<'tcx> { fn visit_ty(&mut self, ty: Ty<'tcx>) -> Self::Result { debug!("Search visiting ty: {:?}", ty); - let (adt_def, args) = match *ty.kind() { + let (adt_def, args) = match ty.kind() { ty::Adt(adt_def, args) => (adt_def, args), ty::Param(_) => { return ControlFlow::Break(ty); diff --git a/compiler/rustc_trait_selection/src/traits/structural_normalize.rs b/compiler/rustc_trait_selection/src/traits/structural_normalize.rs index 9d657ade86bfe..3f9ac21743b5c 100644 --- a/compiler/rustc_trait_selection/src/traits/structural_normalize.rs +++ b/compiler/rustc_trait_selection/src/traits/structural_normalize.rs @@ -15,7 +15,7 @@ impl<'tcx> At<'_, 'tcx> { assert!(!ty.is_ty_var(), "should have resolved vars before calling"); if self.infcx.next_trait_solver() { - let ty::Alias(..) = *ty.kind() else { + let ty::Alias(..) = ty.kind() else { return Ok(ty); }; diff --git a/compiler/rustc_trait_selection/src/traits/util.rs b/compiler/rustc_trait_selection/src/traits/util.rs index 960c27b636e12..3877b168726bd 100644 --- a/compiler/rustc_trait_selection/src/traits/util.rs +++ b/compiler/rustc_trait_selection/src/traits/util.rs @@ -447,7 +447,7 @@ impl<'tcx> TypeFolder> for BoundVarReplacer<'_, 'tcx> { } fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { - match *t.kind() { + match t.kind() { ty::Bound(debruijn, _) if debruijn.as_usize() + 1 > self.current_index.as_usize() + self.universe_indices.len() => @@ -582,7 +582,7 @@ impl<'tcx> TypeFolder> for PlaceholderReplacer<'_, 'tcx> { fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { let ty = self.infcx.shallow_resolve(ty); - match *ty.kind() { + match ty.kind() { ty::Placeholder(p) => { let replace_var = self.mapped_types.get(&p); match replace_var { diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index 066755f7b3e7c..7e36ddbded5a3 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -653,7 +653,7 @@ impl<'a, 'tcx> TypeVisitor> for WfPredicates<'a, 'tcx> { let tcx = self.tcx(); - match *t.kind() { + match t.kind() { ty::Bool | ty::Char | ty::Int(..) diff --git a/compiler/rustc_transmute/src/layout/tree.rs b/compiler/rustc_transmute/src/layout/tree.rs index 604b68d2cd4a6..1213de1add640 100644 --- a/compiler/rustc_transmute/src/layout/tree.rs +++ b/compiler/rustc_transmute/src/layout/tree.rs @@ -248,7 +248,7 @@ pub(crate) mod rustc { let FieldsShape::Array { stride, count } = &ty_and_layout.fields else { return Err(Err::NotYetSupported); }; - let inner_ty_and_layout = cx.layout_of(*inner_ty)?; + let inner_ty_and_layout = cx.layout_of(inner_ty)?; assert_eq!(*stride, inner_ty_and_layout.size); let elt = Tree::from_ty(inner_ty_and_layout, cx)?; Ok(std::iter::repeat(elt) @@ -258,23 +258,17 @@ pub(crate) mod rustc { ty::Adt(adt_def, _args_ref) if !ty_and_layout.ty.is_box() => { match adt_def.adt_kind() { - AdtKind::Struct => Self::from_struct(ty_and_layout, *adt_def, cx), - AdtKind::Enum => Self::from_enum(ty_and_layout, *adt_def, cx), - AdtKind::Union => Self::from_union(ty_and_layout, *adt_def, cx), + AdtKind::Struct => Self::from_struct(ty_and_layout, adt_def, cx), + AdtKind::Enum => Self::from_enum(ty_and_layout, adt_def, cx), + AdtKind::Union => Self::from_union(ty_and_layout, adt_def, cx), } } ty::Ref(lifetime, ty, mutability) => { - let ty_and_layout = cx.layout_of(*ty)?; + let ty_and_layout = cx.layout_of(ty)?; let align = ty_and_layout.align.abi.bytes_usize(); let size = ty_and_layout.size.bytes_usize(); - Ok(Tree::Ref(Ref { - lifetime: *lifetime, - ty: *ty, - mutability: *mutability, - align, - size, - })) + Ok(Tree::Ref(Ref { lifetime, ty, mutability, align, size })) } _ => Err(Err::NotYetSupported), diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index c5ea85c90dc5d..bd82a85c8cb03 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -44,7 +44,7 @@ fn fn_sig_for_fn_abi<'tcx>( } let ty = instance.ty(tcx, param_env); - match *ty.kind() { + match ty.kind() { ty::FnDef(..) => { // HACK(davidtwco,eddyb): This is a workaround for polymorphization considering // parameters unused if they show up in the signature, but not in the `mir::Body` @@ -53,7 +53,7 @@ fn fn_sig_for_fn_abi<'tcx>( // track of a polymorphization `ParamEnv` to allow normalizing later. // // We normalize the `fn_sig` again after instantiating at a later point. - let mut sig = match *ty.kind() { + let mut sig = match ty.kind() { ty::FnDef(def_id, args) => tcx .fn_sig(def_id) .map_bound(|fn_sig| { @@ -177,7 +177,7 @@ fn fn_sig_for_fn_abi<'tcx>( if let InstanceDef::CoroutineKindShim { .. } = instance.def { // Grab the parent coroutine-closure. It has the same args for the purposes // of instantiation, so this will be okay to do. - let ty::CoroutineClosure(_, coroutine_closure_args) = *tcx + let ty::CoroutineClosure(_, coroutine_closure_args) = tcx .instantiate_and_normalize_erasing_regions( args, param_env, @@ -241,7 +241,7 @@ fn fn_sig_for_fn_abi<'tcx>( if let ty::Adt(resume_ty_adt, _) = sig.resume_ty.kind() { let expected_adt = tcx.adt_def(tcx.require_lang_item(LangItem::ResumeTy, None)); - assert_eq!(*resume_ty_adt, expected_adt); + assert_eq!(resume_ty_adt, expected_adt); } else { panic!("expected `ResumeTy`, found `{:?}`", sig.resume_ty); }; @@ -277,7 +277,7 @@ fn fn_sig_for_fn_abi<'tcx>( if let ty::Adt(resume_ty_adt, _) = sig.resume_ty.kind() { let expected_adt = tcx.adt_def(tcx.require_lang_item(LangItem::ResumeTy, None)); - assert_eq!(*resume_ty_adt, expected_adt); + assert_eq!(resume_ty_adt, expected_adt); } else { panic!("expected `ResumeTy`, found `{:?}`", sig.resume_ty); }; @@ -630,7 +630,7 @@ fn fn_abi_new_uncached<'tcx>( let is_return = arg_idx.is_none(); let is_drop_target = is_drop_in_place && arg_idx == Some(0); let drop_target_pointee = is_drop_target.then(|| match ty.kind() { - ty::RawPtr(ty, _) => *ty, + ty::RawPtr(ty, _) => ty, _ => bug!("argument to drop_in_place is not a raw ptr: {:?}", ty), }); diff --git a/compiler/rustc_ty_utils/src/consts.rs b/compiler/rustc_ty_utils/src/consts.rs index 1aec40e95f699..389bd8c5822f3 100644 --- a/compiler/rustc_ty_utils/src/consts.rs +++ b/compiler/rustc_ty_utils/src/consts.rs @@ -37,7 +37,7 @@ fn destructure_const<'tcx>( // construct the consts for the elements of the array/slice let field_consts = branches .iter() - .map(|b| ty::Const::new_value(tcx, *b, *inner_ty)) + .map(|b| ty::Const::new_value(tcx, *b, inner_ty)) .collect::>(); debug!(?field_consts); @@ -64,7 +64,7 @@ fn destructure_const<'tcx>( (field_consts, Some(variant_idx)) } ty::Tuple(elem_tys) => { - let fields = iter::zip(*elem_tys, branches) + let fields = iter::zip(elem_tys, branches) .map(|(elem_ty, elem_valtree)| ty::Const::new_value(tcx, *elem_valtree, elem_ty)) .collect::>(); diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs index e4dcea785d411..d27a230209aa5 100644 --- a/compiler/rustc_ty_utils/src/instance.rs +++ b/compiler/rustc_ty_utils/src/instance.rs @@ -39,7 +39,7 @@ fn resolve_instance<'tcx>( if ty.needs_drop(tcx, param_env) { debug!(" => nontrivial drop glue"); - match *ty.kind() { + match ty.kind() { ty::Closure(..) | ty::CoroutineClosure(..) | ty::Coroutine(..) @@ -61,7 +61,7 @@ fn resolve_instance<'tcx>( let ty = args.type_at(0); if ty.async_drop_glue_morphology(tcx) != AsyncDropGlueMorphology::Noop { - match *ty.kind() { + match ty.kind() { ty::Closure(..) | ty::CoroutineClosure(..) | ty::Coroutine(..) @@ -280,7 +280,7 @@ fn resolve_associated_item<'tcx>( tcx.item_name(trait_item_id) ) } - match *rcvr_args.type_at(0).kind() { + match rcvr_args.type_at(0).kind() { ty::Closure(closure_def_id, args) => { Some(Instance::resolve_closure(tcx, closure_def_id, args, target_kind)) } @@ -313,7 +313,7 @@ fn resolve_associated_item<'tcx>( } } else if let Some(target_kind) = tcx.async_fn_trait_kind_from_def_id(trait_ref.def_id) { - match *rcvr_args.type_at(0).kind() { + match rcvr_args.type_at(0).kind() { ty::CoroutineClosure(coroutine_closure_def_id, args) => { if target_kind == ClosureKind::FnOnce && args.as_coroutine_closure().kind() != ClosureKind::FnOnce diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index 6045abc50a9da..19dcc85ec3ed7 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -128,7 +128,7 @@ fn layout_of_uncached<'tcx>( }; debug_assert!(!ty.has_non_region_infer()); - Ok(match *ty.kind() { + Ok(match ty.kind() { ty::Pat(ty, pat) => { let layout = cx.layout_of(ty)?.layout; let mut layout = LayoutS::clone(&layout.0); @@ -448,7 +448,7 @@ fn layout_of_uncached<'tcx>( return Err(error(cx, LayoutError::Unknown(ty))); }; - (*e_ty, *count, true) + (e_ty, *count, true) } else { // First ADT field is not an array: (f0_ty, def.non_enum_variant().fields.len() as _, false) @@ -1031,7 +1031,7 @@ fn record_layout_for_printing<'tcx>(cx: &LayoutCx<'tcx, TyCtxt<'tcx>>, layout: T ); }; - match *layout.ty.kind() { + match layout.ty.kind() { ty::Adt(adt_def, _) => { debug!("print-type-size t: `{:?}` process adt", layout.ty); let adt_kind = adt_def.adt_kind(); diff --git a/compiler/rustc_ty_utils/src/needs_drop.rs b/compiler/rustc_ty_utils/src/needs_drop.rs index 205b3f2760f36..291b728cc60a6 100644 --- a/compiler/rustc_ty_utils/src/needs_drop.rs +++ b/compiler/rustc_ty_utils/src/needs_drop.rs @@ -54,7 +54,7 @@ fn filter_array_elements<'tcx>( param_env: ty::ParamEnv<'tcx>, ) -> impl Fn(&Result, AlwaysRequiresDrop>) -> bool { move |ty| match ty { - Ok(ty) => match *ty.kind() { + Ok(ty) => match ty.kind() { ty::Array(elem, _) => tcx.needs_drop_raw(param_env.and(elem)), _ => true, }, @@ -150,7 +150,7 @@ where }; for component in components { - match *component.kind() { + match component.kind() { // The information required to determine whether a coroutine has drop is // computed on MIR, while this very method is used to build MIR. // To avoid cycles, we consider that coroutines always require drop. diff --git a/compiler/rustc_ty_utils/src/opaque_types.rs b/compiler/rustc_ty_utils/src/opaque_types.rs index 686f2f04ad9a7..3f5a196ce480a 100644 --- a/compiler/rustc_ty_utils/src/opaque_types.rs +++ b/compiler/rustc_ty_utils/src/opaque_types.rs @@ -207,7 +207,7 @@ impl<'tcx> TypeVisitor> for OpaqueTypeCollector<'tcx> { #[instrument(skip(self), ret, level = "trace")] fn visit_ty(&mut self, t: Ty<'tcx>) { t.super_visit_with(self); - match *t.kind() { + match t.kind() { ty::Alias(ty::Opaque, alias_ty) if alias_ty.def_id.is_local() => { self.visit_opaque_ty(alias_ty); } @@ -281,7 +281,7 @@ impl<'tcx> TypeVisitor> for OpaqueTypeCollector<'tcx> { // assumption to the `param_env` of the default method. We also separately // rely on that assumption here. let ty = self.tcx.type_of(alias_ty.def_id).instantiate(self.tcx, alias_ty.args); - let ty::Alias(ty::Opaque, alias_ty) = *ty.kind() else { bug!("{ty:?}") }; + let ty::Alias(ty::Opaque, alias_ty) = ty.kind() else { bug!("{ty:?}") }; self.visit_opaque_ty(alias_ty); } } diff --git a/compiler/rustc_ty_utils/src/representability.rs b/compiler/rustc_ty_utils/src/representability.rs index 0ffb7f624965e..18143ef9c8b8d 100644 --- a/compiler/rustc_ty_utils/src/representability.rs +++ b/compiler/rustc_ty_utils/src/representability.rs @@ -35,7 +35,7 @@ fn representability(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Representability { } fn representability_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Representability { - match *ty.kind() { + match ty.kind() { ty::Adt(..) => tcx.representability_adt_ty(ty), // FIXME(#11924) allow zero-length arrays? ty::Array(ty, _) => representability_ty(tcx, ty), @@ -100,7 +100,7 @@ fn params_in_repr(tcx: TyCtxt<'_>, def_id: LocalDefId) -> BitSet { } fn params_in_repr_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, params_in_repr: &mut BitSet) { - match *ty.kind() { + match ty.kind() { ty::Adt(adt, args) => { let inner_params_in_repr = tcx.params_in_repr(adt.did()); for (i, arg) in args.iter().enumerate() { diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index 38950c97c9d58..92f468b9758c9 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -38,7 +38,7 @@ fn sized_constraint_for_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option Some(ty), - Pat(ty, _) => sized_constraint_for_ty(tcx, *ty), + Pat(ty, _) => sized_constraint_for_ty(tcx, ty), Tuple(tys) => tys.last().and_then(|&ty| sized_constraint_for_ty(tcx, ty)), @@ -179,7 +179,7 @@ impl<'tcx> TypeVisitor> for ImplTraitInTraitFinder<'_, 'tcx> { } fn visit_ty(&mut self, ty: Ty<'tcx>) { - if let ty::Alias(ty::Projection, unshifted_alias_ty) = *ty.kind() + if let ty::Alias(ty::Projection, unshifted_alias_ty) = ty.kind() && let Some( ty::ImplTraitInTraitData::Trait { fn_def_id, .. } | ty::ImplTraitInTraitData::Impl { fn_def_id, .. }, diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index d4e28927728f4..cc0bfca23638d 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1353,7 +1353,7 @@ pub(crate) fn clean_middle_assoc_item<'tcx>( tcx.fn_sig(assoc_item.def_id).instantiate_identity().input(0).skip_binder(); if self_arg_ty == self_ty { item.decl.inputs.values[0].type_ = Generic(kw::SelfUpper); - } else if let ty::Ref(_, ty, _) = *self_arg_ty.kind() { + } else if let ty::Ref(_, ty, _) = self_arg_ty.kind() { if ty == self_ty { match item.decl.inputs.values[0].type_ { BorrowedRef { ref mut type_, .. } => **type_ = Generic(kw::SelfUpper), @@ -2028,7 +2028,7 @@ pub(crate) fn clean_middle_ty<'tcx>( container: Option>, ) -> Type { let bound_ty = normalize(cx, bound_ty).unwrap_or(bound_ty); - match *bound_ty.skip_binder().kind() { + match bound_ty.skip_binder().kind() { ty::Never => Primitive(PrimitiveType::Never), ty::Bool => Primitive(PrimitiveType::Bool), ty::Char => Primitive(PrimitiveType::Char), @@ -2386,7 +2386,7 @@ pub(crate) fn clean_variant_def<'tcx>(variant: &ty::VariantDef, cx: &mut DocCont pub(crate) fn clean_variant_def_with_args<'tcx>( variant: &ty::VariantDef, - args: &GenericArgsRef<'tcx>, + args: GenericArgsRef<'tcx>, // njn: removed `&` cx: &mut DocContext<'tcx>, ) -> Item { let discriminant = match variant.discr { diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 7fc3d4508d7dd..73899ff87f84e 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -354,7 +354,7 @@ pub(crate) fn print_const(cx: &DocContext<'_>, n: ty::Const<'_>) -> String { } // array lengths are obviously usize ty::ConstKind::Value(ty, ty::ValTree::Leaf(scalar)) - if *ty.kind() == ty::Uint(ty::UintTy::Usize) => + if ty.kind() == ty::Uint(ty::UintTy::Usize) => { scalar.to_string() } @@ -371,8 +371,8 @@ pub(crate) fn print_evaluated_const( tcx.const_eval_poly(def_id).ok().and_then(|val| { let ty = tcx.type_of(def_id).instantiate_identity(); match (val, ty.kind()) { - (_, &ty::Ref(..)) => None, - (mir::ConstValue::Scalar(_), &ty::Adt(_, _)) => None, + (_, ty::Ref(..)) => None, + (mir::ConstValue::Scalar(_), ty::Adt(_, _)) => None, (mir::ConstValue::Scalar(_), _) => { let const_ = mir::Const::from_value(val, ty); Some(print_const_with_custom_print_scalar(tcx, const_, with_underscores, with_type)) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 8ab24a8c12e58..3b9f96464243e 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -482,7 +482,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { /// This is used for resolving type aliases. fn def_id_to_res(&self, ty_id: DefId) -> Option { use PrimitiveType::*; - Some(match *self.cx.tcx.type_of(ty_id).instantiate_identity().kind() { + Some(match self.cx.tcx.type_of(ty_id).instantiate_identity().kind() { ty::Bool => Res::Primitive(Bool), ty::Char => Res::Primitive(Char), ty::Int(ity) => Res::Primitive(ity.into()), diff --git a/src/librustdoc/scrape_examples.rs b/src/librustdoc/scrape_examples.rs index 64753a58a2bff..2735f4d12783e 100644 --- a/src/librustdoc/scrape_examples.rs +++ b/src/librustdoc/scrape_examples.rs @@ -247,7 +247,7 @@ where CallData { locations: Vec::new(), url, display_name, edition, is_bin } }; - let fn_key = tcx.def_path_hash(*def_id); + let fn_key = tcx.def_path_hash(def_id); let fn_entries = self.calls.entry(fn_key).or_default(); trace!("Including expr: {call_span:?}"); diff --git a/src/tools/clippy/clippy_lints/src/borrow_deref_ref.rs b/src/tools/clippy/clippy_lints/src/borrow_deref_ref.rs index 0ca4a0e067d36..bf8e612f6c6ad 100644 --- a/src/tools/clippy/clippy_lints/src/borrow_deref_ref.rs +++ b/src/tools/clippy/clippy_lints/src/borrow_deref_ref.rs @@ -94,7 +94,7 @@ impl<'tcx> LateLintPass<'tcx> for BorrowDerefRef { // has deref trait -> give 2 help // doesn't have deref trait -> give 1 help if let Some(deref_trait_id) = cx.tcx.lang_items().deref_trait() { - if !implements_trait(cx, *inner_ty, deref_trait_id, &[]) { + if !implements_trait(cx, inner_ty, deref_trait_id, &[]) { return; } } diff --git a/src/tools/clippy/clippy_lints/src/casts/cast_possible_truncation.rs b/src/tools/clippy/clippy_lints/src/casts/cast_possible_truncation.rs index 7c5acd1a678d7..a7a38b7e1a489 100644 --- a/src/tools/clippy/clippy_lints/src/casts/cast_possible_truncation.rs +++ b/src/tools/clippy/clippy_lints/src/casts/cast_possible_truncation.rs @@ -127,10 +127,10 @@ pub(super) fn check( { let i = def.variant_index_with_ctor_id(id); let variant = def.variant(i); - let nbits = utils::enum_value_nbits(get_discriminant_value(cx.tcx, *def, i)); + let nbits = utils::enum_value_nbits(get_discriminant_value(cx.tcx, def, i)); (nbits, Some(variant)) } else { - (utils::enum_ty_to_nbits(*def, cx.tcx), None) + (utils::enum_ty_to_nbits(def, cx.tcx), None) }; let to_nbits = utils::int_ty_to_nbits(cast_to, cx.tcx); @@ -161,7 +161,7 @@ pub(super) fn check( format!("casting `{cast_from}` to `{cast_to}` may truncate the value") }, - (ty::Float(FloatTy::F64), false) if matches!(cast_to.kind(), &ty::Float(FloatTy::F32)) => { + (ty::Float(FloatTy::F64), false) if matches!(cast_to.kind(), ty::Float(FloatTy::F32)) => { "casting `f64` to `f32` may truncate the value".to_string() }, diff --git a/src/tools/clippy/clippy_lints/src/casts/cast_precision_loss.rs b/src/tools/clippy/clippy_lints/src/casts/cast_precision_loss.rs index 035666e4d4c92..25047acc378db 100644 --- a/src/tools/clippy/clippy_lints/src/casts/cast_precision_loss.rs +++ b/src/tools/clippy/clippy_lints/src/casts/cast_precision_loss.rs @@ -12,7 +12,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, ca } let from_nbits = utils::int_ty_to_nbits(cast_from, cx.tcx); - let to_nbits = if cast_to.kind() == &ty::Float(FloatTy::F32) { + let to_nbits = if cast_to.kind() == ty::Float(FloatTy::F32) { 32 } else { 64 diff --git a/src/tools/clippy/clippy_lints/src/casts/cast_ptr_alignment.rs b/src/tools/clippy/clippy_lints/src/casts/cast_ptr_alignment.rs index 960c81045e36f..8da93afbdccaf 100644 --- a/src/tools/clippy/clippy_lints/src/casts/cast_ptr_alignment.rs +++ b/src/tools/clippy/clippy_lints/src/casts/cast_ptr_alignment.rs @@ -33,8 +33,8 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) { } fn lint_cast_ptr_alignment<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, cast_from: Ty<'tcx>, cast_to: Ty<'tcx>) { - if let ty::RawPtr(from_ptr_ty, _) = *cast_from.kind() - && let ty::RawPtr(to_ptr_ty, _) = *cast_to.kind() + if let ty::RawPtr(from_ptr_ty, _) = cast_from.kind() + && let ty::RawPtr(to_ptr_ty, _) = cast_to.kind() && let Ok(from_layout) = cx.layout_of(from_ptr_ty) && let Ok(to_layout) = cx.layout_of(to_ptr_ty) && from_layout.align.abi < to_layout.align.abi diff --git a/src/tools/clippy/clippy_lints/src/casts/cast_sign_loss.rs b/src/tools/clippy/clippy_lints/src/casts/cast_sign_loss.rs index 864489ee3fcd5..697070c173217 100644 --- a/src/tools/clippy/clippy_lints/src/casts/cast_sign_loss.rs +++ b/src/tools/clippy/clippy_lints/src/casts/cast_sign_loss.rs @@ -89,7 +89,7 @@ fn get_const_signed_int_eval<'cx>( let ty = ty.into().unwrap_or_else(|| cx.typeck_results().expr_ty(expr)); if let Constant::Int(n) = constant(cx, cx.typeck_results(), expr)? - && let ty::Int(ity) = *ty.kind() + && let ty::Int(ity) = ty.kind() { return Some(sext(cx.tcx, n, ity)); } @@ -104,7 +104,7 @@ fn get_const_unsigned_int_eval<'cx>( let ty = ty.into().unwrap_or_else(|| cx.typeck_results().expr_ty(expr)); if let Constant::Int(n) = constant(cx, cx.typeck_results(), expr)? - && let ty::Uint(_ity) = *ty.kind() + && let ty::Uint(_ity) = ty.kind() { return Some(n); } diff --git a/src/tools/clippy/clippy_lints/src/casts/cast_slice_different_sizes.rs b/src/tools/clippy/clippy_lints/src/casts/cast_slice_different_sizes.rs index 285f0357112ba..31501505e34ce 100644 --- a/src/tools/clippy/clippy_lints/src/casts/cast_slice_different_sizes.rs +++ b/src/tools/clippy/clippy_lints/src/casts/cast_slice_different_sizes.rs @@ -88,7 +88,7 @@ fn is_child_of_cast(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { fn get_raw_slice_ty_mut(ty: Ty<'_>) -> Option> { match ty.kind() { ty::RawPtr(slice_ty, mutbl) => match slice_ty.kind() { - ty::Slice(ty) => Some(TypeAndMut { ty: *ty, mutbl: *mutbl }), + ty::Slice(ty) => Some(TypeAndMut { ty, mutbl }), _ => None, }, _ => None, diff --git a/src/tools/clippy/clippy_lints/src/casts/char_lit_as_u8.rs b/src/tools/clippy/clippy_lints/src/casts/char_lit_as_u8.rs index a7d3868f76c60..22e7e4c216fc8 100644 --- a/src/tools/clippy/clippy_lints/src/casts/char_lit_as_u8.rs +++ b/src/tools/clippy/clippy_lints/src/casts/char_lit_as_u8.rs @@ -12,7 +12,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) { if let ExprKind::Cast(e, _) = &expr.kind && let ExprKind::Lit(l) = &e.kind && let LitKind::Char(c) = l.node - && ty::Uint(UintTy::U8) == *cx.typeck_results().expr_ty(expr).kind() + && ty::Uint(UintTy::U8) == cx.typeck_results().expr_ty(expr).kind() { let mut applicability = Applicability::MachineApplicable; let snippet = snippet_with_applicability(cx, e.span, "'x'", &mut applicability); diff --git a/src/tools/clippy/clippy_lints/src/casts/fn_to_numeric_cast.rs b/src/tools/clippy/clippy_lints/src/casts/fn_to_numeric_cast.rs index f263bec1576d0..7d84d13359e4b 100644 --- a/src/tools/clippy/clippy_lints/src/casts/fn_to_numeric_cast.rs +++ b/src/tools/clippy/clippy_lints/src/casts/fn_to_numeric_cast.rs @@ -20,7 +20,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, let from_snippet = snippet_with_applicability(cx, cast_expr.span, "x", &mut applicability); let to_nbits = utils::int_ty_to_nbits(cast_to, cx.tcx); - if (to_nbits >= cx.tcx.data_layout.pointer_size.bits()) && (*cast_to.kind() != ty::Uint(UintTy::Usize)) { + if (to_nbits >= cx.tcx.data_layout.pointer_size.bits()) && (cast_to.kind() != ty::Uint(UintTy::Usize)) { span_lint_and_sugg( cx, FN_TO_NUMERIC_CAST, diff --git a/src/tools/clippy/clippy_lints/src/casts/ptr_cast_constness.rs b/src/tools/clippy/clippy_lints/src/casts/ptr_cast_constness.rs index 921693567fcd4..e5b8f6f96b171 100644 --- a/src/tools/clippy/clippy_lints/src/casts/ptr_cast_constness.rs +++ b/src/tools/clippy/clippy_lints/src/casts/ptr_cast_constness.rs @@ -26,7 +26,7 @@ pub(super) fn check<'tcx>( && from_ty == to_ty { let sugg = Sugg::hir(cx, cast_expr, "_"); - let constness = match *to_mutbl { + let constness = match to_mutbl { Mutability::Not => "const", Mutability::Mut => "mut", }; diff --git a/src/tools/clippy/clippy_lints/src/default.rs b/src/tools/clippy/clippy_lints/src/default.rs index 2b3f4854255cf..bd550b0e859ac 100644 --- a/src/tools/clippy/clippy_lints/src/default.rs +++ b/src/tools/clippy/clippy_lints/src/default.rs @@ -131,7 +131,7 @@ impl<'tcx> LateLintPass<'tcx> for Default { // only when assigning `... = Default::default()` && is_expr_default(expr, cx) && let binding_type = cx.typeck_results().node_type(binding_id) - && let ty::Adt(adt, args) = *binding_type.kind() + && let ty::Adt(adt, args) = binding_type.kind() && adt.is_struct() && let variant = adt.non_enum_variant() && (adt.did().is_local() || !variant.is_field_list_non_exhaustive()) diff --git a/src/tools/clippy/clippy_lints/src/default_numeric_fallback.rs b/src/tools/clippy/clippy_lints/src/default_numeric_fallback.rs index ff631909bcb58..c0e6439782ebf 100644 --- a/src/tools/clippy/clippy_lints/src/default_numeric_fallback.rs +++ b/src/tools/clippy/clippy_lints/src/default_numeric_fallback.rs @@ -234,8 +234,8 @@ fn fn_sig_opt<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option Some(cx.tcx.fn_sig(*def_id).instantiate_identity()), - ty::FnPtr(fn_sig) => Some(*fn_sig), + ty::FnDef(def_id, _) => Some(cx.tcx.fn_sig(def_id).instantiate_identity()), + ty::FnPtr(fn_sig) => Some(fn_sig), _ => None, } } diff --git a/src/tools/clippy/clippy_lints/src/dereference.rs b/src/tools/clippy/clippy_lints/src/dereference.rs index d60320d828253..3a1c9b5d0834a 100644 --- a/src/tools/clippy/clippy_lints/src/dereference.rs +++ b/src/tools/clippy/clippy_lints/src/dereference.rs @@ -366,7 +366,7 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing<'tcx> { && let arg_ty = cx .tcx .erase_regions(use_cx.adjustments.last().map_or(expr_ty, |a| a.target)) - && let ty::Ref(_, sub_ty, _) = *arg_ty.kind() + && let ty::Ref(_, sub_ty, _) = arg_ty.kind() && let args = typeck.node_args_opt(hir_id).map(|args| &args[1..]).unwrap_or_default() && let impl_ty = @@ -622,9 +622,9 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing<'tcx> { } if !pat.span.from_expansion() - && let ty::Ref(_, tam, _) = *cx.typeck_results().pat_ty(pat).kind() + && let ty::Ref(_, tam, _) = cx.typeck_results().pat_ty(pat).kind() // only lint immutable refs, because borrowed `&mut T` cannot be moved out - && let ty::Ref(_, _, Mutability::Not) = *tam.kind() + && let ty::Ref(_, _, Mutability::Not) = tam.kind() { let mut app = Applicability::MachineApplicable; let snip = snippet_with_context(cx, name.span, pat.span.ctxt(), "..", &mut app).0; @@ -839,13 +839,13 @@ impl TyCoercionStability { } fn for_mir_ty<'tcx>(tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>, ty: Ty<'tcx>, for_return: bool) -> Self { - let ty::Ref(_, mut ty, _) = *ty.kind() else { + let ty::Ref(_, mut ty, _) = ty.kind() else { return Self::None; }; ty = tcx.try_normalize_erasing_regions(param_env, ty).unwrap_or(ty); loop { - break match *ty.kind() { + break match ty.kind() { ty::Ref(_, ref_ty, _) => { ty = ref_ty; continue; @@ -925,7 +925,7 @@ fn ty_contains_infer(ty: &hir::Ty<'_>) -> bool { } fn ty_contains_field(ty: Ty<'_>, name: Symbol) -> bool { - if let ty::Adt(adt, _) = *ty.kind() { + if let ty::Adt(adt, _) = ty.kind() { adt.is_struct() && adt.all_fields().any(|f| f.name == name) } else { false diff --git a/src/tools/clippy/clippy_lints/src/derivable_impls.rs b/src/tools/clippy/clippy_lints/src/derivable_impls.rs index 0c9ad5e8d0015..a2bb8791b9851 100644 --- a/src/tools/clippy/clippy_lints/src/derivable_impls.rs +++ b/src/tools/clippy/clippy_lints/src/derivable_impls.rs @@ -78,7 +78,7 @@ fn is_path_self(e: &Expr<'_>) -> bool { fn contains_trait_object(ty: Ty<'_>) -> bool { match ty.kind() { - ty::Ref(_, ty, _) => contains_trait_object(*ty), + ty::Ref(_, ty, _) => contains_trait_object(ty), ty::Adt(def, args) => def.is_box() && args[0].as_type().map_or(false, contains_trait_object), ty::Dynamic(..) => true, _ => false, @@ -198,7 +198,7 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls { && let Node::ImplItem(impl_item) = cx.tcx.hir_node(impl_item_hir) && let ImplItemKind::Fn(_, b) = &impl_item.kind && let Body { value: func_expr, .. } = cx.tcx.hir().body(*b) - && let &ty::Adt(adt_def, args) = cx.tcx.type_of(item.owner_id).instantiate_identity().kind() + && let ty::Adt(adt_def, args) = cx.tcx.type_of(item.owner_id).instantiate_identity().kind() && let attrs = cx.tcx.hir().attrs(item.hir_id()) && !attrs.iter().any(|attr| attr.doc_str().is_some()) && cx.tcx.hir().attrs(impl_item_hir).is_empty() diff --git a/src/tools/clippy/clippy_lints/src/derive.rs b/src/tools/clippy/clippy_lints/src/derive.rs index 636698e96f6d1..0d9f90a222b48 100644 --- a/src/tools/clippy/clippy_lints/src/derive.rs +++ b/src/tools/clippy/clippy_lints/src/derive.rs @@ -316,7 +316,7 @@ fn check_copy_clone<'tcx>(cx: &LateContext<'tcx>, item: &Item<'_>, trait_ref: &h let Some(copy_id) = cx.tcx.lang_items().copy_trait() else { return; }; - let (ty_adt, ty_subs) = match *ty.kind() { + let (ty_adt, ty_subs) = match ty.kind() { // Unions can't derive clone. ty::Adt(adt, subs) if !adt.is_union() => (adt, subs), _ => return, @@ -453,7 +453,7 @@ fn check_partial_eq_without_eq<'tcx>(cx: &LateContext<'tcx>, span: Span, trait_r && let Some(eq_trait_def_id) = cx.tcx.get_diagnostic_item(sym::Eq) && let Some(def_id) = trait_ref.trait_def_id() && cx.tcx.is_diagnostic_item(sym::PartialEq, def_id) - && !has_non_exhaustive_attr(cx.tcx, *adt) + && !has_non_exhaustive_attr(cx.tcx, adt) && !ty_implements_eq_trait(cx.tcx, ty, eq_trait_def_id) && let param_env = param_env_for_derived_eq(cx.tcx, adt.did(), eq_trait_def_id) && let Some(local_def_id) = adt.did().as_local() diff --git a/src/tools/clippy/clippy_lints/src/eta_reduction.rs b/src/tools/clippy/clippy_lints/src/eta_reduction.rs index 48c4c4206fe88..5158b5aaf950d 100644 --- a/src/tools/clippy/clippy_lints/src/eta_reduction.rs +++ b/src/tools/clippy/clippy_lints/src/eta_reduction.rs @@ -137,7 +137,7 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction { let sig = match callee_ty_adjusted.kind() { ty::FnDef(def, _) => { // Rewriting `x(|| f())` to `x(f)` where f is marked `#[track_caller]` moves the `Location` - if cx.tcx.has_attr(*def, sym::track_caller) { + if cx.tcx.has_attr(def, sym::track_caller) { return; } @@ -152,7 +152,7 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction { if typeck.type_dependent_def_id(body.value.hir_id).is_some() && let subs = typeck.node_args(body.value.hir_id) && let output = typeck.expr_ty(body.value) - && let ty::Tuple(tys) = *subs.type_at(1).kind() + && let ty::Tuple(tys) = subs.type_at(1).kind() { cx.tcx.mk_fn_sig(tys, output, false, Safety::Safe, Abi::Rust) } else { @@ -282,14 +282,14 @@ fn has_late_bound_to_non_late_bound_regions(from_sig: FnSig<'_>, to_sig: FnSig<' fn check_ty(from_ty: Ty<'_>, to_ty: Ty<'_>) -> bool { match (from_ty.kind(), to_ty.kind()) { - (&ty::Adt(_, from_subs), &ty::Adt(_, to_subs)) => check_subs(from_subs, to_subs), - (&ty::Array(from_ty, _), &ty::Array(to_ty, _)) | (&ty::Slice(from_ty), &ty::Slice(to_ty)) => { + (ty::Adt(_, from_subs), ty::Adt(_, to_subs)) => check_subs(from_subs, to_subs), + (ty::Array(from_ty, _), ty::Array(to_ty, _)) | (ty::Slice(from_ty), ty::Slice(to_ty)) => { check_ty(from_ty, to_ty) }, - (&ty::Ref(from_region, from_ty, _), &ty::Ref(to_region, to_ty, _)) => { + (ty::Ref(from_region, from_ty, _), ty::Ref(to_region, to_ty, _)) => { check_region(from_region, to_region) || check_ty(from_ty, to_ty) }, - (&ty::Tuple(from_tys), &ty::Tuple(to_tys)) => { + (ty::Tuple(from_tys), ty::Tuple(to_tys)) => { from_tys.len() != to_tys.len() || from_tys .iter() diff --git a/src/tools/clippy/clippy_lints/src/float_literal.rs b/src/tools/clippy/clippy_lints/src/float_literal.rs index 4ec9bd757ff45..54af3dc3c8344 100644 --- a/src/tools/clippy/clippy_lints/src/float_literal.rs +++ b/src/tools/clippy/clippy_lints/src/float_literal.rs @@ -63,7 +63,7 @@ declare_lint_pass!(FloatLiteral => [EXCESSIVE_PRECISION, LOSSY_FLOAT_LITERAL]); impl<'tcx> LateLintPass<'tcx> for FloatLiteral { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) { let ty = cx.typeck_results().expr_ty(expr); - if let ty::Float(fty) = *ty.kind() + if let ty::Float(fty) = ty.kind() && let hir::ExprKind::Lit(lit) = expr.kind && let LitKind::Float(sym, lit_float_ty) = lit.node { diff --git a/src/tools/clippy/clippy_lints/src/from_raw_with_void_ptr.rs b/src/tools/clippy/clippy_lints/src/from_raw_with_void_ptr.rs index d62d008d480f7..c08683a5848ef 100644 --- a/src/tools/clippy/clippy_lints/src/from_raw_with_void_ptr.rs +++ b/src/tools/clippy/clippy_lints/src/from_raw_with_void_ptr.rs @@ -45,7 +45,7 @@ impl LateLintPass<'_> for FromRawWithVoidPtr { && let Some(type_str) = path_def_id(cx, ty).and_then(|id| def_id_matches_type(cx, id)) && let arg_kind = cx.typeck_results().expr_ty(arg).kind() && let ty::RawPtr(ty, _) = arg_kind - && is_c_void(cx, *ty) + && is_c_void(cx, ty) { let msg = format!("creating a `{type_str}` from a void raw pointer"); span_lint_and_help( diff --git a/src/tools/clippy/clippy_lints/src/functions/must_use.rs b/src/tools/clippy/clippy_lints/src/functions/must_use.rs index e7ec2b3151e6a..345bf79cf6942 100644 --- a/src/tools/clippy/clippy_lints/src/functions/must_use.rs +++ b/src/tools/clippy/clippy_lints/src/functions/must_use.rs @@ -195,7 +195,7 @@ fn is_mutable_pat(cx: &LateContext<'_>, pat: &hir::Pat<'_>, tys: &mut DefIdSet) static KNOWN_WRAPPER_TYS: &[Symbol] = &[sym::Rc, sym::Arc]; fn is_mutable_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, tys: &mut DefIdSet) -> bool { - match *ty.kind() { + match ty.kind() { // primitive types are never mutable ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Str => false, ty::Adt(adt, args) => { diff --git a/src/tools/clippy/clippy_lints/src/functions/not_unsafe_ptr_arg_deref.rs b/src/tools/clippy/clippy_lints/src/functions/not_unsafe_ptr_arg_deref.rs index b44a5f20ef68e..8d881a41bdebb 100644 --- a/src/tools/clippy/clippy_lints/src/functions/not_unsafe_ptr_arg_deref.rs +++ b/src/tools/clippy/clippy_lints/src/functions/not_unsafe_ptr_arg_deref.rs @@ -75,7 +75,7 @@ fn check_raw_ptr<'tcx>( } fn raw_ptr_arg(cx: &LateContext<'_>, arg: &hir::Param<'_>) -> Option { - if let (&hir::PatKind::Binding(_, id, _, _), Some(&ty::RawPtr(_, _))) = ( + if let (&hir::PatKind::Binding(_, id, _, _), Some(ty::RawPtr(_, _))) = ( &arg.pat.kind, cx.maybe_typeck_results() .map(|typeck_results| typeck_results.pat_ty(arg.pat).kind()), diff --git a/src/tools/clippy/clippy_lints/src/functions/result.rs b/src/tools/clippy/clippy_lints/src/functions/result.rs index c3a0b40a677aa..464c17b0b1e90 100644 --- a/src/tools/clippy/clippy_lints/src/functions/result.rs +++ b/src/tools/clippy/clippy_lints/src/functions/result.rs @@ -95,7 +95,7 @@ fn check_result_large_err<'tcx>(cx: &LateContext<'tcx>, err_ty: Ty<'tcx>, hir_ty && let hir::Node::Item(item) = cx.tcx.hir_node_by_def_id(local_def_id) && let hir::ItemKind::Enum(ref def, _) = item.kind { - let variants_size = AdtVariantInfo::new(cx, *adt, subst); + let variants_size = AdtVariantInfo::new(cx, adt, subst); if let Some((first_variant, variants)) = variants_size.split_first() && first_variant.size >= large_err_threshold { diff --git a/src/tools/clippy/clippy_lints/src/future_not_send.rs b/src/tools/clippy/clippy_lints/src/future_not_send.rs index cb1d0de1edff9..a570038c1fd61 100644 --- a/src/tools/clippy/clippy_lints/src/future_not_send.rs +++ b/src/tools/clippy/clippy_lints/src/future_not_send.rs @@ -64,7 +64,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend { return; } let ret_ty = return_ty(cx, cx.tcx.local_def_id_to_hir_id(fn_def_id).expect_owner()); - if let ty::Alias(ty::Opaque, AliasTy { def_id, args, .. }) = *ret_ty.kind() { + if let ty::Alias(ty::Opaque, AliasTy { def_id, args, .. }) = ret_ty.kind() { let preds = cx.tcx.explicit_item_super_predicates(def_id); let mut is_future = false; for (p, _span) in preds.iter_instantiated_copied(cx.tcx, args) { diff --git a/src/tools/clippy/clippy_lints/src/implied_bounds_in_impls.rs b/src/tools/clippy/clippy_lints/src/implied_bounds_in_impls.rs index 2b389d4f9b194..97fd4dedc6fb2 100644 --- a/src/tools/clippy/clippy_lints/src/implied_bounds_in_impls.rs +++ b/src/tools/clippy/clippy_lints/src/implied_bounds_in_impls.rs @@ -200,7 +200,7 @@ fn is_same_generics<'tcx>( return true; } if let Some(ty) = arg.as_type() { - if let &ty::Param(ty::ParamTy { index, .. }) = ty.kind() + if let ty::Param(ty::ParamTy { index, .. }) = ty.kind() // `index == 0` means that it's referring to `Self`, // in which case we don't try to substitute it && index != 0 diff --git a/src/tools/clippy/clippy_lints/src/index_refutable_slice.rs b/src/tools/clippy/clippy_lints/src/index_refutable_slice.rs index 128461ce7bcf3..e80d576960658 100644 --- a/src/tools/clippy/clippy_lints/src/index_refutable_slice.rs +++ b/src/tools/clippy/clippy_lints/src/index_refutable_slice.rs @@ -114,7 +114,7 @@ fn find_slice_values(cx: &LateContext<'_>, pat: &hir::Pat<'_>) -> FxIndexMap LateLintPass<'tcx> for IndexingSlicing { if let Constant::Int(off) = constant && off <= usize::MAX as u128 && let ty::Uint(utype) = cx.typeck_results().expr_ty(index).kind() - && *utype == ty::UintTy::Usize + && utype == ty::UintTy::Usize && let ty::Array(_, s) = ty.kind() && let Some(size) = s.try_eval_target_usize(cx.tcx, cx.param_env) { diff --git a/src/tools/clippy/clippy_lints/src/iter_without_into_iter.rs b/src/tools/clippy/clippy_lints/src/iter_without_into_iter.rs index 601d0e151aae8..ab16afc530c3a 100644 --- a/src/tools/clippy/clippy_lints/src/iter_without_into_iter.rs +++ b/src/tools/clippy/clippy_lints/src/iter_without_into_iter.rs @@ -160,7 +160,7 @@ impl LateLintPass<'_> for IterWithoutIntoIter { && trait_ref .trait_def_id() .is_some_and(|did| cx.tcx.is_diagnostic_item(sym::IntoIterator, did)) - && let &ty::Ref(_, ty, mtbl) = cx.tcx.type_of(item.owner_id).instantiate_identity().kind() + && let ty::Ref(_, ty, mtbl) = cx.tcx.type_of(item.owner_id).instantiate_identity().kind() && let expected_method_name = match mtbl { Mutability::Mut => sym::iter_mut, Mutability::Not => sym::iter, diff --git a/src/tools/clippy/clippy_lints/src/large_const_arrays.rs b/src/tools/clippy/clippy_lints/src/large_const_arrays.rs index 77d05020c8282..70a5aae995ecf 100644 --- a/src/tools/clippy/clippy_lints/src/large_const_arrays.rs +++ b/src/tools/clippy/clippy_lints/src/large_const_arrays.rs @@ -56,7 +56,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeConstArrays { && let ty::Array(element_type, cst) = ty.kind() && let ConstKind::Value(_, ty::ValTree::Leaf(element_count)) = cst.kind() && let Ok(element_count) = element_count.try_to_target_usize(cx.tcx) - && let Ok(element_size) = cx.layout_of(*element_type).map(|l| l.size.bytes()) + && let Ok(element_size) = cx.layout_of(element_type).map(|l| l.size.bytes()) && self.maximum_allowed_size < u128::from(element_count) * u128::from(element_size) { let hi_pos = item.ident.span.lo() - BytePos::from_usize(1); diff --git a/src/tools/clippy/clippy_lints/src/large_enum_variant.rs b/src/tools/clippy/clippy_lints/src/large_enum_variant.rs index 0bf7389ef9cc8..c8801c50ed49a 100644 --- a/src/tools/clippy/clippy_lints/src/large_enum_variant.rs +++ b/src/tools/clippy/clippy_lints/src/large_enum_variant.rs @@ -88,7 +88,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeEnumVariant { if adt.variants().len() <= 1 { return; } - let variants_size = AdtVariantInfo::new(cx, *adt, subst); + let variants_size = AdtVariantInfo::new(cx, adt, subst); let mut difference = variants_size[0].size - variants_size[1].size; if difference > self.maximum_size_difference_allowed { diff --git a/src/tools/clippy/clippy_lints/src/large_stack_arrays.rs b/src/tools/clippy/clippy_lints/src/large_stack_arrays.rs index f0f3f53647b94..db2ed9871747e 100644 --- a/src/tools/clippy/clippy_lints/src/large_stack_arrays.rs +++ b/src/tools/clippy/clippy_lints/src/large_stack_arrays.rs @@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeStackArrays { && let ty::Array(element_type, cst) = cx.typeck_results().expr_ty(expr).kind() && let ConstKind::Value(_, ty::ValTree::Leaf(element_count)) = cst.kind() && let Ok(element_count) = element_count.try_to_target_usize(cx.tcx) - && let Ok(element_size) = cx.layout_of(*element_type).map(|l| l.size.bytes()) + && let Ok(element_size) = cx.layout_of(element_type).map(|l| l.size.bytes()) && !cx.tcx.hir().parent_iter(expr.hir_id).any(|(_, node)| { matches!( node, diff --git a/src/tools/clippy/clippy_lints/src/len_zero.rs b/src/tools/clippy/clippy_lints/src/len_zero.rs index 57e0a7aa2c7e9..46e5e97a57664 100644 --- a/src/tools/clippy/clippy_lints/src/len_zero.rs +++ b/src/tools/clippy/clippy_lints/src/len_zero.rs @@ -360,7 +360,7 @@ fn parse_len_output<'tcx>(cx: &LateContext<'tcx>, sig: FnSig<'tcx>) -> Option Some(LenOutput::Integral), ty::Adt(adt, subs) if cx.tcx.is_diagnostic_item(sym::Option, adt.did()) => { subs.type_at(0).is_integral().then(|| LenOutput::Option(adt.did())) @@ -384,9 +384,9 @@ impl LenOutput { } match (self, ty.kind()) { - (_, &ty::Bool) => true, - (Self::Option(id), &ty::Adt(adt, subs)) if id == adt.did() => subs.type_at(0).is_bool(), - (Self::Result(id), &ty::Adt(adt, subs)) if id == adt.did() => subs.type_at(0).is_bool(), + (_, ty::Bool) => true, + (Self::Option(id), ty::Adt(adt, subs)) if id == adt.did() => subs.type_at(0).is_bool(), + (Self::Result(id), ty::Adt(adt, subs)) if id == adt.did() => subs.type_at(0).is_bool(), _ => false, } } diff --git a/src/tools/clippy/clippy_lints/src/loops/explicit_iter_loop.rs b/src/tools/clippy/clippy_lints/src/loops/explicit_iter_loop.rs index eea5f2a94ea60..1338a9f9d575b 100644 --- a/src/tools/clippy/clippy_lints/src/loops/explicit_iter_loop.rs +++ b/src/tools/clippy/clippy_lints/src/loops/explicit_iter_loop.rs @@ -23,7 +23,7 @@ pub(super) fn check( let Some((adjust, ty)) = is_ref_iterable(cx, self_arg, call_expr, enforce_iter_loop_reborrow) else { return; }; - if let ty::Array(_, count) = *ty.peel_refs().kind() { + if let ty::Array(_, count) = ty.peel_refs().kind() { if !ty.is_ref() { if !msrv.meets(msrvs::ARRAY_INTO_ITERATOR) { return; @@ -136,7 +136,7 @@ fn is_ref_iterable<'tcx>( let res_ty = cx .tcx .erase_regions(EarlyBinder::bind(req_res_ty).instantiate(cx.tcx, typeck.node_args(call_expr.hir_id))); - let mutbl = if let ty::Ref(_, _, mutbl) = *req_self_ty.kind() { + let mutbl = if let ty::Ref(_, _, mutbl) = req_self_ty.kind() { Some(mutbl) } else { None @@ -153,7 +153,7 @@ fn is_ref_iterable<'tcx>( return Some((AdjustKind::None, self_ty)); } } else if enforce_iter_loop_reborrow - && let ty::Ref(region, ty, Mutability::Mut) = *self_ty.kind() + && let ty::Ref(region, ty, Mutability::Mut) = self_ty.kind() && let Some(mutbl) = mutbl { // Attempt to reborrow the mutable reference diff --git a/src/tools/clippy/clippy_lints/src/loops/for_kv_map.rs b/src/tools/clippy/clippy_lints/src/loops/for_kv_map.rs index 6922533fbe9d3..d02faaeea3d72 100644 --- a/src/tools/clippy/clippy_lints/src/loops/for_kv_map.rs +++ b/src/tools/clippy/clippy_lints/src/loops/for_kv_map.rs @@ -15,7 +15,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, pat: &'tcx Pat<'_>, arg: &'tcx if let PatKind::Tuple(pat, _) = pat.kind { if pat.len() == 2 { let arg_span = arg.span; - let (new_pat_span, kind, ty, mutbl) = match *cx.typeck_results().expr_ty(arg).kind() { + let (new_pat_span, kind, ty, mutbl) = match cx.typeck_results().expr_ty(arg).kind() { ty::Ref(_, ty, mutbl) => match (&pat[0].kind, &pat[1].kind) { (key, _) if pat_is_wild(cx, key, body) => (pat[1].span, "value", ty, mutbl), (_, value) if pat_is_wild(cx, value, body) => (pat[0].span, "key", ty, Mutability::Not), diff --git a/src/tools/clippy/clippy_lints/src/loops/manual_memcpy.rs b/src/tools/clippy/clippy_lints/src/loops/manual_memcpy.rs index a7c1d1bd6cd36..1658937da1f98 100644 --- a/src/tools/clippy/clippy_lints/src/loops/manual_memcpy.rs +++ b/src/tools/clippy/clippy_lints/src/loops/manual_memcpy.rs @@ -333,8 +333,8 @@ struct Start<'hir> { fn get_slice_like_element_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option> { match ty.kind() { ty::Adt(adt, subs) if cx.tcx.is_diagnostic_item(sym::Vec, adt.did()) => Some(subs.type_at(0)), - ty::Ref(_, subty, _) => get_slice_like_element_ty(cx, *subty), - ty::Slice(ty) | ty::Array(ty, _) => Some(*ty), + ty::Ref(_, subty, _) => get_slice_like_element_ty(cx, subty), + ty::Slice(ty) | ty::Array(ty, _) => Some(ty), _ => None, } } diff --git a/src/tools/clippy/clippy_lints/src/loops/needless_range_loop.rs b/src/tools/clippy/clippy_lints/src/loops/needless_range_loop.rs index de7ec81bc0108..042167fffeacc 100644 --- a/src/tools/clippy/clippy_lints/src/loops/needless_range_loop.rs +++ b/src/tools/clippy/clippy_lints/src/loops/needless_range_loop.rs @@ -345,7 +345,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> { for expr in args { let ty = self.cx.typeck_results().expr_ty_adjusted(expr); self.prefer_mutable = false; - if let ty::Ref(_, _, mutbl) = *ty.kind() { + if let ty::Ref(_, _, mutbl) = ty.kind() { if mutbl == Mutability::Mut { self.prefer_mutable = true; } @@ -360,7 +360,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> { iter::once(receiver).chain(args.iter()), ) { self.prefer_mutable = false; - if let ty::Ref(_, _, mutbl) = *ty.kind() { + if let ty::Ref(_, _, mutbl) = ty.kind() { if mutbl == Mutability::Mut { self.prefer_mutable = true; } diff --git a/src/tools/clippy/clippy_lints/src/loops/unused_enumerate_index.rs b/src/tools/clippy/clippy_lints/src/loops/unused_enumerate_index.rs index 40ccfec02be58..6fb41bf232f1f 100644 --- a/src/tools/clippy/clippy_lints/src/loops/unused_enumerate_index.rs +++ b/src/tools/clippy/clippy_lints/src/loops/unused_enumerate_index.rs @@ -16,7 +16,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, pat: &Pat<'tcx>, arg: &Expr<'_ && let ExprKind::MethodCall(_method, self_arg, [], _) = arg.kind && let ty = cx.typeck_results().expr_ty(arg) && pat_is_wild(cx, &index.kind, body) - && let ty::Adt(base, _) = *ty.kind() + && let ty::Adt(base, _) = ty.kind() && cx.tcx.is_diagnostic_item(sym::Enumerate, base.did()) && let Some((DefKind::AssocFn, call_id)) = cx.typeck_results().type_dependent_def(arg.hir_id) && cx.tcx.is_diagnostic_item(sym::enumerate_method, call_id) diff --git a/src/tools/clippy/clippy_lints/src/manual_slice_size_calculation.rs b/src/tools/clippy/clippy_lints/src/manual_slice_size_calculation.rs index 1de686dbcb51e..f3c8f38a44807 100644 --- a/src/tools/clippy/clippy_lints/src/manual_slice_size_calculation.rs +++ b/src/tools/clippy/clippy_lints/src/manual_slice_size_calculation.rs @@ -94,7 +94,7 @@ fn simplify_half<'tcx>( && cx.tcx.is_diagnostic_item(sym::mem_size_of, def_id) && let Some(ty2) = cx.typeck_results().node_args(func.hir_id).types().next() // T1 == T2? - && *ty1 == ty2 + && ty1 == ty2 { Some(receiver) } else { diff --git a/src/tools/clippy/clippy_lints/src/map_unit_fn.rs b/src/tools/clippy/clippy_lints/src/map_unit_fn.rs index 9db04b615be7b..a87ac81d7f967 100644 --- a/src/tools/clippy/clippy_lints/src/map_unit_fn.rs +++ b/src/tools/clippy/clippy_lints/src/map_unit_fn.rs @@ -101,7 +101,7 @@ fn is_unit_type(ty: Ty<'_>) -> bool { fn is_unit_function(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> bool { let ty = cx.typeck_results().expr_ty(expr); - if let ty::FnDef(id, _) = *ty.kind() { + if let ty::FnDef(id, _) = ty.kind() { if let Some(fn_type) = cx.tcx.fn_sig(id).instantiate_identity().no_bound_vars() { return is_unit_type(fn_type.output()); } diff --git a/src/tools/clippy/clippy_lints/src/matches/match_as_ref.rs b/src/tools/clippy/clippy_lints/src/matches/match_as_ref.rs index 6c123649afc2f..1ed8886c8b726 100644 --- a/src/tools/clippy/clippy_lints/src/matches/match_as_ref.rs +++ b/src/tools/clippy/clippy_lints/src/matches/match_as_ref.rs @@ -30,7 +30,7 @@ pub(crate) fn check(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr: && let input_ty = args.type_at(0) && let ty::Adt(_, args) = output_ty.kind() && let output_ty = args.type_at(0) - && let ty::Ref(_, output_ty, _) = *output_ty.kind() + && let ty::Ref(_, output_ty, _) = output_ty.kind() && input_ty != output_ty { ".map(|x| x as _)" diff --git a/src/tools/clippy/clippy_lints/src/matches/match_bool.rs b/src/tools/clippy/clippy_lints/src/matches/match_bool.rs index 69105ff0d5c7a..667c21016e63e 100644 --- a/src/tools/clippy/clippy_lints/src/matches/match_bool.rs +++ b/src/tools/clippy/clippy_lints/src/matches/match_bool.rs @@ -12,7 +12,7 @@ use super::MATCH_BOOL; pub(crate) fn check(cx: &LateContext<'_>, scrutinee: &Expr<'_>, arms: &[Arm<'_>], expr: &Expr<'_>) { // Type of expression is `bool`. - if *cx.typeck_results().expr_ty(scrutinee).kind() == ty::Bool { + if cx.typeck_results().expr_ty(scrutinee).kind() == ty::Bool { span_lint_and_then( cx, MATCH_BOOL, diff --git a/src/tools/clippy/clippy_lints/src/matches/match_str_case_mismatch.rs b/src/tools/clippy/clippy_lints/src/matches/match_str_case_mismatch.rs index 322e9c3ebe5b3..96a7b785be0ea 100644 --- a/src/tools/clippy/clippy_lints/src/matches/match_str_case_mismatch.rs +++ b/src/tools/clippy/clippy_lints/src/matches/match_str_case_mismatch.rs @@ -54,7 +54,7 @@ impl<'a, 'tcx> MatchExprVisitor<'a, 'tcx> { if let Some(case_method) = get_case_method(segment_ident) { let ty = self.cx.typeck_results().expr_ty(receiver).peel_refs(); - if is_type_lang_item(self.cx, ty, LangItem::String) || ty.kind() == &ty::Str { + if is_type_lang_item(self.cx, ty, LangItem::String) || ty.kind() == ty::Str { self.case_method = Some(case_method); return true; } diff --git a/src/tools/clippy/clippy_lints/src/matches/significant_drop_in_scrutinee.rs b/src/tools/clippy/clippy_lints/src/matches/significant_drop_in_scrutinee.rs index 2f72e59834fa6..5ec6a2d3882d5 100644 --- a/src/tools/clippy/clippy_lints/src/matches/significant_drop_in_scrutinee.rs +++ b/src/tools/clippy/clippy_lints/src/matches/significant_drop_in_scrutinee.rs @@ -161,7 +161,7 @@ impl<'a, 'tcx> SigDropChecker<'a, 'tcx> { .any(|ty| self.has_sig_drop_attr_impl(ty))) }, rustc_middle::ty::Tuple(tys) => tys.iter().any(|ty| self.has_sig_drop_attr_impl(ty)), - rustc_middle::ty::Array(ty, _) | rustc_middle::ty::Slice(ty) => self.has_sig_drop_attr_impl(*ty), + rustc_middle::ty::Array(ty, _) | rustc_middle::ty::Slice(ty) => self.has_sig_drop_attr_impl(ty), _ => false, }; @@ -321,7 +321,7 @@ impl<'a, 'tcx> SigDropHelper<'a, 'tcx> { let output_ty = fn_sig.skip_binder().output(); if let rustc_middle::ty::Ref(output_re, peel_ref_ty, _) = output_ty.kind() && input_re == output_re - && for_each_top_level_late_bound_region(*peel_ref_ty, contains_input_re).is_continue() + && for_each_top_level_late_bound_region(peel_ref_ty, contains_input_re).is_continue() { // We're lucky! The output type is still a direct reference to the value with significant drop. self.sig_drop_holder = SigDropHolder::DirectRef; @@ -341,7 +341,7 @@ impl<'a, 'tcx> SigDropHelper<'a, 'tcx> { fn ty_peel_refs(mut ty: Ty<'_>) -> (Ty<'_>, usize) { let mut n = 0; while let rustc_middle::ty::Ref(_, new_ty, Mutability::Not) = ty.kind() { - ty = *new_ty; + ty = new_ty; n += 1; } (ty, n) diff --git a/src/tools/clippy/clippy_lints/src/matches/single_match.rs b/src/tools/clippy/clippy_lints/src/matches/single_match.rs index 69791414f72c6..b437abc696112 100644 --- a/src/tools/clippy/clippy_lints/src/matches/single_match.rs +++ b/src/tools/clippy/clippy_lints/src/matches/single_match.rs @@ -55,7 +55,7 @@ pub(crate) fn check(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr: }; let ty = cx.typeck_results().expr_ty(ex); - if (*ty.kind() != ty::Bool || is_lint_allowed(cx, MATCH_BOOL, ex.hir_id)) && + if (ty.kind() != ty::Bool || is_lint_allowed(cx, MATCH_BOOL, ex.hir_id)) && (check_single_pattern(arms) || check_opt_like(cx, arms, ty)) { report_single_pattern(cx, ex, arms, expr, els); } diff --git a/src/tools/clippy/clippy_lints/src/methods/bytecount.rs b/src/tools/clippy/clippy_lints/src/methods/bytecount.rs index 4a2124c74a882..4e636e9d52072 100644 --- a/src/tools/clippy/clippy_lints/src/methods/bytecount.rs +++ b/src/tools/clippy/clippy_lints/src/methods/bytecount.rs @@ -35,7 +35,7 @@ pub(super) fn check<'tcx>( } else { return; } - && ty::Uint(UintTy::U8) == *cx.typeck_results().expr_ty(needle).peel_refs().kind() + && ty::Uint(UintTy::U8) == cx.typeck_results().expr_ty(needle).peel_refs().kind() && !is_local_used(cx, needle, arg_id) { let haystack = if let ExprKind::MethodCall(path, receiver, [], _) = filter_recv.kind { diff --git a/src/tools/clippy/clippy_lints/src/methods/chars_cmp.rs b/src/tools/clippy/clippy_lints/src/methods/chars_cmp.rs index 4ae0aeea2d1c5..e6ca897969c17 100644 --- a/src/tools/clippy/clippy_lints/src/methods/chars_cmp.rs +++ b/src/tools/clippy/clippy_lints/src/methods/chars_cmp.rs @@ -22,7 +22,7 @@ pub(super) fn check( let mut applicability = Applicability::MachineApplicable; let self_ty = cx.typeck_results().expr_ty_adjusted(args[0].0).peel_refs(); - if *self_ty.kind() != ty::Str { + if self_ty.kind() != ty::Str { return false; } diff --git a/src/tools/clippy/clippy_lints/src/methods/cloned_instead_of_copied.rs b/src/tools/clippy/clippy_lints/src/methods/cloned_instead_of_copied.rs index fcafa16223658..11a34072c5cc3 100644 --- a/src/tools/clippy/clippy_lints/src/methods/cloned_instead_of_copied.rs +++ b/src/tools/clippy/clippy_lints/src/methods/cloned_instead_of_copied.rs @@ -30,7 +30,7 @@ pub fn check(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, span: Span, }; match inner_ty.kind() { // &T where T: Copy - ty::Ref(_, ty, _) if is_copy(cx, *ty) => {}, + ty::Ref(_, ty, _) if is_copy(cx, ty) => {}, _ => return, }; span_lint_and_sugg( diff --git a/src/tools/clippy/clippy_lints/src/methods/iter_overeager_cloned.rs b/src/tools/clippy/clippy_lints/src/methods/iter_overeager_cloned.rs index 5ccb5243e903c..6a61ac398119a 100644 --- a/src/tools/clippy/clippy_lints/src/methods/iter_overeager_cloned.rs +++ b/src/tools/clippy/clippy_lints/src/methods/iter_overeager_cloned.rs @@ -49,7 +49,7 @@ pub(super) fn check<'tcx>( && cx.tcx.trait_of_item(method_id) == Some(iter_id) && let cloned_recv_ty = typeck.expr_ty_adjusted(cloned_recv) && let Some(iter_assoc_ty) = cx.get_associated_type(cloned_recv_ty, iter_id, "Item") - && matches!(*iter_assoc_ty.kind(), ty::Ref(_, ty, _) if !is_copy(cx, ty)) + && matches!(iter_assoc_ty.kind(), ty::Ref(_, ty, _) if !is_copy(cx, ty)) { if needs_into_iter && let Some(into_iter_id) = cx.tcx.get_diagnostic_item(sym::IntoIterator) diff --git a/src/tools/clippy/clippy_lints/src/methods/map_clone.rs b/src/tools/clippy/clippy_lints/src/methods/map_clone.rs index a5ba5e5d8918c..278c39b0910fd 100644 --- a/src/tools/clippy/clippy_lints/src/methods/map_clone.rs +++ b/src/tools/clippy/clippy_lints/src/methods/map_clone.rs @@ -78,7 +78,7 @@ pub(super) fn check(cx: &LateContext<'_>, e: &hir::Expr<'_>, recv: &hir::Expr<'_ let obj_ty = cx.typeck_results().expr_ty(obj); if let ty::Ref(_, ty, mutability) = obj_ty.kind() { if matches!(mutability, Mutability::Not) { - let copy = is_copy(cx, *ty); + let copy = is_copy(cx, ty); lint_explicit_closure(cx, e.span, recv.span, copy, msrv); } } else { @@ -123,8 +123,8 @@ fn handle_path( && let Some(ty) = args.iter().find_map(|generic_arg| generic_arg.as_type()) && let ty::Ref(_, ty, Mutability::Not) = ty.kind() && let ty::FnDef(_, lst) = cx.typeck_results().expr_ty(arg).kind() - && lst.iter().all(|l| l.as_type() == Some(*ty)) - && !should_call_clone_as_function(cx, *ty) + && lst.iter().all(|l| l.as_type() == Some(ty)) + && !should_call_clone_as_function(cx, ty) { lint_path(cx, e.span, recv.span, is_copy(cx, ty.peel_refs())); } diff --git a/src/tools/clippy/clippy_lints/src/methods/mod.rs b/src/tools/clippy/clippy_lints/src/methods/mod.rs index 75a86c0c83448..5c237120a2cb1 100644 --- a/src/tools/clippy/clippy_lints/src/methods/mod.rs +++ b/src/tools/clippy/clippy_lints/src/methods/mod.rs @@ -5165,7 +5165,7 @@ impl SelfKind { } fn matches_ref<'a>(cx: &LateContext<'a>, mutability: hir::Mutability, parent_ty: Ty<'a>, ty: Ty<'a>) -> bool { - if let ty::Ref(_, t, m) = *ty.kind() { + if let ty::Ref(_, t, m) = ty.kind() { return m == mutability && t == parent_ty; } diff --git a/src/tools/clippy/clippy_lints/src/methods/needless_collect.rs b/src/tools/clippy/clippy_lints/src/methods/needless_collect.rs index f26f164fa54a4..7106eb4a00493 100644 --- a/src/tools/clippy/clippy_lints/src/methods/needless_collect.rs +++ b/src/tools/clippy/clippy_lints/src/methods/needless_collect.rs @@ -223,7 +223,7 @@ fn is_contains_sig(cx: &LateContext<'_>, call_id: HirId, iter_expr: &Expr<'_>) - && let sig = cx.tcx.fn_sig(id).instantiate_identity() && sig.skip_binder().output().is_bool() && let [_, search_ty] = *sig.skip_binder().inputs() - && let ty::Ref(_, search_ty, Mutability::Not) = *cx + && let ty::Ref(_, search_ty, Mutability::Not) = cx .tcx .instantiate_bound_regions_with_erased(sig.rebind(search_ty)) .kind() @@ -486,14 +486,14 @@ fn get_captured_ids(cx: &LateContext<'_>, ty: Ty<'_>) -> HirIdSet { fn get_captured_ids_recursive(cx: &LateContext<'_>, ty: Ty<'_>, set: &mut HirIdSet) { match ty.kind() { ty::Adt(_, generics) => { - for generic in *generics { + for generic in generics { if let GenericArgKind::Type(ty) = generic.unpack() { get_captured_ids_recursive(cx, ty, set); } } }, ty::Closure(def_id, _) => { - let closure_hir_node = cx.tcx.hir().get_if_local(*def_id).unwrap(); + let closure_hir_node = cx.tcx.hir().get_if_local(def_id).unwrap(); if let Node::Expr(closure_expr) = closure_hir_node { can_move_expr_to_closure(cx, closure_expr) .unwrap() diff --git a/src/tools/clippy/clippy_lints/src/methods/unnecessary_join.rs b/src/tools/clippy/clippy_lints/src/methods/unnecessary_join.rs index efd1a718504ce..7296dc61ee310 100644 --- a/src/tools/clippy/clippy_lints/src/methods/unnecessary_join.rs +++ b/src/tools/clippy/clippy_lints/src/methods/unnecessary_join.rs @@ -21,7 +21,7 @@ pub(super) fn check<'tcx>( if let ty::Ref(_, ref_type, _) = collect_output_adjusted_type.kind() // the turbofish for collect is ::> && let ty::Slice(slice) = ref_type.kind() - && is_type_lang_item(cx, *slice, LangItem::String) + && is_type_lang_item(cx, slice, LangItem::String) // the argument for join is "" && let ExprKind::Lit(spanned) = &join_arg.kind && let LitKind::Str(symbol, _) = spanned.node diff --git a/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs b/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs index ae9aa83efd685..14667a518242e 100644 --- a/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs +++ b/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs @@ -390,7 +390,7 @@ fn get_callee_generic_args_and_args<'tcx>( && let ty::FnDef(callee_def_id, _) = callee_ty.kind() { let generic_args = cx.typeck_results().node_args(callee.hir_id); - return Some((*callee_def_id, generic_args, None, args)); + return Some((callee_def_id, generic_args, None, args)); } if let ExprKind::MethodCall(_, recv, args, _) = expr.kind && let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) @@ -461,7 +461,7 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty< .chain(call_args) .position(|arg| arg.hir_id == expr.hir_id) && let param_ty = fn_sig.input(arg_index).skip_binder() - && let ty::Param(ParamTy { index: param_index , ..}) = *param_ty.kind() + && let ty::Param(ParamTy { index: param_index , ..}) = param_ty.kind() // https://github.com/rust-lang/rust-clippy/issues/9504 and https://github.com/rust-lang/rust-clippy/issues/10021 && (param_index as usize) < call_generic_args.len() { diff --git a/src/tools/clippy/clippy_lints/src/methods/utils.rs b/src/tools/clippy/clippy_lints/src/methods/utils.rs index 1a55b7160fb18..3523af6163a19 100644 --- a/src/tools/clippy/clippy_lints/src/methods/utils.rs +++ b/src/tools/clippy/clippy_lints/src/methods/utils.rs @@ -22,7 +22,7 @@ pub(super) fn derefs_to_slice<'tcx>( ty::Adt(def, _) if def.is_box() => may_slice(cx, ty.boxed_ty()), ty::Adt(..) => is_type_diagnostic_item(cx, ty, sym::Vec), ty::Array(_, size) => size.try_eval_target_usize(cx.tcx, cx.param_env).is_some(), - ty::Ref(_, inner, _) => may_slice(cx, *inner), + ty::Ref(_, inner, _) => may_slice(cx, inner), _ => false, } } @@ -38,7 +38,7 @@ pub(super) fn derefs_to_slice<'tcx>( ty::Slice(_) => Some(expr), ty::Adt(def, _) if def.is_box() && may_slice(cx, ty.boxed_ty()) => Some(expr), ty::Ref(_, inner, _) => { - if may_slice(cx, *inner) { + if may_slice(cx, inner) { Some(expr) } else { None diff --git a/src/tools/clippy/clippy_lints/src/methods/zst_offset.rs b/src/tools/clippy/clippy_lints/src/methods/zst_offset.rs index d33021c2a7bf8..091788e7f0eca 100644 --- a/src/tools/clippy/clippy_lints/src/methods/zst_offset.rs +++ b/src/tools/clippy/clippy_lints/src/methods/zst_offset.rs @@ -7,7 +7,7 @@ use super::ZST_OFFSET; pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr<'_>) { if let ty::RawPtr(ty, _) = cx.typeck_results().expr_ty(recv).kind() - && let Ok(layout) = cx.tcx.layout_of(cx.param_env.and(*ty)) + && let Ok(layout) = cx.tcx.layout_of(cx.param_env.and(ty)) && layout.is_zst() { span_lint(cx, ZST_OFFSET, expr.span, "offset calculation on zero-sized value"); diff --git a/src/tools/clippy/clippy_lints/src/mixed_read_write_in_expression.rs b/src/tools/clippy/clippy_lints/src/mixed_read_write_in_expression.rs index 9c5a8a0cfcdfa..7533bcfd0f8fc 100644 --- a/src/tools/clippy/clippy_lints/src/mixed_read_write_in_expression.rs +++ b/src/tools/clippy/clippy_lints/src/mixed_read_write_in_expression.rs @@ -168,7 +168,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> { match typ.kind() { ty::FnDef(..) | ty::FnPtr(_) => { let sig = typ.fn_sig(self.cx.tcx); - if self.cx.tcx.instantiate_bound_regions_with_erased(sig).output().kind() == &ty::Never { + if self.cx.tcx.instantiate_bound_regions_with_erased(sig).output().kind() == ty::Never { self.report_diverging_sub_expr(e); } }, diff --git a/src/tools/clippy/clippy_lints/src/multiple_unsafe_ops_per_block.rs b/src/tools/clippy/clippy_lints/src/multiple_unsafe_ops_per_block.rs index 5b4ef852f0d9b..e0069c9404250 100644 --- a/src/tools/clippy/clippy_lints/src/multiple_unsafe_ops_per_block.rs +++ b/src/tools/clippy/clippy_lints/src/multiple_unsafe_ops_per_block.rs @@ -128,7 +128,7 @@ fn collect_unsafe_exprs<'tcx>( }, ExprKind::Call(path_expr, _) => { - let sig = match *cx.typeck_results().expr_ty(path_expr).kind() { + let sig = match cx.typeck_results().expr_ty(path_expr).kind() { ty::FnDef(id, _) => cx.tcx.fn_sig(id).skip_binder(), ty::FnPtr(sig) => sig, _ => return Continue(Descend::Yes), diff --git a/src/tools/clippy/clippy_lints/src/mutex_atomic.rs b/src/tools/clippy/clippy_lints/src/mutex_atomic.rs index 853e476a006c6..f9e80e8cc04d7 100644 --- a/src/tools/clippy/clippy_lints/src/mutex_atomic.rs +++ b/src/tools/clippy/clippy_lints/src/mutex_atomic.rs @@ -91,7 +91,7 @@ impl<'tcx> LateLintPass<'tcx> for Mutex { "consider using an `{atomic_name}` instead of a `Mutex` here; if you just want the locking \ behavior and not the internal type, consider using `Mutex<()>`" ); - match *mutex_param.kind() { + match mutex_param.kind() { ty::Uint(t) if t != UintTy::Usize => span_lint(cx, MUTEX_INTEGER, expr.span, msg), ty::Int(t) if t != IntTy::Isize => span_lint(cx, MUTEX_INTEGER, expr.span, msg), _ => span_lint(cx, MUTEX_ATOMIC, expr.span, msg), diff --git a/src/tools/clippy/clippy_lints/src/needless_borrows_for_generic_args.rs b/src/tools/clippy/clippy_lints/src/needless_borrows_for_generic_args.rs index 4f99eaa40c29b..7f75c82f19171 100644 --- a/src/tools/clippy/clippy_lints/src/needless_borrows_for_generic_args.rs +++ b/src/tools/clippy/clippy_lints/src/needless_borrows_for_generic_args.rs @@ -83,7 +83,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessBorrowsForGenericArgs<'tcx> { && let Some(use_cx) = expr_use_ctxt(cx, expr) && !use_cx.is_ty_unified && let Some(DefinedTy::Mir(ty)) = use_cx.node.defined_ty(cx) - && let ty::Param(ty) = *ty.value.skip_binder().kind() + && let ty::Param(ty) = ty.value.skip_binder().kind() && let Some((hir_id, fn_id, i)) = match use_cx.node { ExprUseNode::MethodArg(_, _, 0) => None, ExprUseNode::MethodArg(hir_id, None, i) => cx @@ -318,7 +318,7 @@ fn is_mixed_projection_predicate<'tcx>( // The inner-most self type is a type parameter from the current function. let mut projection_term = projection_predicate.projection_term; loop { - match *projection_term.self_ty().kind() { + match projection_term.self_ty().kind() { ty::Alias(ty::Projection, inner_projection_ty) => { projection_term = inner_projection_ty.into(); }, @@ -382,7 +382,7 @@ fn replace_types<'tcx>( if let Ok(projected_ty) = cx.tcx.try_normalize_erasing_regions(cx.param_env, projection) && args[term_param_ty.index as usize] != GenericArg::from(projected_ty) { - deque.push_back((*term_param_ty, projected_ty)); + deque.push_back((term_param_ty, projected_ty)); } } } diff --git a/src/tools/clippy/clippy_lints/src/non_copy_const.rs b/src/tools/clippy/clippy_lints/src/non_copy_const.rs index 76d9cee18aa7f..e590cf82706d3 100644 --- a/src/tools/clippy/clippy_lints/src/non_copy_const.rs +++ b/src/tools/clippy/clippy_lints/src/non_copy_const.rs @@ -186,7 +186,7 @@ impl<'tcx> NonCopyConst<'tcx> { } fn is_value_unfrozen_raw_inner(cx: &LateContext<'tcx>, val: ty::ValTree<'tcx>, ty: Ty<'tcx>) -> bool { - match *ty.kind() { + match ty.kind() { // the fact that we have to dig into every structs to search enums // leads us to the point checking `UnsafeCell` directly is the only option. ty::Adt(ty_def, ..) if ty_def.is_unsafe_cell() => true, diff --git a/src/tools/clippy/clippy_lints/src/non_send_fields_in_send_ty.rs b/src/tools/clippy/clippy_lints/src/non_send_fields_in_send_ty.rs index 74e6c57b52d46..c1f947a5189fb 100644 --- a/src/tools/clippy/clippy_lints/src/non_send_fields_in_send_ty.rs +++ b/src/tools/clippy/clippy_lints/src/non_send_fields_in_send_ty.rs @@ -205,7 +205,7 @@ fn ty_allowed_with_raw_pointer_heuristic<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'t ty::Tuple(fields) => fields .iter() .all(|ty| ty_allowed_with_raw_pointer_heuristic(cx, ty, send_trait)), - ty::Array(ty, _) | ty::Slice(ty) => ty_allowed_with_raw_pointer_heuristic(cx, *ty, send_trait), + ty::Array(ty, _) | ty::Slice(ty) => ty_allowed_with_raw_pointer_heuristic(cx, ty, send_trait), ty::Adt(_, args) => { if contains_pointer_like(cx, ty) { // descends only if ADT contains any raw pointers diff --git a/src/tools/clippy/clippy_lints/src/only_used_in_recursion.rs b/src/tools/clippy/clippy_lints/src/only_used_in_recursion.rs index 8b8aabe7accc6..129c7bb4ea05d 100644 --- a/src/tools/clippy/clippy_lints/src/only_used_in_recursion.rs +++ b/src/tools/clippy/clippy_lints/src/only_used_in_recursion.rs @@ -388,7 +388,7 @@ fn has_matching_args(kind: FnKind, args: GenericArgsRef<'_>) -> bool { FnKind::Fn => true, FnKind::TraitFn => args.iter().enumerate().all(|(idx, subst)| match subst.unpack() { GenericArgKind::Lifetime(_) => true, - GenericArgKind::Type(ty) => matches!(*ty.kind(), ty::Param(ty) if ty.index as usize == idx), + GenericArgKind::Type(ty) => matches!(ty.kind(), ty::Param(ty) if ty.index as usize == idx), GenericArgKind::Const(c) => matches!(c.kind(), ConstKind::Param(c) if c.index as usize == idx), }), FnKind::ImplTraitFn(expected_args) => std::ptr::from_ref(args) as usize == expected_args, diff --git a/src/tools/clippy/clippy_lints/src/operators/absurd_extreme_comparisons.rs b/src/tools/clippy/clippy_lints/src/operators/absurd_extreme_comparisons.rs index 9769da6d3e9b1..7a26ae54bb82a 100644 --- a/src/tools/clippy/clippy_lints/src/operators/absurd_extreme_comparisons.rs +++ b/src/tools/clippy/clippy_lints/src/operators/absurd_extreme_comparisons.rs @@ -124,16 +124,16 @@ fn detect_extreme_expr<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Op let cv = constant(cx, cx.typeck_results(), expr)?; let which = match (ty.kind(), cv) { - (&ty::Bool, Constant::Bool(false)) | (&ty::Uint(_), Constant::Int(0)) => ExtremeType::Minimum, - (&ty::Int(ity), Constant::Int(i)) if i == unsext(cx.tcx, i128::MIN >> (128 - int_bits(cx.tcx, ity)), ity) => { + (ty::Bool, Constant::Bool(false)) | (ty::Uint(_), Constant::Int(0)) => ExtremeType::Minimum, + (ty::Int(ity), Constant::Int(i)) if i == unsext(cx.tcx, i128::MIN >> (128 - int_bits(cx.tcx, ity)), ity) => { ExtremeType::Minimum }, - (&ty::Bool, Constant::Bool(true)) => ExtremeType::Maximum, - (&ty::Int(ity), Constant::Int(i)) if i == unsext(cx.tcx, i128::MAX >> (128 - int_bits(cx.tcx, ity)), ity) => { + (ty::Bool, Constant::Bool(true)) => ExtremeType::Maximum, + (ty::Int(ity), Constant::Int(i)) if i == unsext(cx.tcx, i128::MAX >> (128 - int_bits(cx.tcx, ity)), ity) => { ExtremeType::Maximum }, - (&ty::Uint(uty), Constant::Int(i)) if clip(cx.tcx, u128::MAX, uty) == i => ExtremeType::Maximum, + (ty::Uint(uty), Constant::Int(i)) if clip(cx.tcx, u128::MAX, uty) == i => ExtremeType::Maximum, _ => return None, }; diff --git a/src/tools/clippy/clippy_lints/src/operators/identity_op.rs b/src/tools/clippy/clippy_lints/src/operators/identity_op.rs index 0879dcd9bcdf6..fbb8afbbf6dd8 100644 --- a/src/tools/clippy/clippy_lints/src/operators/identity_op.rs +++ b/src/tools/clippy/clippy_lints/src/operators/identity_op.rs @@ -202,7 +202,7 @@ fn check_remainder(cx: &LateContext<'_>, left: &Expr<'_>, right: &Expr<'_>, span fn check_op(cx: &LateContext<'_>, e: &Expr<'_>, m: i8, span: Span, arg: Span, parens: Parens, is_erased: bool) -> bool { if let Some(Constant::Int(v)) = constant_simple(cx, cx.typeck_results(), e).map(Constant::peel_refs) { - let check = match *cx.typeck_results().expr_ty(e).peel_refs().kind() { + let check = match cx.typeck_results().expr_ty(e).peel_refs().kind() { ty::Int(ity) => unsext(cx.tcx, -1_i128, ity), ty::Uint(uty) => clip(cx.tcx, !0, uty), _ => return false, diff --git a/src/tools/clippy/clippy_lints/src/operators/modulo_arithmetic.rs b/src/tools/clippy/clippy_lints/src/operators/modulo_arithmetic.rs index c56518ac72a46..df677fb9151da 100644 --- a/src/tools/clippy/clippy_lints/src/operators/modulo_arithmetic.rs +++ b/src/tools/clippy/clippy_lints/src/operators/modulo_arithmetic.rs @@ -61,7 +61,7 @@ struct OperandInfo { fn analyze_operand(operand: &Expr<'_>, cx: &LateContext<'_>, expr: &Expr<'_>) -> Option { match constant(cx, cx.typeck_results(), operand) { - Some(Constant::Int(v)) => match *cx.typeck_results().expr_ty(expr).kind() { + Some(Constant::Int(v)) => match cx.typeck_results().expr_ty(expr).kind() { ty::Int(ity) => { let value = sext(cx.tcx, v, ity); return Some(OperandInfo { diff --git a/src/tools/clippy/clippy_lints/src/operators/modulo_one.rs b/src/tools/clippy/clippy_lints/src/operators/modulo_one.rs index 54eea14833ffe..6ceae71a3ca2a 100644 --- a/src/tools/clippy/clippy_lints/src/operators/modulo_one.rs +++ b/src/tools/clippy/clippy_lints/src/operators/modulo_one.rs @@ -13,7 +13,7 @@ pub(crate) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, op: BinOpKind, right: } if let ty::Int(ity) = cx.typeck_results().expr_ty(right).kind() { - if is_integer_const(cx, right, unsext(cx.tcx, -1, *ity)) { + if is_integer_const(cx, right, unsext(cx.tcx, -1, ity)) { span_lint( cx, MODULO_ONE, diff --git a/src/tools/clippy/clippy_lints/src/pass_by_ref_or_value.rs b/src/tools/clippy/clippy_lints/src/pass_by_ref_or_value.rs index 128bfd49d9e5b..191e8681d188f 100644 --- a/src/tools/clippy/clippy_lints/src/pass_by_ref_or_value.rs +++ b/src/tools/clippy/clippy_lints/src/pass_by_ref_or_value.rs @@ -163,7 +163,7 @@ impl<'tcx> PassByRefOrValue { _ => (), } - match *ty.skip_binder().kind() { + match ty.skip_binder().kind() { ty::Ref(lt, ty, Mutability::Not) => { match lt.kind() { RegionKind::ReBound(index, region) diff --git a/src/tools/clippy/clippy_lints/src/pattern_type_mismatch.rs b/src/tools/clippy/clippy_lints/src/pattern_type_mismatch.rs index 9661a57b8b95c..9afa080e20b76 100644 --- a/src/tools/clippy/clippy_lints/src/pattern_type_mismatch.rs +++ b/src/tools/clippy/clippy_lints/src/pattern_type_mismatch.rs @@ -178,7 +178,7 @@ fn find_first_mismatch(cx: &LateContext<'_>, pat: &Pat<'_>) -> Option<(Span, Mut }; if let Some(adjustments) = cx.typeck_results().pat_adjustments().get(adjust_pat.hir_id) { if let [first, ..] = **adjustments { - if let ty::Ref(.., mutability) = *first.kind() { + if let ty::Ref(.., mutability) = first.kind() { let level = if p.hir_id == pat.hir_id { Level::Top } else { diff --git a/src/tools/clippy/clippy_lints/src/ptr.rs b/src/tools/clippy/clippy_lints/src/ptr.rs index 02c05e0aaf9ce..1de984211a6a6 100644 --- a/src/tools/clippy/clippy_lints/src/ptr.rs +++ b/src/tools/clippy/clippy_lints/src/ptr.rs @@ -425,8 +425,8 @@ fn check_fn_args<'cx, 'tcx: 'cx>( .zip(hir_tys.iter()) .enumerate() .filter_map(move |(i, (ty, hir_ty))| { - if let ty::Ref(_, ty, mutability) = *ty.kind() - && let ty::Adt(adt, args) = *ty.kind() + if let ty::Ref(_, ty, mutability) = ty.kind() + && let ty::Adt(adt, args) = ty.kind() && let TyKind::Ref(lt, ref ty) = hir_ty.kind && let TyKind::Path(QPath::Resolved(None, path)) = ty.ty.kind // Check that the name as typed matches the actual name of the type. @@ -614,7 +614,7 @@ fn check_ptr_arg_usage<'tcx>(cx: &LateContext<'tcx>, body: &Body<'tcx>, args: &[ ExprKind::Call(f, expr_args) => { let i = expr_args.iter().position(|arg| arg.hir_id == child_id).unwrap_or(0); if expr_sig(self.cx, f).and_then(|sig| sig.input(i)).map_or(true, |ty| { - match *ty.skip_binder().peel_refs().kind() { + match ty.skip_binder().peel_refs().kind() { ty::Dynamic(preds, _, _) => !matches_preds(self.cx, args.deref_ty.ty(self.cx), preds), ty::Param(_) => true, ty::Adt(def, _) => def.did() == args.ty_did, @@ -648,7 +648,7 @@ fn check_ptr_arg_usage<'tcx>(cx: &LateContext<'tcx>, body: &Body<'tcx>, args: &[ return; }; - match *self.cx.tcx.fn_sig(id).instantiate_identity().skip_binder().inputs()[i] + match self.cx.tcx.fn_sig(id).instantiate_identity().skip_binder().inputs()[i] .peel_refs() .kind() { diff --git a/src/tools/clippy/clippy_lints/src/rc_clone_in_vec_init.rs b/src/tools/clippy/clippy_lints/src/rc_clone_in_vec_init.rs index d0b45b59526fc..953edc230fc44 100644 --- a/src/tools/clippy/clippy_lints/src/rc_clone_in_vec_init.rs +++ b/src/tools/clippy/clippy_lints/src/rc_clone_in_vec_init.rs @@ -132,7 +132,7 @@ fn ref_init(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<(Symbol, Span)> { return Some((symbol, func.span)); } - if let ty::Adt(adt, _) = *cx.typeck_results().expr_ty(expr).kind() + if let ty::Adt(adt, _) = cx.typeck_results().expr_ty(expr).kind() && matches!(cx.tcx.get_diagnostic_name(adt.did()), Some(sym::RcWeak | sym::ArcWeak)) { return Some((Symbol::intern("Weak"), func.span)); diff --git a/src/tools/clippy/clippy_lints/src/redundant_clone.rs b/src/tools/clippy/clippy_lints/src/redundant_clone.rs index 3416a93e3c4ac..ec2de57bd9dca 100644 --- a/src/tools/clippy/clippy_lints/src/redundant_clone.rs +++ b/src/tools/clippy/clippy_lints/src/redundant_clone.rs @@ -258,7 +258,7 @@ fn is_call_with_ref_arg<'tcx>( } = kind && args.len() == 1 && let mir::Operand::Move(mir::Place { local, .. }) = &args[0].node - && let ty::FnDef(def_id, _) = *func.ty(mir, cx.tcx).kind() + && let ty::FnDef(def_id, _) = func.ty(mir, cx.tcx).kind() && let (inner_ty, 1) = walk_ptrs_ty_depth(args[0].node.ty(mir, cx.tcx)) && !is_copy(cx, inner_ty) { diff --git a/src/tools/clippy/clippy_lints/src/significant_drop_tightening.rs b/src/tools/clippy/clippy_lints/src/significant_drop_tightening.rs index 038eb92d652b4..f900a7ab6bb42 100644 --- a/src/tools/clippy/clippy_lints/src/significant_drop_tightening.rs +++ b/src/tools/clippy/clippy_lints/src/significant_drop_tightening.rs @@ -189,7 +189,7 @@ impl<'cx, 'others, 'tcx> AttrChecker<'cx, 'others, 'tcx> { return true; } } - for generic_arg in *b { + for generic_arg in b { if let GenericArgKind::Type(ty) = generic_arg.unpack() { if self.has_sig_drop_attr(ty) { return true; @@ -201,7 +201,7 @@ impl<'cx, 'others, 'tcx> AttrChecker<'cx, 'others, 'tcx> { rustc_middle::ty::Array(ty, _) | rustc_middle::ty::RawPtr(ty, _) | rustc_middle::ty::Ref(_, ty, _) - | rustc_middle::ty::Slice(ty) => self.has_sig_drop_attr(*ty), + | rustc_middle::ty::Slice(ty) => self.has_sig_drop_attr(ty), _ => false, } } diff --git a/src/tools/clippy/clippy_lints/src/size_of_in_element_count.rs b/src/tools/clippy/clippy_lints/src/size_of_in_element_count.rs index 01f0e3cfadbd4..51ed91007f41d 100644 --- a/src/tools/clippy/clippy_lints/src/size_of_in_element_count.rs +++ b/src/tools/clippy/clippy_lints/src/size_of_in_element_count.rs @@ -110,7 +110,7 @@ fn get_pointee_ty_and_count_expr<'tcx>( && let ty::RawPtr(pointee_ty, _) = cx.typeck_results().expr_ty(ptr_self).kind() { - return Some((*pointee_ty, count)); + return Some((pointee_ty, count)); }; None } diff --git a/src/tools/clippy/clippy_lints/src/to_digit_is_some.rs b/src/tools/clippy/clippy_lints/src/to_digit_is_some.rs index dafe9e38818f5..743eb82ce7006 100644 --- a/src/tools/clippy/clippy_lints/src/to_digit_is_some.rs +++ b/src/tools/clippy/clippy_lints/src/to_digit_is_some.rs @@ -44,7 +44,7 @@ impl<'tcx> LateLintPass<'tcx> for ToDigitIsSome { hir::ExprKind::MethodCall(to_digits_path, char_arg, [radix_arg], _) => { if to_digits_path.ident.name.as_str() == "to_digit" && let char_arg_ty = cx.typeck_results().expr_ty_adjusted(char_arg) - && *char_arg_ty.kind() == ty::Char + && char_arg_ty.kind() == ty::Char { Some((true, *char_arg, radix_arg)) } else { diff --git a/src/tools/clippy/clippy_lints/src/transmute/crosspointer_transmute.rs b/src/tools/clippy/clippy_lints/src/transmute/crosspointer_transmute.rs index c8f959a9854b4..c650f6b3f075b 100644 --- a/src/tools/clippy/clippy_lints/src/transmute/crosspointer_transmute.rs +++ b/src/tools/clippy/clippy_lints/src/transmute/crosspointer_transmute.rs @@ -7,7 +7,7 @@ use rustc_middle::ty::{self, Ty}; /// Checks for `crosspointer_transmute` lint. /// Returns `true` if it's triggered, otherwise returns `false`. pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, from_ty: Ty<'tcx>, to_ty: Ty<'tcx>) -> bool { - match (*from_ty.kind(), *to_ty.kind()) { + match (from_ty.kind(), to_ty.kind()) { (ty::RawPtr(from_ptr_ty, _), _) if from_ptr_ty == to_ty => { span_lint( cx, diff --git a/src/tools/clippy/clippy_lints/src/transmute/transmute_ref_to_ref.rs b/src/tools/clippy/clippy_lints/src/transmute/transmute_ref_to_ref.rs index 3842c4eb60e82..54c068158ad5f 100644 --- a/src/tools/clippy/clippy_lints/src/transmute/transmute_ref_to_ref.rs +++ b/src/tools/clippy/clippy_lints/src/transmute/transmute_ref_to_ref.rs @@ -19,8 +19,8 @@ pub(super) fn check<'tcx>( ) -> bool { let mut triggered = false; - if let (ty::Ref(_, ty_from, from_mutbl), ty::Ref(_, ty_to, to_mutbl)) = (*from_ty.kind(), *to_ty.kind()) { - if let ty::Slice(slice_ty) = *ty_from.kind() + if let (ty::Ref(_, ty_from, from_mutbl), ty::Ref(_, ty_to, to_mutbl)) = (from_ty.kind(), to_ty.kind()) { + if let ty::Slice(slice_ty) = ty_from.kind() && ty_to.is_str() && let ty::Uint(ty::UintTy::U8) = slice_ty.kind() && from_mutbl == to_mutbl diff --git a/src/tools/clippy/clippy_lints/src/transmute/transmute_undefined_repr.rs b/src/tools/clippy/clippy_lints/src/transmute/transmute_undefined_repr.rs index 3b32e4396b9f1..4129befe9c276 100644 --- a/src/tools/clippy/clippy_lints/src/transmute/transmute_undefined_repr.rs +++ b/src/tools/clippy/clippy_lints/src/transmute/transmute_undefined_repr.rs @@ -196,21 +196,21 @@ fn reduce_refs<'tcx>(cx: &LateContext<'tcx>, mut from_ty: Ty<'tcx>, mut to_ty: T let (from_fat_ptr, to_fat_ptr) = loop { break match (from_ty.kind(), to_ty.kind()) { ( - &(ty::Ref(_, from_sub_ty, _) | ty::RawPtr(from_sub_ty, _)), - &(ty::Ref(_, to_sub_ty, _) | ty::RawPtr(to_sub_ty, _)), + ty::Ref(_, from_sub_ty, _) | ty::RawPtr(from_sub_ty, _), + ty::Ref(_, to_sub_ty, _) | ty::RawPtr(to_sub_ty, _), ) => { - from_raw_ptr = matches!(*from_ty.kind(), ty::RawPtr(_, _)); + from_raw_ptr = matches!(from_ty.kind(), ty::RawPtr(_, _)); from_ty = from_sub_ty; - to_raw_ptr = matches!(*to_ty.kind(), ty::RawPtr(_, _)); + to_raw_ptr = matches!(to_ty.kind(), ty::RawPtr(_, _)); to_ty = to_sub_ty; continue; }, - (&(ty::Ref(_, unsized_ty, _) | ty::RawPtr(unsized_ty, _)), _) + (ty::Ref(_, unsized_ty, _) | ty::RawPtr(unsized_ty, _), _) if !unsized_ty.is_sized(cx.tcx, cx.param_env) => { (true, false) }, - (_, &(ty::Ref(_, unsized_ty, _) | ty::RawPtr(unsized_ty, _))) + (_, ty::Ref(_, unsized_ty, _) | ty::RawPtr(unsized_ty, _)) if !unsized_ty.is_sized(cx.tcx, cx.param_env) => { (false, true) @@ -245,7 +245,7 @@ enum ReducedTy<'tcx> { fn reduce_ty<'tcx>(cx: &LateContext<'tcx>, mut ty: Ty<'tcx>) -> ReducedTy<'tcx> { loop { ty = cx.tcx.try_normalize_erasing_regions(cx.param_env, ty).unwrap_or(ty); - return match *ty.kind() { + return match ty.kind() { ty::Array(sub_ty, _) if matches!(sub_ty.kind(), ty::Int(_) | ty::Uint(_)) => { ReducedTy::TypeErasure { raw_ptr_only: false } }, @@ -307,7 +307,7 @@ fn is_zero_sized_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool { } fn is_size_pair(ty: Ty<'_>) -> bool { - if let ty::Tuple(tys) = *ty.kind() + if let ty::Tuple(tys) = ty.kind() && let [ty1, ty2] = &**tys { matches!(ty1.kind(), ty::Int(IntTy::Isize) | ty::Uint(UintTy::Usize)) diff --git a/src/tools/clippy/clippy_lints/src/transmute/useless_transmute.rs b/src/tools/clippy/clippy_lints/src/transmute/useless_transmute.rs index ec5fb2793f976..58acee8d5a4b6 100644 --- a/src/tools/clippy/clippy_lints/src/transmute/useless_transmute.rs +++ b/src/tools/clippy/clippy_lints/src/transmute/useless_transmute.rs @@ -15,7 +15,7 @@ pub(super) fn check<'tcx>( to_ty: Ty<'tcx>, arg: &'tcx Expr<'_>, ) -> bool { - match (*from_ty.kind(), *to_ty.kind()) { + match (from_ty.kind(), to_ty.kind()) { _ if from_ty == to_ty && !from_ty.has_erased_regions() => { span_lint( cx, diff --git a/src/tools/clippy/clippy_lints/src/tuple_array_conversions.rs b/src/tools/clippy/clippy_lints/src/tuple_array_conversions.rs index 564b065d0ba27..109acf28d157e 100644 --- a/src/tools/clippy/clippy_lints/src/tuple_array_conversions.rs +++ b/src/tools/clippy/clippy_lints/src/tuple_array_conversions.rs @@ -83,7 +83,7 @@ fn check_array<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, elements: & ExprKind::Path(_) => Some(elements.iter().collect()), _ => None, }) - && all_bindings_are_for_conv(cx, &[*ty], expr, elements, &locals, ToType::Array) + && all_bindings_are_for_conv(cx, &[ty], expr, elements, &locals, ToType::Array) && !is_from_proc_macro(cx, expr) { span_lint_and_help( @@ -184,7 +184,8 @@ fn all_bindings_are_for_conv<'tcx>( }, (ToType::Tuple, ty::Array(ty, len)) => { let Some(len) = len.try_eval_target_usize(cx.tcx, cx.param_env) else { return false }; - len as usize == elements.len() && final_tys.iter().chain(once(ty)).all_equal() + // njn: added `&` + len as usize == elements.len() && final_tys.iter().chain(once(&ty)).all_equal() }, _ => false, } diff --git a/src/tools/clippy/clippy_lints/src/unconditional_recursion.rs b/src/tools/clippy/clippy_lints/src/unconditional_recursion.rs index 5e41b3f4914ff..c568b6044548c 100644 --- a/src/tools/clippy/clippy_lints/src/unconditional_recursion.rs +++ b/src/tools/clippy/clippy_lints/src/unconditional_recursion.rs @@ -139,7 +139,7 @@ fn matches_ty<'tcx>( expected_left: Ty<'tcx>, expected_right: Ty<'tcx>, ) -> bool { - while let (&ty::Ref(_, lty, _), &ty::Ref(_, rty, _)) = (left.kind(), right.kind()) { + while let (ty::Ref(_, lty, _), ty::Ref(_, rty, _)) = (left.kind(), right.kind()) { if lty == expected_left && rty == expected_right { return true; } @@ -160,8 +160,8 @@ fn check_partial_eq(cx: &LateContext<'_>, method_span: Span, method_def_id: Loca // That has two arguments. if let [self_arg, other_arg] = sig.inputs() - && let &ty::Ref(_, self_arg, _) = self_arg.kind() - && let &ty::Ref(_, other_arg, _) = other_arg.kind() + && let ty::Ref(_, self_arg, _) = self_arg.kind() + && let ty::Ref(_, other_arg, _) = other_arg.kind() // The two arguments are of the same type. && let Some(trait_def_id) = get_impl_trait_def_id(cx, method_def_id) // The trait is `PartialEq`. diff --git a/src/tools/clippy/clippy_lints/src/unit_types/let_unit_value.rs b/src/tools/clippy/clippy_lints/src/unit_types/let_unit_value.rs index 80b661a757c21..12e32f3f712d4 100644 --- a/src/tools/clippy/clippy_lints/src/unit_types/let_unit_value.rs +++ b/src/tools/clippy/clippy_lints/src/unit_types/let_unit_value.rs @@ -218,7 +218,7 @@ fn needs_inferred_result_ty( _ => return false, }; let sig = cx.tcx.fn_sig(id).instantiate_identity().skip_binder(); - if let ty::Param(output_ty) = *sig.output().kind() { + if let ty::Param(output_ty) = sig.output().kind() { let args: Vec<&Expr<'_>> = if let Some(receiver) = receiver { std::iter::once(receiver).chain(args.iter()).collect() } else { diff --git a/src/tools/clippy/clippy_lints/src/use_self.rs b/src/tools/clippy/clippy_lints/src/use_self.rs index 0bab917607daf..1d28f72ba200c 100644 --- a/src/tools/clippy/clippy_lints/src/use_self.rs +++ b/src/tools/clippy/clippy_lints/src/use_self.rs @@ -350,7 +350,7 @@ fn same_lifetimes<'tcx>(a: MiddleTy<'tcx>, b: MiddleTy<'tcx>) -> bool { fn has_no_lifetime(ty: MiddleTy<'_>) -> bool { use rustc_middle::ty::{Adt, GenericArgKind}; match ty.kind() { - &Adt(_, args) => !args + Adt(_, args) => !args .iter() // TODO: Handle inferred lifetimes .any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(..))), diff --git a/src/tools/clippy/clippy_utils/src/consts.rs b/src/tools/clippy/clippy_utils/src/consts.rs index cd88ccd87cf0a..cc284ee2a616e 100644 --- a/src/tools/clippy/clippy_utils/src/consts.rs +++ b/src/tools/clippy/clippy_utils/src/consts.rs @@ -193,7 +193,7 @@ impl<'tcx> Constant<'tcx> { match (left, right) { (Self::Str(ls), Self::Str(rs)) => Some(ls.cmp(rs)), (Self::Char(l), Self::Char(r)) => Some(l.cmp(r)), - (&Self::Int(l), &Self::Int(r)) => match *cmp_type.kind() { + (&Self::Int(l), &Self::Int(r)) => match cmp_type.kind() { ty::Int(int_ty) => Some(sext(tcx, l, int_ty).cmp(&sext(tcx, r, int_ty))), ty::Uint(_) => Some(l.cmp(&r)), _ => bug!("Not an int type"), @@ -201,7 +201,7 @@ impl<'tcx> Constant<'tcx> { (&Self::F64(l), &Self::F64(r)) => l.partial_cmp(&r), (&Self::F32(l), &Self::F32(r)) => l.partial_cmp(&r), (Self::Bool(l), Self::Bool(r)) => Some(l.cmp(r)), - (Self::Tuple(l), Self::Tuple(r)) if l.len() == r.len() => match *cmp_type.kind() { + (Self::Tuple(l), Self::Tuple(r)) if l.len() == r.len() => match cmp_type.kind() { ty::Tuple(tys) if tys.len() == l.len() => l .iter() .zip(r) @@ -212,7 +212,7 @@ impl<'tcx> Constant<'tcx> { _ => None, }, (Self::Vec(l), Self::Vec(r)) => { - let (ty::Array(cmp_type, _) | ty::Slice(cmp_type)) = *cmp_type.kind() else { + let (ty::Array(cmp_type, _) | ty::Slice(cmp_type)) = cmp_type.kind() else { return None; }; iter::zip(l, r) @@ -223,7 +223,7 @@ impl<'tcx> Constant<'tcx> { (Self::Repeat(lv, ls), Self::Repeat(rv, rs)) => { match Self::partial_cmp( tcx, - match *cmp_type.kind() { + match cmp_type.kind() { ty::Array(ty, _) => ty, _ => return None, }, @@ -236,7 +236,7 @@ impl<'tcx> Constant<'tcx> { }, (Self::Ref(lb), Self::Ref(rb)) => Self::partial_cmp( tcx, - match *cmp_type.kind() { + match cmp_type.kind() { ty::Ref(_, ty, _) => ty, _ => return None, }, @@ -251,7 +251,7 @@ impl<'tcx> Constant<'tcx> { /// Returns the integer value or `None` if `self` or `val_type` is not integer type. pub fn int_value(&self, cx: &LateContext<'_>, val_type: Ty<'_>) -> Option { if let Constant::Int(const_int) = *self { - match *val_type.kind() { + match val_type.kind() { ty::Int(ity) => Some(FullInt::S(sext(cx.tcx, const_int, ity))), ty::Uint(_) => Some(FullInt::U(const_int)), _ => None, @@ -474,7 +474,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> { if let Some(Constant::Adt(constant)) = &self.expr(local_expr) && let ty::Adt(adt_def, _) = constant.ty().kind() && adt_def.is_struct() - && let Some(desired_field) = field_of_struct(*adt_def, self.lcx, *constant, field) + && let Some(desired_field) = field_of_struct(adt_def, self.lcx, *constant, field) { mir_to_const(self.lcx, desired_field) } else { @@ -534,7 +534,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> { Bool(b) => Some(Bool(!b)), Int(value) => { let value = !value; - match *ty.kind() { + match ty.kind() { ty::Int(ity) => Some(Int(unsext(self.lcx.tcx, value as i128, ity))), ty::Uint(ity) => Some(Int(clip(self.lcx.tcx, value, ity))), _ => None, @@ -548,7 +548,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> { use self::Constant::{Int, F32, F64}; match *o { Int(value) => { - let ty::Int(ity) = *ty.kind() else { return None }; + let ty::Int(ity) = ty.kind() else { return None }; let (min, _) = ity.min_max()?; // sign extend let value = sext(self.lcx.tcx, value, ity); @@ -692,7 +692,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> { let l = self.expr(left)?; let r = self.expr(right); match (l, r) { - (Constant::Int(l), Some(Constant::Int(r))) => match *self.typeck_results.expr_ty_opt(left)?.kind() { + (Constant::Int(l), Some(Constant::Int(r))) => match self.typeck_results.expr_ty_opt(left)?.kind() { ty::Int(ity) => { let (ty_min_value, _) = ity.min_max()?; let bits = ity.bits(); diff --git a/src/tools/clippy/clippy_utils/src/lib.rs b/src/tools/clippy/clippy_utils/src/lib.rs index 1147dce6215f4..3e18d44abc662 100644 --- a/src/tools/clippy/clippy_utils/src/lib.rs +++ b/src/tools/clippy/clippy_utils/src/lib.rs @@ -1060,7 +1060,7 @@ pub fn capture_local_usage(cx: &LateContext<'_>, e: &Expr<'_>) -> CaptureKind { .map_or(&[][..], |x| &**x) { if let rustc_ty::RawPtr(_, mutability) | rustc_ty::Ref(_, _, mutability) = - *adjust.last().map_or(target, |a| a.target).kind() + adjust.last().map_or(target, |a| a.target).kind() { return CaptureKind::Ref(mutability); } @@ -2312,10 +2312,10 @@ pub fn is_slice_of_primitives(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option is_recursively_primitive_type(*element_type), - rustc_ty::Ref(_, inner_ty, _) if matches!(inner_ty.kind(), &rustc_ty::Slice(_)) => { + rustc_ty::Slice(element_type) => is_recursively_primitive_type(element_type), + rustc_ty::Ref(_, inner_ty, _) if matches!(inner_ty.kind(), rustc_ty::Slice(_)) => { if let rustc_ty::Slice(element_type) = inner_ty.kind() { - is_recursively_primitive_type(*element_type) + is_recursively_primitive_type(element_type) } else { unreachable!() } diff --git a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs index 81e94725a70cb..70ac25a0291fe 100644 --- a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs +++ b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs @@ -67,7 +67,7 @@ fn check_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, span: Span) -> McfResult { return Err((span, "function pointers in const fn are unstable".into())); }, ty::Dynamic(preds, _, _) => { - for pred in *preds { + for pred in preds { match pred.skip_binder() { ty::ExistentialPredicate::AutoTrait(_) | ty::ExistentialPredicate::Projection(_) => { return Err(( @@ -328,7 +328,7 @@ fn check_terminator<'tcx>( fn_span: _, } => { let fn_ty = func.ty(body, tcx); - if let ty::FnDef(fn_def_id, _) = *fn_ty.kind() { + if let ty::FnDef(fn_def_id, _) = fn_ty.kind() { if !is_const_fn(tcx, fn_def_id, msrv) { return Err(( span, diff --git a/src/tools/clippy/clippy_utils/src/ty.rs b/src/tools/clippy/clippy_utils/src/ty.rs index f0dac6f5d9c46..31ac7ba7694b2 100644 --- a/src/tools/clippy/clippy_utils/src/ty.rs +++ b/src/tools/clippy/clippy_utils/src/ty.rs @@ -91,7 +91,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<' return true; } - if let ty::Alias(ty::Opaque, AliasTy { def_id, .. }) = *inner_ty.kind() { + if let ty::Alias(ty::Opaque, AliasTy { def_id, .. }) = inner_ty.kind() { if !seen.insert(def_id) { return false; } @@ -195,7 +195,7 @@ pub fn has_iter_method(cx: &LateContext<'_>, probably_ref_ty: Ty<'_>) -> Option< ]; let ty_to_check = match probably_ref_ty.kind() { - ty::Ref(_, ty_to_check, _) => *ty_to_check, + ty::Ref(_, ty_to_check, _) => ty_to_check, _ => probably_ref_ty, }; @@ -326,11 +326,11 @@ pub fn has_drop<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool { pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool { match ty.kind() { ty::Adt(adt, _) => cx.tcx.has_attr(adt.did(), sym::must_use), - ty::Foreign(did) => cx.tcx.has_attr(*did, sym::must_use), + ty::Foreign(did) => cx.tcx.has_attr(did, sym::must_use), ty::Slice(ty) | ty::Array(ty, _) | ty::RawPtr(ty, _) | ty::Ref(_, ty, _) => { // for the Array case we don't need to care for the len == 0 case // because we don't want to lint functions returning empty arrays - is_must_use_ty(cx, *ty) + is_must_use_ty(cx, ty) }, ty::Tuple(args) => args.iter().any(|ty| is_must_use_ty(cx, ty)), ty::Alias(ty::Opaque, AliasTy { def_id, .. }) => { @@ -344,7 +344,7 @@ pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool { false }, ty::Dynamic(binder, _, _) => { - for predicate in *binder { + for predicate in binder { if let ty::ExistentialPredicate::Trait(ref trait_ref) = predicate.skip_binder() { if cx.tcx.has_attr(trait_ref.def_id, sym::must_use) { return true; @@ -411,7 +411,7 @@ pub fn is_non_aggregate_primitive_type(ty: Ty<'_>) -> bool { /// Returns `true` if the given type is a primitive (a `bool` or `char`, any integer or /// floating-point number type, a `str`, or an array, slice, or tuple of those types). pub fn is_recursively_primitive_type(ty: Ty<'_>) -> bool { - match *ty.kind() { + match ty.kind() { ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Str => true, ty::Ref(_, inner, _) if inner.is_str() => true, ty::Array(inner_type, _) | ty::Slice(inner_type) => is_recursively_primitive_type(inner_type), @@ -514,7 +514,7 @@ pub fn needs_ordered_drop<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool { // Check if any component type has any. match ty.kind() { ty::Tuple(fields) => fields.iter().any(|ty| needs_ordered_drop_inner(cx, ty, seen)), - ty::Array(ty, _) => needs_ordered_drop_inner(cx, *ty, seen), + ty::Array(ty, _) => needs_ordered_drop_inner(cx, ty, seen), ty::Adt(adt, subs) => adt .all_fields() .map(|f| f.ty(cx.tcx, subs)) @@ -534,7 +534,7 @@ pub fn needs_ordered_drop<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool { pub fn peel_mid_ty_refs(ty: Ty<'_>) -> (Ty<'_>, usize) { fn peel(ty: Ty<'_>, count: usize) -> (Ty<'_>, usize) { if let ty::Ref(_, ty, _) = ty.kind() { - peel(*ty, count + 1) + peel(ty, count + 1) } else { (ty, count) } @@ -547,8 +547,8 @@ pub fn peel_mid_ty_refs(ty: Ty<'_>) -> (Ty<'_>, usize) { pub fn peel_mid_ty_refs_is_mutable(ty: Ty<'_>) -> (Ty<'_>, usize, Mutability) { fn f(ty: Ty<'_>, count: usize, mutability: Mutability) -> (Ty<'_>, usize, Mutability) { match ty.kind() { - ty::Ref(_, ty, Mutability::Mut) => f(*ty, count + 1, mutability), - ty::Ref(_, ty, Mutability::Not) => f(*ty, count + 1, Mutability::Not), + ty::Ref(_, ty, Mutability::Mut) => f(ty, count + 1, mutability), + ty::Ref(_, ty, Mutability::Not) => f(ty, count + 1, Mutability::Not), _ => (ty, count, mutability), } } @@ -576,7 +576,7 @@ pub fn walk_ptrs_hir_ty<'tcx>(ty: &'tcx hir::Ty<'tcx>) -> &'tcx hir::Ty<'tcx> { pub fn walk_ptrs_ty_depth(ty: Ty<'_>) -> (Ty<'_>, usize) { fn inner(ty: Ty<'_>, depth: usize) -> (Ty<'_>, usize) { match ty.kind() { - ty::Ref(_, ty, _) => inner(*ty, depth + 1), + ty::Ref(_, ty, _) => inner(ty, depth + 1), _ => (ty, depth), } } @@ -616,7 +616,7 @@ pub fn is_uninit_value_valid_for_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) /// A fallback for polymorphic types, which are not supported by `check_validity_requirement`. fn is_uninit_value_valid_for_ty_fallback<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool { - match *ty.kind() { + match ty.kind() { // The array length may be polymorphic, let's try the inner type. ty::Array(component, _) => is_uninit_value_valid_for_ty(cx, component), // Peek through tuples and try their fallbacks. @@ -724,7 +724,7 @@ pub fn ty_sig<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option { let decl = id .as_local() @@ -1018,7 +1018,7 @@ pub fn approx_ty_size<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> u64 { (Ok(size), _) => size, (Err(_), ty::Tuple(list)) => list.iter().map(|t| approx_ty_size(cx, t)).sum(), (Err(_), ty::Array(t, n)) => { - n.try_eval_target_usize(cx.tcx, cx.param_env).unwrap_or_default() * approx_ty_size(cx, *t) + n.try_eval_target_usize(cx.tcx, cx.param_env).unwrap_or_default() * approx_ty_size(cx, t) }, (Err(_), ty::Adt(def, subst)) if def.is_struct() => def .variants() @@ -1232,7 +1232,7 @@ impl<'tcx> InteriorMut<'tcx> { Entry::Vacant(v) => v.insert(None), }; - let interior_mut = match *ty.kind() { + let interior_mut = match ty.kind() { ty::RawPtr(inner_ty, _) if !self.ignore_pointers => self.is_interior_mut_ty(cx, inner_ty), ty::Ref(_, inner_ty, _) | ty::Slice(inner_ty) => self.is_interior_mut_ty(cx, inner_ty), ty::Array(inner_ty, size) => { diff --git a/src/tools/clippy/clippy_utils/src/ty/type_certainty/mod.rs b/src/tools/clippy/clippy_utils/src/ty/type_certainty/mod.rs index 8021930345026..fdf6a43b52931 100644 --- a/src/tools/clippy/clippy_utils/src/ty/type_certainty/mod.rs +++ b/src/tools/clippy/clippy_utils/src/ty/type_certainty/mod.rs @@ -284,7 +284,7 @@ fn type_is_inferable_from_arguments(cx: &LateContext<'_>, expr: &Expr<'_>) -> bo ExprKind::Call(callee, _) => { let callee_ty = cx.typeck_results().expr_ty(callee); if let ty::FnDef(callee_def_id, _) = callee_ty.kind() { - Some(*callee_def_id) + Some(callee_def_id) } else { None } diff --git a/src/tools/clippy/clippy_utils/src/visitors.rs b/src/tools/clippy/clippy_utils/src/visitors.rs index 90b56297bb556..29acc35fd9e30 100644 --- a/src/tools/clippy/clippy_utils/src/visitors.rs +++ b/src/tools/clippy/clippy_utils/src/visitors.rs @@ -426,7 +426,7 @@ pub fn is_expr_unsafe<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> bool { { self.is_unsafe = true; }, - ExprKind::Call(func, _) => match *self.cx.typeck_results().expr_ty(func).peel_refs().kind() { + ExprKind::Call(func, _) => match self.cx.typeck_results().expr_ty(func).peel_refs().kind() { ty::FnDef(id, _) if self.cx.tcx.fn_sig(id).skip_binder().safety() == Safety::Unsafe => { self.is_unsafe = true; }, diff --git a/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs b/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs index e1c06b2bd98e5..ea401d10973d8 100644 --- a/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs +++ b/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs @@ -387,7 +387,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { ) -> InterpResult<'tcx, ImmTy<'tcx, Provenance>> { let this = self.eval_context_mut(); let new_perm = match val.layout.ty.kind() { - &ty::Ref(_, pointee, mutability) => + ty::Ref(_, pointee, mutability) => NewPermission::from_ref_ty(pointee, mutability, kind, this), _ => None, }; @@ -474,7 +474,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Check the type of this value to see what to do with it (retag, or recurse). match place.layout.ty.kind() { - &ty::Ref(_, pointee, mutability) => { + ty::Ref(_, pointee, mutability) => { let new_perm = NewPermission::from_ref_ty(pointee, mutability, self.kind, self.ecx); self.retag_ptr_inplace(place, new_perm)?; diff --git a/src/tools/miri/src/intrinsics/simd.rs b/src/tools/miri/src/intrinsics/simd.rs index 8ba4964ff896b..000c8fca4c4b5 100644 --- a/src/tools/miri/src/intrinsics/simd.rs +++ b/src/tools/miri/src/intrinsics/simd.rs @@ -456,7 +456,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // The mask must be an integer or an array. assert!( mask.layout.ty.is_integral() - || matches!(mask.layout.ty.kind(), ty::Array(elemty, _) if elemty == &this.tcx.types.u8) + || matches!(mask.layout.ty.kind(), ty::Array(elemty, _) if elemty == this.tcx.types.u8) ); assert!(bitmask_len <= 64); assert_eq!(bitmask_len, mask.layout.size.bits()); @@ -502,7 +502,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Returns either an unsigned integer or array of `u8`. assert!( dest.layout.ty.is_integral() - || matches!(dest.layout.ty.kind(), ty::Array(elemty, _) if elemty == &this.tcx.types.u8) + || matches!(dest.layout.ty.kind(), ty::Array(elemty, _) if elemty == this.tcx.types.u8) ); assert!(bitmask_len <= 64); assert_eq!(bitmask_len, dest.layout.size.bits());