From 4d9737621693959f0757587451e4bc12129288ee Mon Sep 17 00:00:00 2001 From: Bram van den Heuvel Date: Fri, 9 Oct 2020 22:56:28 +0200 Subject: [PATCH] Rename ty::TyKind to ty::TyData, Ty::kind to Ty::data --- compiler/rustc_codegen_llvm/src/builder.rs | 2 +- compiler/rustc_codegen_llvm/src/consts.rs | 2 +- .../src/debuginfo/metadata.rs | 38 ++-- .../rustc_codegen_llvm/src/debuginfo/mod.rs | 4 +- compiler/rustc_codegen_llvm/src/intrinsic.rs | 50 ++--- compiler/rustc_codegen_llvm/src/type_of.rs | 10 +- compiler/rustc_codegen_ssa/src/base.rs | 8 +- .../src/debuginfo/type_names.rs | 2 +- compiler/rustc_codegen_ssa/src/glue.rs | 4 +- compiler/rustc_codegen_ssa/src/mir/analyze.rs | 2 +- compiler/rustc_codegen_ssa/src/mir/block.rs | 8 +- .../rustc_codegen_ssa/src/mir/intrinsic.rs | 6 +- compiler/rustc_codegen_ssa/src/mir/mod.rs | 2 +- compiler/rustc_codegen_ssa/src/mir/place.rs | 2 +- compiler/rustc_codegen_ssa/src/mir/rvalue.rs | 6 +- .../rustc_codegen_ssa/src/traits/type_.rs | 2 +- .../src/infer/canonical/canonicalizer.rs | 2 +- .../src/infer/canonical/query_response.rs | 2 +- compiler/rustc_infer/src/infer/combine.rs | 6 +- compiler/rustc_infer/src/infer/equate.rs | 2 +- .../src/infer/error_reporting/mod.rs | 26 +-- .../infer/error_reporting/need_type_info.rs | 14 +- .../nice_region_error/static_impl_trait.rs | 2 +- .../error_reporting/nice_region_error/util.rs | 2 +- compiler/rustc_infer/src/infer/freshen.rs | 2 +- compiler/rustc_infer/src/infer/fudge.rs | 2 +- compiler/rustc_infer/src/infer/lattice.rs | 2 +- compiler/rustc_infer/src/infer/mod.rs | 8 +- .../rustc_infer/src/infer/nll_relate/mod.rs | 8 +- .../src/infer/outlives/obligations.rs | 2 +- .../rustc_infer/src/infer/outlives/verify.rs | 4 +- compiler/rustc_infer/src/infer/resolve.rs | 4 +- compiler/rustc_infer/src/infer/sub.rs | 2 +- .../rustc_infer/src/infer/type_variable.rs | 2 +- compiler/rustc_lint/src/array_into_iter.rs | 6 +- compiler/rustc_lint/src/builtin.rs | 22 +- compiler/rustc_lint/src/context.rs | 2 +- compiler/rustc_lint/src/internal.rs | 24 +-- compiler/rustc_lint/src/lib.rs | 6 +- compiler/rustc_lint/src/types.rs | 22 +- compiler/rustc_lint/src/unused.rs | 2 +- compiler/rustc_metadata/src/rmeta/encoder.rs | 4 +- compiler/rustc_middle/src/ich/impls_ty.rs | 6 +- compiler/rustc_middle/src/mir/mod.rs | 2 +- compiler/rustc_middle/src/mir/tcx.rs | 4 +- compiler/rustc_middle/src/ty/_match.rs | 2 +- compiler/rustc_middle/src/ty/cast.rs | 2 +- compiler/rustc_middle/src/ty/codec.rs | 10 +- compiler/rustc_middle/src/ty/context.rs | 56 +++--- compiler/rustc_middle/src/ty/diagnostics.rs | 10 +- compiler/rustc_middle/src/ty/error.rs | 16 +- compiler/rustc_middle/src/ty/fast_reject.rs | 2 +- compiler/rustc_middle/src/ty/flags.rs | 10 +- compiler/rustc_middle/src/ty/fold.rs | 6 +- .../rustc_middle/src/ty/inhabitedness/mod.rs | 4 +- compiler/rustc_middle/src/ty/instance.rs | 2 +- compiler/rustc_middle/src/ty/layout.rs | 28 +-- compiler/rustc_middle/src/ty/mod.rs | 18 +- compiler/rustc_middle/src/ty/outlives.rs | 2 +- compiler/rustc_middle/src/ty/print/mod.rs | 2 +- compiler/rustc_middle/src/ty/print/pretty.rs | 20 +- compiler/rustc_middle/src/ty/relate.rs | 6 +- .../rustc_middle/src/ty/structural_impls.rs | 6 +- compiler/rustc_middle/src/ty/sty.rs | 144 ++++++------- compiler/rustc_middle/src/ty/subst.rs | 2 +- compiler/rustc_middle/src/ty/util.rs | 44 ++-- compiler/rustc_middle/src/ty/walk.rs | 2 +- .../diagnostics/conflict_errors.rs | 22 +- .../diagnostics/explain_borrow.rs | 4 +- .../src/borrow_check/diagnostics/mod.rs | 18 +- .../borrow_check/diagnostics/move_errors.rs | 4 +- .../diagnostics/mutability_errors.rs | 12 +- .../borrow_check/diagnostics/region_errors.rs | 6 +- .../borrow_check/diagnostics/region_name.rs | 2 +- compiler/rustc_mir/src/borrow_check/mod.rs | 8 +- .../rustc_mir/src/borrow_check/place_ext.rs | 2 +- .../src/borrow_check/places_conflict.rs | 4 +- .../rustc_mir/src/borrow_check/prefixes.rs | 2 +- .../src/borrow_check/type_check/mod.rs | 36 ++-- .../src/borrow_check/universal_regions.rs | 4 +- .../rustc_mir/src/const_eval/eval_queries.rs | 6 +- compiler/rustc_mir/src/const_eval/mod.rs | 4 +- .../src/dataflow/drop_flag_effects.rs | 2 +- compiler/rustc_mir/src/dataflow/impls/mod.rs | 2 +- .../src/dataflow/move_paths/builder.rs | 6 +- compiler/rustc_mir/src/interpret/cast.rs | 24 +-- .../rustc_mir/src/interpret/eval_context.rs | 2 +- compiler/rustc_mir/src/interpret/intern.rs | 6 +- .../rustc_mir/src/interpret/intrinsics.rs | 2 +- .../src/interpret/intrinsics/type_name.rs | 2 +- compiler/rustc_mir/src/interpret/operand.rs | 2 +- compiler/rustc_mir/src/interpret/operator.rs | 4 +- compiler/rustc_mir/src/interpret/place.rs | 6 +- .../rustc_mir/src/interpret/terminator.rs | 6 +- compiler/rustc_mir/src/interpret/util.rs | 4 +- compiler/rustc_mir/src/interpret/validity.rs | 14 +- compiler/rustc_mir/src/interpret/visitor.rs | 2 +- .../rustc_mir/src/monomorphize/collector.rs | 10 +- .../src/monomorphize/polymorphize.rs | 4 +- compiler/rustc_mir/src/shim.rs | 6 +- compiler/rustc_mir/src/transform/add_retag.rs | 2 +- .../src/transform/check_consts/qualifs.rs | 2 +- .../src/transform/check_consts/validation.rs | 14 +- .../rustc_mir/src/transform/check_unsafety.rs | 6 +- .../rustc_mir/src/transform/const_prop.rs | 2 +- compiler/rustc_mir/src/transform/dest_prop.rs | 2 +- compiler/rustc_mir/src/transform/generator.rs | 6 +- compiler/rustc_mir/src/transform/inline.rs | 6 +- .../rustc_mir/src/transform/instcombine.rs | 4 +- .../rustc_mir/src/transform/promote_consts.rs | 16 +- .../rustc_mir/src/transform/rustc_peek.rs | 4 +- .../rustc_mir/src/transform/simplify_try.rs | 2 +- compiler/rustc_mir/src/transform/validate.rs | 2 +- compiler/rustc_mir/src/util/alignment.rs | 2 +- .../rustc_mir/src/util/borrowck_errors.rs | 2 +- .../rustc_mir/src/util/elaborate_drops.rs | 2 +- compiler/rustc_mir/src/util/find_self_call.rs | 2 +- compiler/rustc_mir/src/util/pretty.rs | 4 +- .../src/build/expr/as_place.rs | 4 +- .../rustc_mir_build/src/build/expr/into.rs | 2 +- .../src/build/matches/simplify.rs | 2 +- .../rustc_mir_build/src/build/matches/test.rs | 8 +- .../rustc_mir_build/src/build/matches/util.rs | 2 +- compiler/rustc_mir_build/src/build/mod.rs | 10 +- compiler/rustc_mir_build/src/lints.rs | 2 +- compiler/rustc_mir_build/src/thir/constant.rs | 4 +- compiler/rustc_mir_build/src/thir/cx/expr.rs | 10 +- .../src/thir/pattern/_match.rs | 34 ++-- .../src/thir/pattern/check_match.rs | 10 +- .../src/thir/pattern/const_to_pat.rs | 4 +- .../rustc_mir_build/src/thir/pattern/mod.rs | 18 +- compiler/rustc_mir_build/src/thir/util.rs | 2 +- compiler/rustc_passes/src/dead.rs | 6 +- compiler/rustc_passes/src/intrinsicck.rs | 12 +- compiler/rustc_passes/src/liveness.rs | 2 +- compiler/rustc_privacy/src/lib.rs | 4 +- compiler/rustc_save_analysis/src/lib.rs | 6 +- compiler/rustc_span/src/symbol.rs | 2 +- compiler/rustc_symbol_mangling/src/legacy.rs | 6 +- compiler/rustc_symbol_mangling/src/v0.rs | 6 +- .../rustc_trait_selection/src/opaque_types.rs | 6 +- .../src/traits/auto_trait.rs | 4 +- .../src/traits/coherence.rs | 6 +- .../src/traits/error_reporting/mod.rs | 20 +- .../error_reporting/on_unimplemented.rs | 4 +- .../src/traits/error_reporting/suggestions.rs | 30 +-- .../rustc_trait_selection/src/traits/misc.rs | 2 +- .../src/traits/object_safety.rs | 2 +- .../src/traits/project.rs | 8 +- .../src/traits/query/dropck_outlives.rs | 2 +- .../src/traits/query/normalize.rs | 2 +- .../src/traits/select/candidate_assembly.rs | 14 +- .../src/traits/select/confirmation.rs | 14 +- .../src/traits/select/mod.rs | 8 +- .../src/traits/structural_match.rs | 2 +- .../rustc_trait_selection/src/traits/wf.rs | 10 +- compiler/rustc_traits/src/chalk/db.rs | 2 +- compiler/rustc_traits/src/chalk/lowering.rs | 16 +- compiler/rustc_traits/src/dropck_outlives.rs | 4 +- compiler/rustc_ty/src/instance.rs | 8 +- compiler/rustc_ty/src/needs_drop.rs | 4 +- compiler/rustc_ty/src/ty.rs | 6 +- compiler/rustc_typeck/src/astconv/mod.rs | 4 +- compiler/rustc_typeck/src/check/autoderef.rs | 2 +- compiler/rustc_typeck/src/check/callee.rs | 6 +- compiler/rustc_typeck/src/check/cast.rs | 18 +- compiler/rustc_typeck/src/check/check.rs | 34 ++-- compiler/rustc_typeck/src/check/closure.rs | 6 +- compiler/rustc_typeck/src/check/coercion.rs | 38 ++-- .../rustc_typeck/src/check/compare_method.rs | 2 +- compiler/rustc_typeck/src/check/demand.rs | 12 +- compiler/rustc_typeck/src/check/dropck.rs | 2 +- .../rustc_typeck/src/check/expectation.rs | 2 +- compiler/rustc_typeck/src/check/expr.rs | 38 ++-- compiler/rustc_typeck/src/check/fn_ctxt.rs | 32 +-- .../rustc_typeck/src/check/method/confirm.rs | 4 +- compiler/rustc_typeck/src/check/method/mod.rs | 4 +- .../rustc_typeck/src/check/method/probe.rs | 14 +- .../rustc_typeck/src/check/method/suggest.rs | 28 +-- compiler/rustc_typeck/src/check/mod.rs | 10 +- compiler/rustc_typeck/src/check/op.rs | 36 ++-- compiler/rustc_typeck/src/check/pat.rs | 30 +-- compiler/rustc_typeck/src/check/place_op.rs | 10 +- compiler/rustc_typeck/src/check/regionck.rs | 6 +- compiler/rustc_typeck/src/check/upvar.rs | 4 +- compiler/rustc_typeck/src/check/wfcheck.rs | 14 +- compiler/rustc_typeck/src/check/writeback.rs | 4 +- .../rustc_typeck/src/coherence/builtin.rs | 8 +- .../src/coherence/inherent_impls.rs | 8 +- compiler/rustc_typeck/src/coherence/mod.rs | 2 +- compiler/rustc_typeck/src/coherence/orphan.rs | 8 +- compiler/rustc_typeck/src/collect.rs | 4 +- compiler/rustc_typeck/src/collect/type_of.rs | 4 +- .../src/constrained_generic_params.rs | 2 +- compiler/rustc_typeck/src/expr_use_visitor.rs | 2 +- compiler/rustc_typeck/src/lib.rs | 4 +- .../rustc_typeck/src/mem_categorization.rs | 8 +- .../src/outlives/implicit_infer.rs | 2 +- .../rustc_typeck/src/variance/constraints.rs | 4 +- compiler/rustc_typeck/src/variance/solve.rs | 2 +- src/librustdoc/clean/blanket_impl.rs | 2 +- src/librustdoc/clean/mod.rs | 12 +- src/librustdoc/clean/utils.rs | 6 +- .../passes/collect_intra_doc_links.rs | 8 +- .../internal-lints/ty_tydata_usage.rs | 48 +++++ .../internal-lints/ty_tydata_usage.stderr | 190 ++++++++++++++++++ .../internal-lints/ty_tykind_usage.rs | 48 ----- .../internal-lints/ty_tykind_usage.stderr | 190 ------------------ src/tools/clippy/clippy_dev/src/lib.rs | 2 +- .../clippy_lints/src/atomic_ordering.rs | 2 +- .../clippy_lints/src/await_holding_lock.rs | 2 +- .../clippy/clippy_lints/src/bytecount.rs | 2 +- src/tools/clippy/clippy_lints/src/consts.rs | 24 +-- .../clippy_lints/src/default_trait_access.rs | 2 +- src/tools/clippy/clippy_lints/src/derive.rs | 8 +- src/tools/clippy/clippy_lints/src/doc.rs | 4 +- .../clippy_lints/src/drop_forget_ref.rs | 2 +- .../clippy/clippy_lints/src/enum_clike.rs | 4 +- .../clippy/clippy_lints/src/eta_reduction.rs | 8 +- .../clippy_lints/src/eval_order_dependence.rs | 4 +- .../src/float_equality_without_abs.rs | 4 +- .../clippy/clippy_lints/src/float_literal.rs | 2 +- .../src/floating_point_arithmetic.rs | 2 +- src/tools/clippy/clippy_lints/src/format.rs | 2 +- .../clippy/clippy_lints/src/functions.rs | 2 +- .../clippy_lints/src/future_not_send.rs | 2 +- .../clippy/clippy_lints/src/identity_op.rs | 2 +- .../clippy_lints/src/indexing_slicing.rs | 4 +- .../clippy_lints/src/large_const_arrays.rs | 2 +- .../clippy_lints/src/large_stack_arrays.rs | 2 +- src/tools/clippy/clippy_lints/src/len_zero.rs | 2 +- src/tools/clippy/clippy_lints/src/loops.rs | 12 +- .../clippy/clippy_lints/src/manual_strip.rs | 2 +- .../clippy/clippy_lints/src/map_clone.rs | 4 +- .../clippy/clippy_lints/src/map_unit_fn.rs | 4 +- src/tools/clippy/clippy_lints/src/matches.rs | 16 +- .../src/methods/inefficient_to_string.rs | 4 +- .../clippy/clippy_lints/src/methods/mod.rs | 54 ++--- src/tools/clippy/clippy_lints/src/misc.rs | 6 +- .../clippy_lints/src/modulo_arithmetic.rs | 2 +- src/tools/clippy/clippy_lints/src/mut_key.rs | 4 +- src/tools/clippy/clippy_lints/src/mut_mut.rs | 2 +- .../clippy/clippy_lints/src/mut_reference.rs | 4 +- .../src/mutable_debug_assertion.rs | 2 +- .../clippy/clippy_lints/src/mutex_atomic.rs | 6 +- .../clippy_lints/src/needless_borrow.rs | 6 +- .../src/needless_pass_by_value.rs | 2 +- .../clippy_lints/src/needless_update.rs | 2 +- .../clippy_lints/src/pattern_type_mismatch.rs | 14 +- src/tools/clippy/clippy_lints/src/ptr.rs | 2 +- src/tools/clippy/clippy_lints/src/ranges.rs | 2 +- .../clippy_lints/src/redundant_clone.rs | 4 +- src/tools/clippy/clippy_lints/src/shadow.rs | 2 +- src/tools/clippy/clippy_lints/src/swap.rs | 4 +- .../clippy_lints/src/to_digit_is_some.rs | 2 +- .../clippy/clippy_lints/src/transmute.rs | 12 +- .../src/trivially_copy_pass_by_ref.rs | 4 +- src/tools/clippy/clippy_lints/src/try_err.rs | 12 +- src/tools/clippy/clippy_lints/src/types.rs | 40 ++-- .../src/unit_return_expecting_ord.rs | 2 +- .../clippy_lints/src/unnamed_address.rs | 4 +- .../clippy_lints/src/unnecessary_sort_by.rs | 2 +- .../clippy_lints/src/useless_conversion.rs | 4 +- .../clippy/clippy_lints/src/utils/mod.rs | 30 +-- .../src/utils/qualify_min_const_fn.rs | 8 +- src/tools/clippy/clippy_lints/src/vec.rs | 6 +- 266 files changed, 1340 insertions(+), 1340 deletions(-) create mode 100644 src/test/ui-fulldeps/internal-lints/ty_tydata_usage.rs create mode 100644 src/test/ui-fulldeps/internal-lints/ty_tydata_usage.stderr delete mode 100644 src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs delete mode 100644 src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs index f496f3283da78..13f1e69d45406 100644 --- a/compiler/rustc_codegen_llvm/src/builder.rs +++ b/compiler/rustc_codegen_llvm/src/builder.rs @@ -307,7 +307,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { use rustc_ast::UintTy::*; use rustc_middle::ty::{Int, Uint}; - let new_kind = match ty.kind() { + let new_kind = match ty.data() { Int(t @ Isize) => Int(t.normalize(self.tcx.sess.target.ptr_width)), Uint(t @ Usize) => Uint(t.normalize(self.tcx.sess.target.ptr_width)), t @ (Uint(_) | Int(_)) => t.clone(), diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs index 6d3582d30276e..aba9b422e022d 100644 --- a/compiler/rustc_codegen_llvm/src/consts.rs +++ b/compiler/rustc_codegen_llvm/src/consts.rs @@ -121,7 +121,7 @@ fn check_and_apply_linkage( // extern "C" fn() from being non-null, so we can't just declare a // static and call it a day. Some linkages (like weak) will make it such // that the static actually has a null value. - let llty2 = if let ty::RawPtr(ref mt) = ty.kind() { + let llty2 = if let ty::RawPtr(ref mt) = ty.data() { cx.layout_of(mt.ty).llvm_type(cx) } else { cx.sess().span_fatal( diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index 987149cb4c25c..5cf665772d385 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -343,7 +343,7 @@ fn fixed_vec_metadata( let (size, align) = cx.size_and_align_of(array_or_slice_type); - let upper_bound = match array_or_slice_type.kind() { + let upper_bound = match array_or_slice_type.data() { ty::Array(_, len) => len.eval_usize(cx.tcx, ty::ParamEnv::reveal_all()) as c_longlong, _ => -1, }; @@ -432,7 +432,7 @@ fn subroutine_type_metadata( let signature_metadata: Vec<_> = iter::once( // return type - match signature.output().kind() { + match signature.output().data() { ty::Tuple(ref tys) if tys.is_empty() => None, _ => Some(type_metadata(cx, signature.output(), span)), }, @@ -472,7 +472,7 @@ fn trait_pointer_metadata( // type is assigned the correct name, size, namespace, and source location. // However, it does not describe the trait's methods. - let containing_scope = match trait_type.kind() { + let containing_scope = match trait_type.data() { ty::Dynamic(ref data, ..) => { data.principal_def_id().map(|did| get_namespace_for_item(cx, did)) } @@ -572,7 +572,7 @@ pub fn type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>, usage_site_span: Sp debug!("type_metadata: {:?}", t); - let ptr_metadata = |ty: Ty<'tcx>| match *ty.kind() { + let ptr_metadata = |ty: Ty<'tcx>| match *ty.data() { ty::Slice(typ) => Ok(vec_slice_metadata(cx, t, typ, unique_type_id, usage_site_span)), ty::Str => Ok(vec_slice_metadata(cx, t, cx.tcx.types.u8, unique_type_id, usage_site_span)), ty::Dynamic(..) => Ok(MetadataCreationResult::new( @@ -592,7 +592,7 @@ pub fn type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>, usage_site_span: Sp } }; - let MetadataCreationResult { metadata, already_stored_in_typemap } = match *t.kind() { + let MetadataCreationResult { metadata, already_stored_in_typemap } = match *t.data() { ty::Never | ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) => { MetadataCreationResult::new(basic_type_metadata(cx, t), false) } @@ -876,7 +876,7 @@ fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType { // .natvis visualizers (and perhaps other existing native debuggers?) let msvc_like_names = cx.tcx.sess.target.target.options.is_like_msvc; - let (name, encoding) = match t.kind() { + let (name, encoding) = match t.data() { ty::Never => ("!", DW_ATE_unsigned), ty::Tuple(ref elements) if elements.is_empty() => ("()", DW_ATE_unsigned), ty::Bool => ("bool", DW_ATE_boolean), @@ -904,7 +904,7 @@ fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType { return ty_metadata; } - let typedef_name = match t.kind() { + let typedef_name = match t.data() { ty::Int(int_ty) => int_ty.name_str(), ty::Uint(uint_ty) => uint_ty.name_str(), ty::Float(float_ty) => float_ty.name_str(), @@ -1239,7 +1239,7 @@ fn prepare_struct_metadata( ) -> RecursiveTypeDescription<'ll, 'tcx> { let struct_name = compute_debuginfo_type_name(cx.tcx, struct_type, false); - let (struct_def_id, variant) = match struct_type.kind() { + let (struct_def_id, variant) = match struct_type.data() { ty::Adt(def, _) => (def.did, def.non_enum_variant()), _ => bug!("prepare_struct_metadata on a non-ADT"), }; @@ -1373,7 +1373,7 @@ fn prepare_union_metadata( ) -> RecursiveTypeDescription<'ll, 'tcx> { let union_name = compute_debuginfo_type_name(cx.tcx, union_type, false); - let (union_def_id, variant) = match union_type.kind() { + let (union_def_id, variant) = match union_type.data() { ty::Adt(def, _) => (def.did, def.non_enum_variant()), _ => bug!("prepare_union_metadata on a non-ADT"), }; @@ -1457,14 +1457,14 @@ struct EnumMemberDescriptionFactory<'ll, 'tcx> { impl EnumMemberDescriptionFactory<'ll, 'tcx> { fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>) -> Vec> { - let generator_variant_info_data = match *self.enum_type.kind() { + let generator_variant_info_data = match *self.enum_type.data() { ty::Generator(def_id, ..) => { Some(generator_layout_and_saved_local_names(cx.tcx, def_id)) } _ => None, }; - let variant_info_for = |index: VariantIdx| match *self.enum_type.kind() { + let variant_info_for = |index: VariantIdx| match *self.enum_type.data() { ty::Adt(adt, _) => VariantInfo::Adt(&adt.variants[index]), ty::Generator(def_id, _, _) => { let (generator_layout, generator_saved_local_names) = @@ -1486,14 +1486,14 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> { } else { type_metadata(cx, self.enum_type, self.span) }; - let flags = match self.enum_type.kind() { + let flags = match self.enum_type.data() { ty::Generator(..) => DIFlags::FlagArtificial, _ => DIFlags::FlagZero, }; match self.layout.variants { Variants::Single { index } => { - if let ty::Adt(adt, _) = self.enum_type.kind() { + if let ty::Adt(adt, _) = self.enum_type.data() { if adt.variants.is_empty() { return vec![]; } @@ -1941,7 +1941,7 @@ fn prepare_enum_metadata( let tcx = cx.tcx; let enum_name = compute_debuginfo_type_name(tcx, enum_type, false); // FIXME(tmandry): This doesn't seem to have any effect. - let enum_flags = match enum_type.kind() { + let enum_flags = match enum_type.data() { ty::Generator(..) => DIFlags::FlagArtificial, _ => DIFlags::FlagZero, }; @@ -1956,13 +1956,13 @@ fn prepare_enum_metadata( let file_metadata = unknown_file_metadata(cx); let discriminant_type_metadata = |discr: Primitive| { - let enumerators_metadata: Vec<_> = match enum_type.kind() { + let enumerators_metadata: Vec<_> = match enum_type.data() { ty::Adt(def, _) => def .discriminants(tcx) .zip(&def.variants) .map(|((_, discr), v)| { let name = v.ident.as_str(); - let is_unsigned = match discr.ty.kind() { + let is_unsigned = match discr.ty.data() { ty::Int(_) => false, ty::Uint(_) => true, _ => bug!("non integer discriminant"), @@ -2011,7 +2011,7 @@ fn prepare_enum_metadata( type_metadata(cx, discr.to_ty(tcx), rustc_span::DUMMY_SP); let item_name; - let discriminant_name = match enum_type.kind() { + let discriminant_name = match enum_type.data() { ty::Adt(..) => { item_name = tcx.item_name(enum_def_id).as_str(); &*item_name @@ -2104,7 +2104,7 @@ fn prepare_enum_metadata( ); } - let discriminator_name = match enum_type.kind() { + let discriminator_name = match enum_type.data() { ty::Generator(..) => "__state", _ => "", }; @@ -2327,7 +2327,7 @@ fn set_members_of_composite_type( /// Computes the type parameters for a type, if any, for the given metadata. fn compute_type_parameters(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>) -> Option<&'ll DIArray> { - if let ty::Adt(def, substs) = *ty.kind() { + if let ty::Adt(def, substs) = *ty.data() { if substs.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/mod.rs b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs index 7cdd366175dad..fdefcd4011a8d 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs @@ -361,7 +361,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { // already inaccurate due to ABI adjustments (see #42800). signature.extend(fn_abi.args.iter().map(|arg| { let t = arg.layout.ty; - let t = match t.kind() { + let t = match t.data() { ty::Array(ct, _) if (*ct == cx.tcx.types.u8) || cx.layout_of(ct).is_zst() => { @@ -467,7 +467,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { // Only "class" methods are generally understood by LLVM, // so avoid methods on other types (e.g., `<*mut T>::null`). - match impl_self_ty.kind() { + match impl_self_ty.data() { ty::Adt(def, ..) if !def.is_box() => { // Again, only create type information if full debuginfo is enabled if cx.sess().opts.debuginfo == DebugInfo::Full diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index e76e86f56510b..2b374a1bbe364 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -85,7 +85,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> { let tcx = self.tcx; let callee_ty = instance.ty(tcx, ty::ParamEnv::reveal_all()); - let (def_id, substs) = match *callee_ty.kind() { + let (def_id, substs) = match *callee_ty.data() { ty::FnDef(def_id, substs) => (def_id, substs), _ => bug!("expected fn item type, found {}", callee_ty), }; @@ -783,7 +783,7 @@ fn generic_simd_intrinsic( if name == sym::simd_select_bitmask { let in_ty = arg_tys[0]; - let m_len = match in_ty.kind() { + let m_len = match in_ty.data() { // Note that this `.unwrap()` crashes for isize/usize, that's sort // of intentional as there's not currently a use case for that. ty::Int(i) => i.bit_width().unwrap(), @@ -952,7 +952,7 @@ fn generic_simd_intrinsic( m_len, v_len ); - match m_elem_ty.kind() { + match m_elem_ty.data() { ty::Int(_) => {} _ => return_error!("mask element type is `{}`, expected `i_`", m_elem_ty), } @@ -971,13 +971,13 @@ fn generic_simd_intrinsic( // If the vector has less than 8 lanes, an u8 is returned with zeroed // trailing bits. let expected_int_bits = in_len.max(8); - match ret_ty.kind() { + match ret_ty.data() { ty::Uint(i) if i.bit_width() == Some(expected_int_bits) => (), _ => return_error!("bitmask `{}`, expected `u{}`", ret_ty, expected_int_bits), } // Integer vector : - let (i_xn, in_elem_bitwidth) = match in_elem.kind() { + let (i_xn, in_elem_bitwidth) = match in_elem.data() { ty::Int(i) => { (args[0].immediate(), i.bit_width().unwrap_or(bx.data_layout().pointer_size.bits())) } @@ -1034,7 +1034,7 @@ fn generic_simd_intrinsic( } } } - let ety = match in_elem.kind() { + let ety = match in_elem.data() { ty::Float(f) if f.bit_width() == 32 => { if in_len < 2 || in_len > 16 { return_error!( @@ -1128,7 +1128,7 @@ fn generic_simd_intrinsic( // https://github.com/llvm-mirror/llvm/blob/master/include/llvm/IR/Intrinsics.h#L81 fn llvm_vector_str(elem_ty: Ty<'_>, vec_len: u64, no_pointers: usize) -> String { let p0s: String = "p0".repeat(no_pointers); - match *elem_ty.kind() { + match *elem_ty.data() { ty::Int(v) => format!("v{}{}i{}", vec_len, p0s, v.bit_width().unwrap()), ty::Uint(v) => format!("v{}{}i{}", vec_len, p0s, v.bit_width().unwrap()), ty::Float(v) => format!("v{}{}f{}", vec_len, p0s, v.bit_width()), @@ -1143,7 +1143,7 @@ fn generic_simd_intrinsic( mut no_pointers: usize, ) -> &'ll Type { // FIXME: use cx.layout_of(ty).llvm_type() ? - let mut elem_ty = match *elem_ty.kind() { + let mut elem_ty = match *elem_ty.data() { 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), @@ -1196,7 +1196,7 @@ fn generic_simd_intrinsic( // This counts how many pointers fn ptr_count(t: Ty<'_>) -> usize { - match t.kind() { + match t.data() { ty::RawPtr(p) => 1 + ptr_count(p.ty), _ => 0, } @@ -1204,7 +1204,7 @@ fn generic_simd_intrinsic( // Non-ptr type fn non_ptr(t: Ty<'_>) -> Ty<'_> { - match t.kind() { + match t.data() { ty::RawPtr(p) => non_ptr(p.ty), _ => t, } @@ -1212,7 +1212,7 @@ fn generic_simd_intrinsic( // The second argument must be a simd vector with an element type that's a pointer // to the element type of the first argument - let (pointer_count, underlying_ty) = match arg_tys[1].simd_type(tcx).kind() { + let (pointer_count, underlying_ty) = match arg_tys[1].simd_type(tcx).data() { ty::RawPtr(p) if p.ty == in_elem => { (ptr_count(arg_tys[1].simd_type(tcx)), non_ptr(arg_tys[1].simd_type(tcx))) } @@ -1237,7 +1237,7 @@ fn generic_simd_intrinsic( assert_eq!(underlying_ty, non_ptr(arg_tys[0].simd_type(tcx))); // The element type of the third argument must be a signed integer type of any width: - match arg_tys[2].simd_type(tcx).kind() { + match arg_tys[2].simd_type(tcx).data() { ty::Int(_) => (), _ => { require!( @@ -1319,7 +1319,7 @@ fn generic_simd_intrinsic( // This counts how many pointers fn ptr_count(t: Ty<'_>) -> usize { - match t.kind() { + match t.data() { ty::RawPtr(p) => 1 + ptr_count(p.ty), _ => 0, } @@ -1327,7 +1327,7 @@ fn generic_simd_intrinsic( // Non-ptr type fn non_ptr(t: Ty<'_>) -> Ty<'_> { - match t.kind() { + match t.data() { ty::RawPtr(p) => non_ptr(p.ty), _ => t, } @@ -1335,7 +1335,7 @@ fn generic_simd_intrinsic( // The second argument must be a simd vector with an element type that's a pointer // to the element type of the first argument - let (pointer_count, underlying_ty) = match arg_tys[1].simd_type(tcx).kind() { + let (pointer_count, underlying_ty) = match arg_tys[1].simd_type(tcx).data() { ty::RawPtr(p) if p.ty == in_elem && p.mutbl == hir::Mutability::Mut => { (ptr_count(arg_tys[1].simd_type(tcx)), non_ptr(arg_tys[1].simd_type(tcx))) } @@ -1360,7 +1360,7 @@ fn generic_simd_intrinsic( assert_eq!(underlying_ty, non_ptr(arg_tys[0].simd_type(tcx))); // The element type of the third argument must be a signed integer type of any width: - match arg_tys[2].simd_type(tcx).kind() { + match arg_tys[2].simd_type(tcx).data() { ty::Int(_) => (), _ => { require!( @@ -1416,7 +1416,7 @@ fn generic_simd_intrinsic( in_ty, ret_ty ); - return match in_elem.kind() { + return match in_elem.data() { ty::Int(_) | ty::Uint(_) => { let r = bx.$integer_reduce(args[0].immediate()); if $ordered { @@ -1488,7 +1488,7 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#, in_ty, ret_ty ); - return match in_elem.kind() { + return match in_elem.data() { ty::Int(_i) => Ok(bx.$int_red(args[0].immediate(), true)), ty::Uint(_u) => Ok(bx.$int_red(args[0].immediate(), false)), ty::Float(_f) => Ok(bx.$float_red(args[0].immediate())), @@ -1523,7 +1523,7 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#, ); args[0].immediate() } else { - match in_elem.kind() { + match in_elem.data() { ty::Int(_) | ty::Uint(_) => {} _ => return_error!( "unsupported {} from `{}` with element `{}` to `{}`", @@ -1539,7 +1539,7 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#, let i1xn = bx.type_vector(i1, in_len as u64); bx.trunc(args[0].immediate(), i1xn) }; - return match in_elem.kind() { + return match in_elem.data() { ty::Int(_) | ty::Uint(_) => { let r = bx.$red(input); Ok(if !$boolean { r } else { bx.zext(r, bx.type_bool()) }) @@ -1587,7 +1587,7 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#, Unsupported, } - let (in_style, in_width) = match in_elem.kind() { + let (in_style, in_width) = match in_elem.data() { // vectors of pointer-sized integers should've been // disallowed before here, so this unwrap is safe. ty::Int(i) => (Style::Int(true), i.bit_width().unwrap()), @@ -1595,7 +1595,7 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#, ty::Float(f) => (Style::Float, f.bit_width()), _ => (Style::Unsupported, 0), }; - let (out_style, out_width) = match out_elem.kind() { + let (out_style, out_width) = match out_elem.data() { ty::Int(i) => (Style::Int(true), i.bit_width().unwrap()), ty::Uint(u) => (Style::Int(false), u.bit_width().unwrap()), ty::Float(f) => (Style::Float, f.bit_width()), @@ -1651,7 +1651,7 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#, macro_rules! arith { ($($name: ident: $($($p: ident),* => $call: ident),*;)*) => { $(if name == sym::$name { - match in_elem.kind() { + match in_elem.data() { $($(ty::$p(_))|* => { return Ok(bx.$call(args[0].immediate(), args[1].immediate())) })* @@ -1685,7 +1685,7 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#, 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.data() { 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)), _ => { @@ -1720,7 +1720,7 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#, // FIXME: there’s multiple of this functions, investigate using some of the already existing // stuffs. fn int_type_width_signed(ty: Ty<'_>, cx: &CodegenCx<'_, '_>) -> Option<(u64, bool)> { - match ty.kind() { + match ty.data() { ty::Int(t) => { Some((t.bit_width().unwrap_or(u64::from(cx.tcx.sess.target.ptr_width)), true)) } diff --git a/compiler/rustc_codegen_llvm/src/type_of.rs b/compiler/rustc_codegen_llvm/src/type_of.rs index e0754d21df1f0..ee994a56f4df5 100644 --- a/compiler/rustc_codegen_llvm/src/type_of.rs +++ b/compiler/rustc_codegen_llvm/src/type_of.rs @@ -36,7 +36,7 @@ fn uncached_llvm_type<'a, 'tcx>( Abi::Uninhabited | Abi::Aggregate { .. } => {} } - let name = match layout.ty.kind() { + let name = match layout.ty.data() { // FIXME(eddyb) producing readable type names for trait objects can result // in problematically distinct types due to HRTB and subtyping (see #47638). // ty::Dynamic(..) | @@ -45,14 +45,14 @@ fn uncached_llvm_type<'a, 'tcx>( { let mut name = with_no_trimmed_paths(|| layout.ty.to_string()); if let (&ty::Adt(def, _), &Variants::Single { index }) = - (layout.ty.kind(), &layout.variants) + (layout.ty.data(), &layout.variants) { if def.is_enum() && !def.variants.is_empty() { write!(&mut name, "::{}", def.variants[index].ident).unwrap(); } } if let (&ty::Generator(_, _, _), &Variants::Single { index }) = - (layout.ty.kind(), &layout.variants) + (layout.ty.data(), &layout.variants) { write!(&mut name, "::{}", ty::GeneratorSubsts::variant_name(index)).unwrap(); } @@ -223,7 +223,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> { if let Some(&llty) = cx.scalar_lltypes.borrow().get(&self.ty) { return llty; } - let llty = match *self.ty.kind() { + let llty = match *self.ty.data() { ty::Ref(_, ty, _) | ty::RawPtr(ty::TypeAndMut { ty, .. }) => { cx.type_ptr_to(cx.layout_of(ty).llvm_type(cx)) } @@ -316,7 +316,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> { ) -> &'a Type { // HACK(eddyb) special-case fat pointers until LLVM removes // pointee types, to avoid bitcasting every `OperandRef::deref`. - match self.ty.kind() { + match self.ty.data() { ty::Ref(..) | ty::RawPtr(_) => { return self.field(cx, index).llvm_type(cx); } diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index 8e6f8e193c0e2..a2045fadd879b 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -120,7 +120,7 @@ pub fn compare_simd_types<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( ret_ty: Bx::Type, op: hir::BinOpKind, ) -> Bx::Value { - let signed = match t.kind() { + let signed = match t.data() { ty::Float(_) => { let cmp = bin_op_to_fcmp_predicate(op); let cmp = bx.fcmp(cmp, lhs, rhs); @@ -153,7 +153,7 @@ pub fn unsized_info<'tcx, Cx: CodegenMethods<'tcx>>( ) -> Cx::Value { let (source, target) = cx.tcx().struct_lockstep_tails_erasing_lifetimes(source, target, cx.param_env()); - match (source.kind(), target.kind()) { + match (source.data(), target.data()) { (&ty::Array(_, len), &ty::Slice(_)) => { cx.const_usize(len.eval_usize(cx.tcx(), ty::ParamEnv::reveal_all())) } @@ -182,7 +182,7 @@ pub fn unsize_thin_ptr<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( dst_ty: Ty<'tcx>, ) -> (Bx::Value, Bx::Value) { debug!("unsize_thin_ptr: {:?} => {:?}", src_ty, dst_ty); - match (src_ty.kind(), dst_ty.kind()) { + match (src_ty.data(), dst_ty.data()) { (&ty::Ref(_, a, _), &ty::Ref(_, b, _) | &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) | (&ty::RawPtr(ty::TypeAndMut { ty: a, .. }), &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) => { assert!(bx.cx().type_is_sized(a)); @@ -231,7 +231,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()) { + match (src_ty.data(), dst_ty.data()) { (&ty::Ref(..), &ty::Ref(..) | &ty::RawPtr(..)) | (&ty::RawPtr(..), &ty::RawPtr(..)) => { let (base, info) = match bx.load_operand(src).val { OperandValue::Pair(base, info) => { diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs index 45ecb793387d0..df5035bbba96c 100644 --- a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs +++ b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs @@ -35,7 +35,7 @@ pub fn push_debuginfo_type_name<'tcx>( // .natvis visualizers (and perhaps other existing native debuggers?) let cpp_like_names = tcx.sess.target.target.options.is_like_msvc; - match *t.kind() { + match *t.data() { ty::Bool => output.push_str("bool"), ty::Char => output.push_str("char"), ty::Str => output.push_str("str"), diff --git a/compiler/rustc_codegen_ssa/src/glue.rs b/compiler/rustc_codegen_ssa/src/glue.rs index b88de0b241141..dc6d886ff9f2d 100644 --- a/compiler/rustc_codegen_ssa/src/glue.rs +++ b/compiler/rustc_codegen_ssa/src/glue.rs @@ -19,7 +19,7 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( let align = bx.const_usize(layout.align.abi.bytes()); return (size, align); } - match t.kind() { + match t.data() { ty::Dynamic(..) => { // load size/align from vtable let vtable = info.unwrap(); @@ -64,7 +64,7 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( let size = bx.add(sized_size, unsized_size); // Packed types ignore the alignment of their fields. - if let ty::Adt(def, _) = t.kind() { + if let ty::Adt(def, _) = t.data() { if def.repr.packed() { unsized_align = sized_align; } diff --git a/compiler/rustc_codegen_ssa/src/mir/analyze.rs b/compiler/rustc_codegen_ssa/src/mir/analyze.rs index bdde07d3fa9b0..cb0834c2e0741 100644 --- a/compiler/rustc_codegen_ssa/src/mir/analyze.rs +++ b/compiler/rustc_codegen_ssa/src/mir/analyze.rs @@ -236,7 +236,7 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx> fn visit_terminator(&mut self, terminator: &mir::Terminator<'tcx>, location: Location) { let check = match terminator.kind { mir::TerminatorKind::Call { func: mir::Operand::Constant(ref c), ref args, .. } => { - match *c.literal.ty.kind() { + match *c.literal.ty.data() { ty::FnDef(did, _) => Some((did, args)), _ => None, } diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index 703a17b200a34..3da9f9f9f753e 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -332,7 +332,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { args1 = [place.llval]; &args1[..] }; - let (drop_fn, fn_abi) = match ty.kind() { + let (drop_fn, fn_abi) = match ty.data() { // FIXME(eddyb) perhaps move some of this logic into // `Instance::resolve_drop_in_place`? ty::Dynamic(..) => { @@ -540,7 +540,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(&mut bx, func); - let (instance, mut llfn) = match *callee.layout.ty.kind() { + let (instance, mut llfn) = match *callee.layout.ty.data() { ty::FnDef(def_id, substs) => ( Some( ty::Instance::resolve(bx.tcx(), ty::ParamEnv::reveal_all(), def_id, substs) @@ -876,7 +876,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { ), }; let value = scalar.assert_bits(size); - let string = match ty.kind() { + let string = match ty.data() { ty::Uint(_) => value.to_string(), ty::Int(int_ty) => { match int_ty.normalize(bx.tcx().sess.target.ptr_width) { @@ -903,7 +903,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } mir::InlineAsmOperand::SymFn { ref value } => { let literal = self.monomorphize(&value.literal); - if let ty::FnDef(def_id, substs) = *literal.ty.kind() { + if let ty::FnDef(def_id, substs) = *literal.ty.data() { 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 14f1ed59a67c5..ff9bba3a81b71 100644 --- a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs +++ b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs @@ -58,7 +58,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { ) { let callee_ty = instance.ty(bx.tcx(), ty::ParamEnv::reveal_all()); - let (def_id, substs) = match *callee_ty.kind() { + let (def_id, substs) = match *callee_ty.data() { ty::FnDef(def_id, substs) => (def_id, substs), _ => bug!("expected fn item type, found {}", callee_ty), }; @@ -579,7 +579,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { // FIXME: there’s multiple of this functions, investigate using some of the already existing // stuffs. fn int_type_width_signed(ty: Ty<'_>, tcx: TyCtxt<'_>) -> Option<(u64, bool)> { - match ty.kind() { + match ty.data() { ty::Int(t) => Some((t.bit_width().unwrap_or(u64::from(tcx.sess.target.ptr_width)), true)), ty::Uint(t) => Some((t.bit_width().unwrap_or(u64::from(tcx.sess.target.ptr_width)), false)), _ => None, @@ -589,7 +589,7 @@ fn int_type_width_signed(ty: Ty<'_>, tcx: TyCtxt<'_>) -> Option<(u64, bool)> { // Returns the width of a float Ty // Returns None if the type is not a float fn float_type_width(ty: Ty<'_>) -> Option { - match ty.kind() { + match ty.data() { ty::Float(t) => Some(t.bit_width()), _ => None, } diff --git a/compiler/rustc_codegen_ssa/src/mir/mod.rs b/compiler/rustc_codegen_ssa/src/mir/mod.rs index 64d456fb7aa67..ad292a2f855d6 100644 --- a/compiler/rustc_codegen_ssa/src/mir/mod.rs +++ b/compiler/rustc_codegen_ssa/src/mir/mod.rs @@ -369,7 +369,7 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( // individual LLVM function arguments. let arg_ty = fx.monomorphize(&arg_decl.ty); - let tupled_arg_tys = match arg_ty.kind() { + let tupled_arg_tys = match arg_ty.data() { ty::Tuple(tys) => tys, _ => bug!("spread argument isn't a tuple?!"), }; diff --git a/compiler/rustc_codegen_ssa/src/mir/place.rs b/compiler/rustc_codegen_ssa/src/mir/place.rs index 91609b226158b..3bcc4ddd2540f 100644 --- a/compiler/rustc_codegen_ssa/src/mir/place.rs +++ b/compiler/rustc_codegen_ssa/src/mir/place.rs @@ -134,7 +134,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> { // * no metadata available - just log the case // * known alignment - sized types, `[T]`, `str` or a foreign type // * packed struct - there is no alignment padding - match field.ty.kind() { + match field.ty.data() { _ if self.llextra.is_none() => { debug!( "unsized field `{}`, of `{:?}` has no metadata for adjustment", diff --git a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs index 7ce110dcbfc48..b19b38ff1add5 100644 --- a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs +++ b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs @@ -185,7 +185,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let val = match *kind { mir::CastKind::Pointer(PointerCast::ReifyFnPointer) => { - match *operand.layout.ty.kind() { + match *operand.layout.ty.data() { ty::FnDef(def_id, substs) => { if bx.cx().tcx().has_attr(def_id, sym::rustc_args_required_const) { bug!("reifying a fn ptr that requires const arguments"); @@ -204,7 +204,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } } mir::CastKind::Pointer(PointerCast::ClosureFnPointer(_)) => { - match *operand.layout.ty.kind() { + match *operand.layout.ty.data() { ty::Closure(def_id, substs) => { let instance = Instance::resolve_closure( bx.cx().tcx(), @@ -564,7 +564,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { // because codegen_place() panics if Local is operand. if let Some(index) = place.as_local() { if let LocalRef::Operand(Some(op)) = self.locals[index] { - if let ty::Array(_, n) = op.layout.ty.kind() { + if let ty::Array(_, n) = op.layout.ty.data() { let n = n.eval_usize(bx.cx().tcx(), ty::ParamEnv::reveal_all()); return bx.cx().const_usize(n); } diff --git a/compiler/rustc_codegen_ssa/src/traits/type_.rs b/compiler/rustc_codegen_ssa/src/traits/type_.rs index cec07b977e685..e192f51dc328b 100644 --- a/compiler/rustc_codegen_ssa/src/traits/type_.rs +++ b/compiler/rustc_codegen_ssa/src/traits/type_.rs @@ -89,7 +89,7 @@ pub trait DerivedTypeMethods<'tcx>: BaseTypeMethods<'tcx> + MiscMethods<'tcx> { } let tail = self.tcx().struct_tail_erasing_lifetimes(ty, param_env); - match tail.kind() { + match tail.data() { ty::Foreign(..) => false, ty::Str | ty::Slice(..) | ty::Dynamic(..) => true, _ => bug!("unexpected unsized tail: {:?}", tail), diff --git a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs index 871fc4fafe269..732dc929a39cb 100644 --- a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs +++ b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs @@ -340,7 +340,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> { } fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { - match *t.kind() { + match *t.data() { ty::Infer(ty::TyVar(vid)) => { debug!("canonical: type var found with vid {:?}", vid); match self.infcx.unwrap().probe_ty_var(vid) { diff --git a/compiler/rustc_infer/src/infer/canonical/query_response.rs b/compiler/rustc_infer/src/infer/canonical/query_response.rs index 93e19521893ef..a45895098eb1b 100644 --- a/compiler/rustc_infer/src/infer/canonical/query_response.rs +++ b/compiler/rustc_infer/src/infer/canonical/query_response.rs @@ -422,7 +422,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, '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.data() { // ...in which case we would set `canonical_vars[0]` to `Some(?U)`. // We only allow a `ty::INNERMOST` index in substitutions. diff --git a/compiler/rustc_infer/src/infer/combine.rs b/compiler/rustc_infer/src/infer/combine.rs index 6a1715ef81899..a98faa7bb7b89 100644 --- a/compiler/rustc_infer/src/infer/combine.rs +++ b/compiler/rustc_infer/src/infer/combine.rs @@ -73,7 +73,7 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> { { let a_is_expected = relation.a_is_expected(); - match (a.kind(), b.kind()) { + match (a.data(), b.data()) { // Relate integral variables to other types (&ty::Infer(ty::IntVar(a_id)), &ty::Infer(ty::IntVar(b_id))) => { self.inner @@ -597,7 +597,7 @@ impl 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 result = match *t.kind() { + let result = match *t.data() { ty::Infer(ty::TyVar(vid)) => { let vid = self.infcx.inner.borrow_mut().type_variables().root_var(vid); let sub_vid = self.infcx.inner.borrow_mut().type_variables().sub_root_var(vid); @@ -840,7 +840,7 @@ impl TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> { debug_assert_eq!(t, _t); debug!("ConstInferUnifier: t={:?}", t); - match t.kind() { + match t.data() { &ty::Infer(ty::TyVar(vid)) => { let vid = self.infcx.inner.borrow_mut().type_variables().root_var(vid); let probe = self.infcx.inner.borrow_mut().type_variables().probe(vid); diff --git a/compiler/rustc_infer/src/infer/equate.rs b/compiler/rustc_infer/src/infer/equate.rs index 7c388b5503ee3..2e2653348ff8c 100644 --- a/compiler/rustc_infer/src/infer/equate.rs +++ b/compiler/rustc_infer/src/infer/equate.rs @@ -77,7 +77,7 @@ impl TypeRelation<'tcx> for Equate<'combine, 'infcx, 'tcx> { debug!("{}.tys: replacements ({:?}, {:?})", self.tag(), a, b); - match (a.kind(), b.kind()) { + match (a.data(), b.data()) { (&ty::Infer(TyVar(a_id)), &ty::Infer(TyVar(b_id))) => { infcx.inner.borrow_mut().type_variables().equate(a_id, b_id); } diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 795c5a64d26b7..34cda0250aabb 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -570,7 +570,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { // 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, _)) = - (exp_found.expected.kind(), exp_found.found.kind()) + (exp_found.expected.data(), exp_found.found.data()) { report_path_match(err, exp_adt.did, found_adt.did); } @@ -856,7 +856,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { self.highlight_outer(&mut t1_out, &mut t2_out, path, sub, i, &other_ty); return Some(()); } - if let &ty::Adt(def, _) = ta.kind() { + if let &ty::Adt(def, _) = ta.data() { let path_ = self.tcx.def_path_str(def.did); if path_ == other_path { self.highlight_outer(&mut t1_out, &mut t2_out, path, sub, i, &other_ty); @@ -1037,11 +1037,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { /// Compares two given types, eliding parts that are the same between them and highlighting /// relevant differences, and return two representation of those types for highlighted printing. fn cmp(&self, t1: Ty<'tcx>, t2: Ty<'tcx>) -> (DiagnosticStyledString, DiagnosticStyledString) { - debug!("cmp(t1={}, t1.kind={:?}, t2={}, t2.kind={:?})", t1, t1.kind(), t2, t2.kind()); + debug!("cmp(t1={}, t1.kind={:?}, t2={}, t2.kind={:?})", t1, t1.data(), t2, t2.data()); // helper functions fn equals<'tcx>(a: Ty<'tcx>, b: Ty<'tcx>) -> bool { - match (a.kind(), b.kind()) { + match (a.data(), b.data()) { (a, b) if *a == *b => true, (&ty::Int(_), &ty::Infer(ty::InferTy::IntVar(_))) | ( @@ -1074,7 +1074,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { } // process starts here - match (t1.kind(), t2.kind()) { + match (t1.data(), t2.data()) { (&ty::Adt(def1, sub1), &ty::Adt(def2, sub2)) => { let sub_no_defaults_1 = self.strip_generic_default_params(def1.did, sub1); let sub_no_defaults_2 = self.strip_generic_default_params(def2.did, sub2); @@ -1536,7 +1536,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { }; match (&terr, expected == found) { (TypeError::Sorts(values), extra) => { - let sort_string = |ty: Ty<'tcx>| match (extra, ty.kind()) { + let sort_string = |ty: Ty<'tcx>| match (extra, ty.data()) { (true, ty::Opaque(def_id, _)) => format!( " (opaque type at {})", self.tcx @@ -1623,7 +1623,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { exp_span, exp_found.expected, exp_found.found ); - if let ty::Opaque(def_id, _) = *exp_found.expected.kind() { + if let ty::Opaque(def_id, _) = *exp_found.expected.data() { let future_trait = self.tcx.require_lang_item(LangItem::Future, None); // Future::Output let item_def_id = self @@ -1676,9 +1676,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { diag: &mut DiagnosticBuilder<'tcx>, ) { if let (ty::Adt(exp_def, exp_substs), ty::Ref(_, found_ty, _)) = - (exp_found.expected.kind(), exp_found.found.kind()) + (exp_found.expected.data(), exp_found.found.data()) { - if let ty::Adt(found_def, found_substs) = *found_ty.kind() { + if let ty::Adt(found_def, found_substs) = *found_ty.data() { let path_str = format!("{:?}", exp_def); if exp_def == &found_def { let opt_msg = "you can convert from `&Option` to `Option<&T>` using \ @@ -1697,9 +1697,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { { let mut show_suggestion = true; for (exp_ty, found_ty) in exp_substs.types().zip(found_substs.types()) { - match *exp_ty.kind() { + match *exp_ty.data() { ty::Ref(_, exp_ty, _) => { - match (exp_ty.kind(), found_ty.kind()) { + match (exp_ty.data(), found_ty.data()) { (_, ty::Param(_)) | (_, ty::Infer(_)) | (ty::Param(_), _) @@ -2049,7 +2049,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { ); if let Some(infer::RelateParamBound(_, t)) = origin { let t = self.resolve_vars_if_possible(&t); - match t.kind() { + match t.data() { // We've got: // fn get_later(g: G, dest: &mut T) -> impl FnOnce() + '_ // suggest: @@ -2291,7 +2291,7 @@ impl TyCategory { } pub fn from_ty(ty: Ty<'_>) -> Option<(Self, DefId)> { - match *ty.kind() { + match *ty.data() { ty::Closure(def_id, _) => Some((Self::Closure, def_id)), ty::Opaque(def_id, _) => Some((Self::Opaque, def_id)), ty::Generator(def_id, ..) => Some((Self::Generator, def_id)), 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 2f3089f1a92c1..f21d29b2f19de 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 @@ -54,7 +54,7 @@ impl<'a, 'tcx> FindHirNodeVisitor<'a, 'tcx> { inner == self.target || match (inner.unpack(), self.target.unpack()) { (GenericArgKind::Type(inner_ty), GenericArgKind::Type(target_ty)) => { - match (inner_ty.kind(), target_ty.kind()) { + match (inner_ty.data(), target_ty.data()) { ( &ty::Infer(ty::TyVar(a_vid)), &ty::Infer(ty::TyVar(b_vid)), @@ -239,7 +239,7 @@ impl<'a, 'tcx> InferCtxt<'a, '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.data() { let mut inner = self.inner.borrow_mut(); let ty_vars = &inner.type_variables(); let var_origin = ty_vars.var_origin(ty_vid); @@ -378,7 +378,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { None }; printer.name_resolver = Some(Box::new(&getter)); - let _ = if let ty::FnDef(..) = ty.kind() { + let _ = if let ty::FnDef(..) = ty.data() { // We don't want the regular output for `fn`s because it includes its path in // invalid pseudo-syntax, we want the `fn`-pointer output instead. ty.fn_sig(self.tcx).print(printer) @@ -428,7 +428,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { (_, Some(_)) => String::new(), (Some(ty), _) if ty.is_closure() => { let substs = - if let ty::Closure(_, substs) = *ty.kind() { substs } else { unreachable!() }; + if let ty::Closure(_, substs) = *ty.data() { substs } else { unreachable!() }; let fn_sig = substs.as_closure().sig(); let args = closure_args(&fn_sig); let ret = fn_sig.output().skip_binder().to_string(); @@ -464,7 +464,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { let suffix = match local_visitor.found_node_ty { Some(ty) if ty.is_closure() => { let substs = - if let ty::Closure(_, substs) = *ty.kind() { substs } else { unreachable!() }; + if let ty::Closure(_, substs) = *ty.data() { substs } else { unreachable!() }; let fn_sig = substs.as_closure().sig(); let ret = fn_sig.output().skip_binder().to_string(); @@ -682,8 +682,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { let bound_output = sig.output(); let output = bound_output.skip_binder(); err.span_label(e.span, &format!("this method call resolves to `{}`", output)); - let kind = output.kind(); - if let ty::Projection(proj) = kind { + let data = output.data(); + if let ty::Projection(proj) = data { if let Some(span) = self.tcx.hir().span_if_local(proj.item_def_id) { err.span_label(span, &format!("`{}` defined here", output)); } diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs index 441cfeea20a48..a964c75851690 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs @@ -465,7 +465,7 @@ struct TraitObjectVisitor(Vec); impl TypeVisitor<'_> for TraitObjectVisitor { fn visit_ty(&mut self, t: Ty<'_>) -> bool { - match t.kind() { + match t.data() { ty::Dynamic(preds, RegionKind::ReStatic) => { if let Some(def_id) = preds.principal_def_id() { self.0.push(def_id); diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/util.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/util.rs index c055fed43f6d5..c0cf091f35bcb 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/util.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/util.rs @@ -95,7 +95,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { decl: &hir::FnDecl<'_>, ) -> Option { let ret_ty = self.tcx().type_of(scope_def_id); - if let ty::FnDef(_, _) = ret_ty.kind() { + if let ty::FnDef(_, _) = ret_ty.data() { let sig = ret_ty.fn_sig(self.tcx()); let late_bound_regions = self.tcx().collect_referenced_late_bound_regions(&sig.output()); diff --git a/compiler/rustc_infer/src/infer/freshen.rs b/compiler/rustc_infer/src/infer/freshen.rs index b3d7876c6e819..12bcf98b95cec 100644 --- a/compiler/rustc_infer/src/infer/freshen.rs +++ b/compiler/rustc_infer/src/infer/freshen.rs @@ -144,7 +144,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> { let tcx = self.infcx.tcx; - match *t.kind() { + match *t.data() { ty::Infer(ty::TyVar(v)) => { let opt_ty = self.infcx.inner.borrow_mut().type_variables().probe(v).known(); self.freshen_ty(opt_ty, ty::TyVar(v), ty::FreshTy) diff --git a/compiler/rustc_infer/src/infer/fudge.rs b/compiler/rustc_infer/src/infer/fudge.rs index d7bc636db8f8f..11f24513d08e8 100644 --- a/compiler/rustc_infer/src/infer/fudge.rs +++ b/compiler/rustc_infer/src/infer/fudge.rs @@ -182,7 +182,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for InferenceFudger<'a, 'tcx> { } fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { - match *ty.kind() { + match *ty.data() { 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/lattice.rs b/compiler/rustc_infer/src/infer/lattice.rs index c47d476963772..84e523ed98fe0 100644 --- a/compiler/rustc_infer/src/infer/lattice.rs +++ b/compiler/rustc_infer/src/infer/lattice.rs @@ -58,7 +58,7 @@ where let infcx = this.infcx(); let a = infcx.inner.borrow_mut().type_variables().replace_if_possible(a); let b = infcx.inner.borrow_mut().type_variables().replace_if_possible(b); - match (a.kind(), b.kind()) { + match (a.data(), b.data()) { // If one side is known to be a variable and one is not, // create a variable (`v`) to represent the LUB. Make sure to // relate `v` to the non-type-variable first (by passing it diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index 9742f5e234651..3d3c3068e7ec3 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -675,7 +675,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { } pub fn type_var_diverges(&'a self, ty: Ty<'_>) -> bool { - match *ty.kind() { + match *ty.data() { ty::Infer(ty::TyVar(vid)) => self.inner.borrow_mut().type_variables().var_diverges(vid), _ => false, } @@ -688,7 +688,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { pub fn type_is_unconstrained_numeric(&'a self, ty: Ty<'_>) -> UnconstrainedNumeric { use rustc_middle::ty::error::UnconstrainedNumeric::Neither; use rustc_middle::ty::error::UnconstrainedNumeric::{UnconstrainedFloat, UnconstrainedInt}; - match *ty.kind() { + match *ty.data() { ty::Infer(ty::IntVar(vid)) => { if self.inner.borrow_mut().int_unification_table().probe_value(vid).is_some() { Neither @@ -1554,7 +1554,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { /// not a type variable, just return it unmodified. // FIXME(eddyb) inline into `ShallowResolver::visit_ty`. fn shallow_resolve_ty(&self, typ: Ty<'tcx>) -> Ty<'tcx> { - match *typ.kind() { + match *typ.data() { ty::Infer(ty::TyVar(v)) => { // Not entirely obvious: if `typ` is a type variable, // it can be resolved to an int/float variable, which @@ -1674,7 +1674,7 @@ impl TyOrConstInferVar<'tcx> { /// Tries to extract an inference variable from a type, returns `None` /// for types other than `ty::Infer(_)` (or `InferTy::Fresh*`). pub fn maybe_from_ty(ty: Ty<'tcx>) -> Option { - match *ty.kind() { + match *ty.data() { 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/nll_relate/mod.rs b/compiler/rustc_infer/src/infer/nll_relate/mod.rs index 839891f322c81..7351aa88dbc4c 100644 --- a/compiler/rustc_infer/src/infer/nll_relate/mod.rs +++ b/compiler/rustc_infer/src/infer/nll_relate/mod.rs @@ -265,7 +265,7 @@ where use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc_span::DUMMY_SP; - match *value_ty.kind() { + match *value_ty.data() { ty::Projection(other_projection_ty) => { let var = self.infcx.next_ty_var(TypeVariableOrigin { kind: TypeVariableOriginKind::MiscVariable, @@ -311,7 +311,7 @@ where // This only presently applies to chalk integration, as NLL // doesn't permit type variables to appear on both sides (and // doesn't use lazy norm). - match *value_ty.kind() { + match *value_ty.data() { ty::Infer(ty::TyVar(value_vid)) => { // Two type variables: just equate them. self.infcx.inner.borrow_mut().type_variables().equate(vid, value_vid); @@ -531,7 +531,7 @@ where } } - match (a.kind(), b.kind()) { + match (a.data(), b.data()) { (_, &ty::Infer(ty::TyVar(vid))) => { if D::forbid_inference_vars() { // Forbid inference variables in the RHS. @@ -868,7 +868,7 @@ where debug!("TypeGeneralizer::tys(a={:?})", a); - match *a.kind() { + match *a.data() { ty::Infer(ty::TyVar(_)) | ty::Infer(ty::IntVar(_)) | ty::Infer(ty::FloatVar(_)) if D::forbid_inference_vars() => { diff --git a/compiler/rustc_infer/src/infer/outlives/obligations.rs b/compiler/rustc_infer/src/infer/outlives/obligations.rs index 2851da89ab2db..ad7713b59e799 100644 --- a/compiler/rustc_infer/src/infer/outlives/obligations.rs +++ b/compiler/rustc_infer/src/infer/outlives/obligations.rs @@ -383,7 +383,7 @@ where // #55756) in cases where you have e.g., `>::Item: // 'a` in the environment but `trait Foo<'b> { type Item: 'b // }` in the trait definition. - approx_env_bounds.retain(|bound| match *bound.0.kind() { + approx_env_bounds.retain(|bound| match *bound.0.data() { ty::Projection(projection_ty) => self .verify_bound .projection_declared_bounds_from_trait(projection_ty) diff --git a/compiler/rustc_infer/src/infer/outlives/verify.rs b/compiler/rustc_infer/src/infer/outlives/verify.rs index 2b827f4f4eddc..e298c75959f2e 100644 --- a/compiler/rustc_infer/src/infer/outlives/verify.rs +++ b/compiler/rustc_infer/src/infer/outlives/verify.rs @@ -46,7 +46,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> { ty: Ty<'tcx>, visited: &mut SsoHashSet>, ) -> VerifyBound<'tcx> { - match *ty.kind() { + match *ty.data() { ty::Param(p) => self.param_bound(p), ty::Projection(data) => self.projection_bound(data, visited), ty::FnDef(_, substs) => { @@ -126,7 +126,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> { let projection_ty = GenericKind::Projection(projection_ty).to_ty(self.tcx); let erased_projection_ty = self.tcx.erase_regions(&projection_ty); self.declared_generic_bounds_from_env_with_compare_fn(|ty| { - if let ty::Projection(..) = ty.kind() { + if let ty::Projection(..) = ty.data() { let erased_ty = self.tcx.erase_regions(&ty); erased_ty == erased_projection_ty } else { diff --git a/compiler/rustc_infer/src/infer/resolve.rs b/compiler/rustc_infer/src/infer/resolve.rs index 337772d70b823..c2853382a1dfd 100644 --- a/compiler/rustc_infer/src/infer/resolve.rs +++ b/compiler/rustc_infer/src/infer/resolve.rs @@ -124,7 +124,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'tcx> { fn visit_ty(&mut self, t: Ty<'tcx>) -> bool { let t = self.infcx.shallow_resolve(t); if t.has_infer_types() { - if let ty::Infer(infer_ty) = *t.kind() { + if let ty::Infer(infer_ty) = *t.data() { // Since we called `shallow_resolve` above, this must // be an (as yet...) unresolved inference variable. let ty_var_span = if let ty::TyVar(ty_vid) = infer_ty { @@ -191,7 +191,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> { 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.data() { ty::Infer(ty::TyVar(vid)) => { self.err = Some(FixupError::UnresolvedTy(vid)); self.tcx().ty_error() diff --git a/compiler/rustc_infer/src/infer/sub.rs b/compiler/rustc_infer/src/infer/sub.rs index a676c5e65a73b..68e818fc89d62 100644 --- a/compiler/rustc_infer/src/infer/sub.rs +++ b/compiler/rustc_infer/src/infer/sub.rs @@ -83,7 +83,7 @@ impl TypeRelation<'tcx> for Sub<'combine, 'infcx, 'tcx> { let infcx = self.fields.infcx; let a = infcx.inner.borrow_mut().type_variables().replace_if_possible(a); let b = infcx.inner.borrow_mut().type_variables().replace_if_possible(b); - match (a.kind(), b.kind()) { + match (a.data(), b.data()) { (&ty::Infer(TyVar(a_vid)), &ty::Infer(TyVar(b_vid))) => { // Shouldn't have any LBR here, so we can safely put // this under a binder below without fear of accidental diff --git a/compiler/rustc_infer/src/infer/type_variable.rs b/compiler/rustc_infer/src/infer/type_variable.rs index 35b97fff3da1f..aa6c362875f80 100644 --- a/compiler/rustc_infer/src/infer/type_variable.rs +++ b/compiler/rustc_infer/src/infer/type_variable.rs @@ -306,7 +306,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.data() { ty::Infer(ty::TyVar(v)) => match self.probe(v) { TypeVariableValue::Unknown { .. } => t, TypeVariableValue::Known { value } => value, diff --git a/compiler/rustc_lint/src/array_into_iter.rs b/compiler/rustc_lint/src/array_into_iter.rs index e6be082da0e99..3dc2623ef3ff5 100644 --- a/compiler/rustc_lint/src/array_into_iter.rs +++ b/compiler/rustc_lint/src/array_into_iter.rs @@ -78,7 +78,7 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter { } // Make sure we found an array after peeling the boxes. - if !matches!(recv_ty.kind(), ty::Array(..)) { + if !matches!(recv_ty.data(), ty::Array(..)) { return; } @@ -91,9 +91,9 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter { } // Emit lint diagnostic. - let target = match *cx.typeck_results().expr_ty_adjusted(receiver_arg).kind() { + let target = match *cx.typeck_results().expr_ty_adjusted(receiver_arg).data() { ty::Ref(_, inner_ty, _) if inner_ty.is_array() => "[T; N]", - ty::Ref(_, inner_ty, _) if matches!(inner_ty.kind(), ty::Slice(..)) => "[T]", + ty::Ref(_, inner_ty, _) if matches!(inner_ty.data(), ty::Slice(..)) => "[T]", // We know the original first argument type is an array type, // we know that the first adjustment was an autoref coercion diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index abd899e8db4d3..efcf2db168207 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -1166,7 +1166,7 @@ impl<'tcx> LateLintPass<'tcx> for MutableTransmutes { fn check_expr(&mut self, cx: &LateContext<'_>, expr: &hir::Expr<'_>) { use rustc_target::spec::abi::Abi::RustIntrinsic; if let Some((&ty::Ref(_, _, from_mt), &ty::Ref(_, _, to_mt))) = - get_transmute_from_to(cx, expr).map(|(ty1, ty2)| (ty1.kind(), ty2.kind())) + get_transmute_from_to(cx, expr).map(|(ty1, ty2)| (ty1.data(), ty2.data())) { if to_mt == hir::Mutability::Mut && from_mt == hir::Mutability::Not { let msg = "mutating transmuted &mut T from &T may cause undefined behavior, \ @@ -2416,14 +2416,14 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue { ty: Ty<'tcx>, init: InitKind, ) -> Option { - use rustc_middle::ty::TyKind::*; - match ty.kind() { + use rustc_middle::ty::TyData::*; + match ty.data() { // Primitive types that don't like 0 as a value. Ref(..) => Some(("references must be non-null".to_string(), None)), Adt(..) if ty.is_box() => Some(("`Box` must be non-null".to_string(), None)), FnPtr(..) => Some(("function pointers must be non-null".to_string(), None)), Never => Some(("the `!` type has no valid value".to_string(), None)), - RawPtr(tm) if matches!(tm.ty.kind(), Dynamic(..)) => + RawPtr(tm) if matches!(tm.ty.data(), Dynamic(..)) => // raw ptr to dyn Trait { Some(("the vtable of a wide raw pointer must be non-null".to_string(), None)) @@ -2684,7 +2684,7 @@ impl ClashingExternDeclarations { let non_transparent_ty = |ty: Ty<'tcx>| -> Ty<'tcx> { let mut ty = ty; loop { - if let ty::Adt(def, substs) = *ty.kind() { + if let ty::Adt(def, substs) = *ty.data() { let is_transparent = def.subst(tcx, substs).repr.transparent(); let is_non_null = crate::types::nonnull_optimization_guaranteed(tcx, &def); debug!( @@ -2721,9 +2721,9 @@ impl ClashingExternDeclarations { true } else { // Do a full, depth-first comparison between the two. - use rustc_middle::ty::TyKind::*; - let a_kind = a.kind(); - let b_kind = b.kind(); + use rustc_middle::ty::TyData::*; + let a_kind = a.data(); + let b_kind = b.data(); let compare_layouts = |a, b| -> Result> { debug!("compare_layouts({:?}, {:?})", a, b); @@ -2738,8 +2738,8 @@ impl ClashingExternDeclarations { Ok(a_layout == b_layout) }; - #[allow(rustc::usage_of_ty_tykind)] - let is_primitive_or_pointer = |kind: &ty::TyKind<'_>| { + #[allow(rustc::usage_of_ty_tydata)] + let is_primitive_or_pointer = |kind: &ty::TyData<'_>| { kind.is_primitive() || matches!(kind, RawPtr(..) | Ref(..)) }; @@ -2845,7 +2845,7 @@ impl ClashingExternDeclarations { if is_primitive_or_pointer(other_kind) => { let (primitive, adt) = - if is_primitive_or_pointer(a.kind()) { (a, b) } else { (b, a) }; + if is_primitive_or_pointer(a.data()) { (a, b) } else { (b, a) }; if let Some(ty) = crate::types::repr_nullable_ptr(cx, adt, ckind) { ty == primitive } else { diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 7a3035e5b4631..34302baa5ac9b 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -794,7 +794,7 @@ impl<'tcx> LateContext<'tcx> { trait_ref: Option>, ) -> Result { if trait_ref.is_none() { - if let ty::Adt(def, substs) = self_ty.kind() { + if let ty::Adt(def, substs) = self_ty.data() { return self.print_def_path(def.did, substs); } } diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index c2d98b8e4ad37..e2609badc67c7 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -60,9 +60,9 @@ impl EarlyLintPass for DefaultHashTypes { } declare_tool_lint! { - pub rustc::USAGE_OF_TY_TYKIND, + pub rustc::USAGE_OF_TY_TYDATA, Allow, - "usage of `ty::TyKind` outside of the `ty::sty` module", + "usage of `ty::TyData` outside of the `ty::sty` module", report_in_external_macro: true } @@ -80,24 +80,24 @@ declare_tool_lint! { report_in_external_macro: true } -declare_lint_pass!(TyTyKind => [ - USAGE_OF_TY_TYKIND, +declare_lint_pass!(TyTyData => [ + USAGE_OF_TY_TYDATA, TY_PASS_BY_REFERENCE, USAGE_OF_QUALIFIED_TY, ]); -impl<'tcx> LateLintPass<'tcx> for TyTyKind { +impl<'tcx> LateLintPass<'tcx> for TyTyData { fn check_path(&mut self, cx: &LateContext<'_>, path: &'tcx Path<'tcx>, _: HirId) { let segments = path.segments.iter().rev().skip(1).rev(); if let Some(last) = segments.last() { let span = path.span.with_hi(last.ident.span.hi()); if lint_ty_kind_usage(cx, last) { - cx.struct_span_lint(USAGE_OF_TY_TYKIND, span, |lint| { - lint.build("usage of `ty::TyKind::`") + cx.struct_span_lint(USAGE_OF_TY_TYDATA, span, |lint| { + lint.build("usage of `ty::TyData::`") .span_suggestion( span, - "try using ty:: directly", + "try using ty:: directly", "ty".to_string(), Applicability::MaybeIncorrect, // ty maybe needs an import ) @@ -113,8 +113,8 @@ impl<'tcx> LateLintPass<'tcx> for TyTyKind { if let QPath::Resolved(_, path) = qpath { if let Some(last) = path.segments.iter().last() { if lint_ty_kind_usage(cx, last) { - cx.struct_span_lint(USAGE_OF_TY_TYKIND, path.span, |lint| { - lint.build("usage of `ty::TyKind`") + cx.struct_span_lint(USAGE_OF_TY_TYDATA, path.span, |lint| { + lint.build("usage of `ty::TyData`") .help("try using `Ty` instead") .emit(); }) @@ -169,7 +169,7 @@ impl<'tcx> LateLintPass<'tcx> for TyTyKind { fn lint_ty_kind_usage(cx: &LateContext<'_>, segment: &PathSegment<'_>) -> bool { if let Some(res) = segment.res { if let Some(did) = res.opt_def_id() { - return cx.tcx.is_diagnostic_item(sym::TyKind, did); + return cx.tcx.is_diagnostic_item(sym::TyData, did); } } @@ -189,7 +189,7 @@ fn is_ty_or_ty_ctxt(cx: &LateContext<'_>, ty: &Ty<'_>) -> Option { } // Only lint on `&Ty` and `&TyCtxt` if it is used outside of a trait. Res::SelfTy(None, Some((did, _))) => { - if let ty::Adt(adt, substs) = cx.tcx.type_of(did).kind() { + if let ty::Adt(adt, substs) = cx.tcx.type_of(did).data() { if cx.tcx.is_diagnostic_item(sym::Ty, adt.did) { // NOTE: This path is currently unreachable as `Ty<'tcx>` is // defined as a type alias meaning that `impl<'tcx> Ty<'tcx>` diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 1db59bfc39dce..39f840932545a 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -453,15 +453,15 @@ fn register_internals(store: &mut LintStore) { store.register_early_pass(|| box DefaultHashTypes::new()); store.register_lints(&LintPassImpl::get_lints()); store.register_early_pass(|| box LintPassImpl); - store.register_lints(&TyTyKind::get_lints()); - store.register_late_pass(|| box TyTyKind); + store.register_lints(&TyTyData::get_lints()); + store.register_late_pass(|| box TyTyData); store.register_group( false, "rustc::internal", None, vec![ LintId::of(DEFAULT_HASH_TYPES), - LintId::of(USAGE_OF_TY_TYKIND), + LintId::of(USAGE_OF_TY_TYDATA), LintId::of(LINT_PASS_IMPL_WITHOUT_MACRO), LintId::of(TY_PASS_BY_REFERENCE), LintId::of(USAGE_OF_QUALIFIED_TY), diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index 9925444b869f9..b00e317a7c4ba 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -279,7 +279,7 @@ fn get_type_suggestion(t: Ty<'_>, val: u128, negative: bool) -> Option<&'static } } } - match t.kind() { + match t.data() { ty::Int(i) => find_fit!(i, val, negative, I8 => [U8] => [I16, I32, I64, I128], I16 => [U16] => [I32, I64, I128], @@ -365,7 +365,7 @@ fn lint_uint_literal<'tcx>( if let Node::Expr(par_e) = cx.tcx.hir().get(parent_id) { match par_e.kind { hir::ExprKind::Cast(..) => { - if let ty::Char = cx.typeck_results().expr_ty(par_e).kind() { + if let ty::Char = cx.typeck_results().expr_ty(par_e).data() { cx.struct_span_lint(OVERFLOWING_LITERALS, par_e.span, |lint| { lint.build("only `u8` can be cast into `char`") .span_suggestion( @@ -416,7 +416,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).data() { ty::Int(t) => { match lit.node { ast::LitKind::Int(v, ast::LitIntType::Signed(_) | ast::LitIntType::Unsuffixed) => { @@ -512,7 +512,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).data() { ty::Int(int_ty) => { let (min, max) = int_ty_range(int_ty); let lit_val: i128 = match lit.kind { @@ -660,7 +660,7 @@ pub fn transparent_newtype_field<'a, 'tcx>( /// Is type known to be non-null? crate fn ty_is_known_nonnull<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, mode: CItemKind) -> bool { let tcx = cx.tcx; - match ty.kind() { + match ty.data() { ty::FnPtr(_) => true, ty::Ref(..) => true, ty::Adt(def, _) if def.is_box() && matches!(mode, CItemKind::Definition) => true, @@ -689,7 +689,7 @@ crate fn ty_is_known_nonnull<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, mode: C /// If the type passed in was not scalar, returns None. fn get_nullable_type<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option> { let tcx = cx.tcx; - Some(match *ty.kind() { + Some(match *ty.data() { ty::Adt(field_def, field_substs) => { let inner_field_ty = { let first_non_zst_ty = @@ -741,7 +741,7 @@ crate fn repr_nullable_ptr<'tcx>( ckind: CItemKind, ) -> Option> { debug!("is_repr_nullable_ptr(cx, ty = {:?})", ty); - if let ty::Adt(ty_def, substs) = ty.kind() { + if let ty::Adt(ty_def, substs) = ty.data() { if ty_def.variants.len() != 2 { return None; } @@ -791,7 +791,7 @@ crate fn repr_nullable_ptr<'tcx>( impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { /// Check if the type is array and emit an unsafe type lint. fn check_for_array_ty(&mut self, sp: Span, ty: Ty<'tcx>) -> bool { - if let ty::Array(..) = ty.kind() { + if let ty::Array(..) = ty.data() { self.emit_ffi_unsafe_type_lint( ty, sp, @@ -879,7 +879,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { return FfiSafe; } - match ty.kind() { + match ty.data() { ty::Adt(def, _) if def.is_box() && matches!(self.mode, CItemKind::Definition) => { FfiSafe } @@ -1118,7 +1118,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { diag.help(help); } diag.note(note); - if let ty::Adt(def, _) = ty.kind() { + if let ty::Adt(def, _) = ty.data() { if let Some(sp) = self.cx.tcx.hir().span_if_local(def.did) { diag.span_note(sp, "the type is defined here"); } @@ -1135,7 +1135,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { impl<'a, 'tcx> ty::fold::TypeVisitor<'tcx> for ProhibitOpaqueTypes<'a, 'tcx> { fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool { - match ty.kind() { + match ty.data() { ty::Opaque(..) => { self.ty = Some(ty); true diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index 3abd9a6325d6e..ceeb6fe1bd01c 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -191,7 +191,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { let plural_suffix = pluralize!(plural_len); - match *ty.kind() { + match *ty.data() { ty::Adt(..) if ty.is_box() => { let boxed_ty = ty.boxed_ty(); let descr_pre = &format!("{}boxed ", descr_pre); diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index f0911928e81c9..46fb21da8c7ac 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1495,7 +1495,7 @@ impl EncodeContext<'a, 'tcx> { let hir_id = self.tcx.hir().local_def_id_to_hir_id(def_id); let ty = self.tcx.typeck(def_id).node_type(hir_id); - record!(self.tables.kind[def_id.to_def_id()] <- match ty.kind() { + record!(self.tables.kind[def_id.to_def_id()] <- match ty.data() { ty::Generator(..) => { let data = self.tcx.generator_kind(def_id).unwrap(); EntryKind::Generator(data) @@ -1509,7 +1509,7 @@ impl EncodeContext<'a, 'tcx> { record!(self.tables.span[def_id.to_def_id()] <- self.tcx.def_span(def_id)); record!(self.tables.attributes[def_id.to_def_id()] <- &self.tcx.get_attrs(def_id.to_def_id())[..]); self.encode_item_type(def_id.to_def_id()); - if let ty::Closure(def_id, substs) = *ty.kind() { + if let ty::Closure(def_id, substs) = *ty.data() { record!(self.tables.fn_sig[def_id] <- substs.as_closure().sig()); } self.encode_generics(def_id.to_def_id()); diff --git a/compiler/rustc_middle/src/ich/impls_ty.rs b/compiler/rustc_middle/src/ich/impls_ty.rs index 8f15c99f951fe..0e6d78b84ab99 100644 --- a/compiler/rustc_middle/src/ich/impls_ty.rs +++ b/compiler/rustc_middle/src/ich/impls_ty.rs @@ -164,7 +164,7 @@ impl<'a> HashStable> for ty::TyVid { fn hash_stable(&self, _hcx: &mut StableHashingContext<'a>, _hasher: &mut StableHasher) { // `TyVid` values are confined to an inference context and hence // should not be hashed. - bug!("ty::TyKind::hash_stable() - can't hash a TyVid {:?}.", *self) + bug!("ty::TyData::hash_stable() - can't hash a TyVid {:?}.", *self) } } @@ -172,7 +172,7 @@ impl<'a> HashStable> for ty::IntVid { fn hash_stable(&self, _hcx: &mut StableHashingContext<'a>, _hasher: &mut StableHasher) { // `IntVid` values are confined to an inference context and hence // should not be hashed. - bug!("ty::TyKind::hash_stable() - can't hash an IntVid {:?}.", *self) + bug!("ty::TyData::hash_stable() - can't hash an IntVid {:?}.", *self) } } @@ -180,7 +180,7 @@ impl<'a> HashStable> for ty::FloatVid { fn hash_stable(&self, _hcx: &mut StableHashingContext<'a>, _hasher: &mut StableHasher) { // `FloatVid` values are confined to an inference context and hence // should not be hashed. - bug!("ty::TyKind::hash_stable() - can't hash a FloatVid {:?}.", *self) + bug!("ty::TyData::hash_stable() - can't hash a FloatVid {:?}.", *self) } } diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 92a2baa30ee8c..3e409ca9f57b4 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -2566,7 +2566,7 @@ impl<'tcx> Debug for Constant<'tcx> { impl<'tcx> Display for Constant<'tcx> { fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result { - match self.literal.ty.kind() { + match self.literal.ty.data() { ty::FnDef(..) => {} _ => write!(fmt, "const ")?, } diff --git a/compiler/rustc_middle/src/mir/tcx.rs b/compiler/rustc_middle/src/mir/tcx.rs index b9e4f6fb12eb1..43be3e22784e3 100644 --- a/compiler/rustc_middle/src/mir/tcx.rs +++ b/compiler/rustc_middle/src/mir/tcx.rs @@ -33,7 +33,7 @@ impl<'tcx> PlaceTy<'tcx> { /// /// Note that the resulting type has not been normalized. pub fn field_ty(self, tcx: TyCtxt<'tcx>, f: &Field) -> Ty<'tcx> { - let answer = match self.ty.kind() { + let answer = match self.ty.data() { ty::Adt(adt_def, substs) => { let variant_def = match self.variant_index { None => adt_def.non_enum_variant(), @@ -90,7 +90,7 @@ impl<'tcx> PlaceTy<'tcx> { PlaceTy::from_ty(self.ty.builtin_index().unwrap()) } ProjectionElem::Subslice { from, to, from_end } => { - PlaceTy::from_ty(match self.ty.kind() { + PlaceTy::from_ty(match self.ty.data() { ty::Slice(..) => self.ty, ty::Array(inner, _) if !from_end => tcx.mk_array(inner, (to - from) as u64), ty::Array(inner, size) if from_end => { diff --git a/compiler/rustc_middle/src/ty/_match.rs b/compiler/rustc_middle/src/ty/_match.rs index 27bccc0bcafa4..51d695675e7dc 100644 --- a/compiler/rustc_middle/src/ty/_match.rs +++ b/compiler/rustc_middle/src/ty/_match.rs @@ -67,7 +67,7 @@ impl TypeRelation<'tcx> for Match<'tcx> { return Ok(a); } - match (a.kind(), b.kind()) { + match (a.data(), b.data()) { ( _, &ty::Infer(ty::FreshTy(_)) diff --git a/compiler/rustc_middle/src/ty/cast.rs b/compiler/rustc_middle/src/ty/cast.rs index b47d9c50e1d0a..161b4f089e0be 100644 --- a/compiler/rustc_middle/src/ty/cast.rs +++ b/compiler/rustc_middle/src/ty/cast.rs @@ -50,7 +50,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.data() { 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 8ea34f9161abc..e598fe44dfd4e 100644 --- a/compiler/rustc_middle/src/ty/codec.rs +++ b/compiler/rustc_middle/src/ty/codec.rs @@ -33,13 +33,13 @@ pub trait EncodableWithShorthand<'tcx, E: TyEncoder<'tcx>>: Copy + Eq + Hash { fn variant(&self) -> &Self::Variant; } -#[allow(rustc::usage_of_ty_tykind)] +#[allow(rustc::usage_of_ty_tydata)] impl<'tcx, E: TyEncoder<'tcx>> EncodableWithShorthand<'tcx, E> for Ty<'tcx> { - type Variant = ty::TyKind<'tcx>; + type Variant = ty::TyData<'tcx>; #[inline] fn variant(&self) -> &Self::Variant { - self.kind() + self.data() } } @@ -224,7 +224,7 @@ where } impl<'tcx, D: TyDecoder<'tcx>> Decodable for Ty<'tcx> { - #[allow(rustc::usage_of_ty_tykind)] + #[allow(rustc::usage_of_ty_tydata)] fn decode(decoder: &mut D) -> Result, D::Error> { // Handle shorthands first, if we have an usize > 0x80. if decoder.positioned_at_shorthand() { @@ -237,7 +237,7 @@ impl<'tcx, D: TyDecoder<'tcx>> Decodable for Ty<'tcx> { }) } else { let tcx = decoder.tcx(); - Ok(tcx.mk_ty(ty::TyKind::decode(decoder)?)) + Ok(tcx.mk_ty(ty::TyData::decode(decoder)?)) } } } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index e67a76f0111a0..28b57ee821966 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -16,12 +16,12 @@ use crate::traits; use crate::ty::query::{self, TyCtxtAt}; use crate::ty::steal::Steal; use crate::ty::subst::{GenericArg, GenericArgKind, InternalSubsts, Subst, SubstsRef, UserSubsts}; -use crate::ty::TyKind::*; +use crate::ty::TyData::*; use crate::ty::{ self, AdtDef, AdtKind, BindingMode, BoundVar, CanonicalPolyFnSig, Const, ConstVid, DefIdTree, ExistentialPredicate, FloatVar, FloatVid, GenericParamDefKind, InferConst, InferTy, IntVar, IntVid, List, ParamConst, ParamTy, PolyFnSig, Predicate, PredicateInner, PredicateKind, - ProjectionTy, Region, RegionKind, ReprOptions, TraitObjectVisitor, Ty, TyKind, TyS, TyVar, + ProjectionTy, Region, RegionKind, ReprOptions, TraitObjectVisitor, Ty, TyData, TyS, TyVar, TyVid, TypeAndMut, }; use rustc_ast as ast; @@ -66,7 +66,7 @@ use std::mem; use std::ops::{Bound, Deref}; use std::sync::Arc; -/// A type that is not publicly constructable. This prevents people from making [`TyKind::Error`]s +/// A type that is not publicly constructable. This prevents people from making [`TyData::Error`]s /// except through the error-reporting functions on a [`tcx`][TyCtxt]. #[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] #[derive(TyEncodable, TyDecodable, HashStable)] @@ -112,15 +112,15 @@ impl<'tcx> CtxtInterners<'tcx> { } /// Interns a type. - #[allow(rustc::usage_of_ty_tykind)] + #[allow(rustc::usage_of_ty_tydata)] #[inline(never)] - fn intern_ty(&self, kind: TyKind<'tcx>) -> Ty<'tcx> { + fn intern_ty(&self, data: TyData<'tcx>) -> Ty<'tcx> { self.type_ - .intern(kind, |kind| { - let flags = super::flags::FlagComputation::for_kind(&kind); + .intern(data, |data| { + let flags = super::flags::FlagComputation::for_data(&data); let ty_struct = TyS { - kind, + data, flags: flags.flags, outer_exclusive_binder: flags.outer_exclusive_binder, }; @@ -753,7 +753,7 @@ impl CanonicalUserType<'tcx> { user_substs.substs.iter().zip(BoundVar::new(0)..).all(|(kind, cvar)| { match kind.unpack() { - GenericArgKind::Type(ty) => match ty.kind() { + GenericArgKind::Type(ty) => match ty.data() { ty::Bound(debruijn, b) => { // We only allow a `ty::INNERMOST` index in substitutions. assert_eq!(*debruijn, ty::INNERMOST); @@ -1154,13 +1154,13 @@ impl<'tcx> TyCtxt<'tcx> { } } - /// Constructs a `TyKind::Error` type and registers a `delay_span_bug` to ensure it gets used. + /// Constructs a `TyData::Error` type and registers a `delay_span_bug` to ensure it gets used. #[track_caller] pub fn ty_error(self) -> Ty<'tcx> { - self.ty_error_with_message(DUMMY_SP, "TyKind::Error constructed but no error reported") + self.ty_error_with_message(DUMMY_SP, "TyData::Error constructed but no error reported") } - /// Constructs a `TyKind::Error` type and registers a `delay_span_bug` with the given `msg` to + /// Constructs a `TyData::Error` type and registers a `delay_span_bug` with the given `msg` to /// ensure it gets used. #[track_caller] pub fn ty_error_with_message>(self, span: S, msg: &str) -> Ty<'tcx> { @@ -1492,7 +1492,7 @@ impl<'tcx> TyCtxt<'tcx> { } let ret_ty = self.type_of(scope_def_id); - match ret_ty.kind() { + match ret_ty.data() { ty::FnDef(_, _) => { let sig = ret_ty.fn_sig(self); let output = self.erase_late_bound_regions(&sig.output()); @@ -1564,7 +1564,7 @@ impl<'tcx> TyCtxt<'tcx> { /// `None` is returned if the value or one of the components is not part /// of the provided context. /// For `Ty`, `None` can be returned if either the type interner doesn't -/// contain the `TyKind` key or if the address of the interned +/// contain the `TyData` key or if the address of the interned /// pointer differs. The latter case is possible if a primitive type, /// e.g., `()` or `u8`, was interned in a different context. pub trait Lift<'tcx>: fmt::Debug { @@ -1816,7 +1816,7 @@ macro_rules! sty_debug_print { let shards = tcx.interners.type_.lock_shards(); let types = shards.iter().flat_map(|shard| shard.keys()); for &Interned(t) in types { - let variant = match t.kind() { + let variant = match t.data() { ty::Bool | ty::Char | ty::Int(..) | ty::Uint(..) | ty::Float(..) | ty::Str | ty::Never => continue, ty::Error(_) => /* unimportant */ continue, @@ -1922,10 +1922,10 @@ impl<'tcx, T: 'tcx + ?Sized> IntoPointer for Interned<'tcx, T> { self.0 as *const _ as *const () } } -// N.B., an `Interned` compares and hashes as a `TyKind`. +// N.B., an `Interned` compares and hashes as a `TyData`. impl<'tcx> PartialEq for Interned<'tcx, TyS<'tcx>> { fn eq(&self, other: &Interned<'tcx, TyS<'tcx>>) -> bool { - self.0.kind() == other.0.kind() + self.0.data() == other.0.data() } } @@ -1933,14 +1933,14 @@ impl<'tcx> Eq for Interned<'tcx, TyS<'tcx>> {} impl<'tcx> Hash for Interned<'tcx, TyS<'tcx>> { fn hash(&self, s: &mut H) { - self.0.kind().hash(s) + self.0.data().hash(s) } } -#[allow(rustc::usage_of_ty_tykind)] -impl<'tcx> Borrow> for Interned<'tcx, TyS<'tcx>> { - fn borrow<'a>(&'a self) -> &'a TyKind<'tcx> { - &self.0.kind() +#[allow(rustc::usage_of_ty_tydata)] +impl<'tcx> Borrow> for Interned<'tcx, TyS<'tcx>> { + fn borrow<'a>(&'a self) -> &'a TyData<'tcx> { + &self.0.data() } } // N.B., an `Interned` compares and hashes as a `PredicateKind`. @@ -2078,7 +2078,7 @@ impl<'tcx> TyCtxt<'tcx> { unsafety: hir::Unsafety, ) -> PolyFnSig<'tcx> { sig.map_bound(|s| { - let params_iter = match s.inputs()[0].kind() { + let params_iter = match s.inputs()[0].data() { ty::Tuple(params) => params.into_iter().map(|k| k.expect_ty()), _ => bug!(), }; @@ -2093,9 +2093,9 @@ impl<'tcx> TyCtxt<'tcx> { if *r == kind { r } else { self.mk_region(kind) } } - #[allow(rustc::usage_of_ty_tykind)] + #[allow(rustc::usage_of_ty_tydata)] #[inline] - pub fn mk_ty(self, st: TyKind<'tcx>) -> Ty<'tcx> { + pub fn mk_ty(self, st: TyData<'tcx>) -> Ty<'tcx> { self.interners.intern_ty(st) } @@ -2587,13 +2587,13 @@ impl<'tcx> TyCtxt<'tcx> { } impl TyCtxtAt<'tcx> { - /// Constructs a `TyKind::Error` type and registers a `delay_span_bug` to ensure it gets used. + /// Constructs a `TyData::Error` type and registers a `delay_span_bug` to ensure it gets used. #[track_caller] pub fn ty_error(self) -> Ty<'tcx> { - self.tcx.ty_error_with_message(self.span, "TyKind::Error constructed but no error reported") + self.tcx.ty_error_with_message(self.span, "TyData::Error constructed but no error reported") } - /// Constructs a `TyKind::Error` type and registers a `delay_span_bug` with the given `msg to + /// Constructs a `TyData::Error` type and registers a `delay_span_bug` with the given `msg to /// ensure it gets used. #[track_caller] pub fn ty_error_with_message(self, msg: &str) -> Ty<'tcx> { diff --git a/compiler/rustc_middle/src/ty/diagnostics.rs b/compiler/rustc_middle/src/ty/diagnostics.rs index 65703d04c7040..2b267e4049201 100644 --- a/compiler/rustc_middle/src/ty/diagnostics.rs +++ b/compiler/rustc_middle/src/ty/diagnostics.rs @@ -1,7 +1,7 @@ //! Diagnostics related methods for `TyS`. use crate::ty::sty::InferTy; -use crate::ty::TyKind::*; +use crate::ty::TyData::*; use crate::ty::{TyCtxt, TyS}; use rustc_errors::{Applicability, DiagnosticBuilder}; use rustc_hir as hir; @@ -12,7 +12,7 @@ impl<'tcx> TyS<'tcx> { /// Similar to `TyS::is_primitive`, but also considers inferred numeric values to be primitive. pub fn is_primitive_ty(&self) -> bool { matches!( - self.kind(), + self.data(), Bool | Char | Str | Int(_) | Uint(_) | Float(_) | Infer( InferTy::IntVar(_) @@ -26,7 +26,7 @@ impl<'tcx> TyS<'tcx> { /// Whether the type is succinctly representable as a type instead of just referred to with a /// description in error messages. This is used in the main error message. pub fn is_simple_ty(&self) -> bool { - match self.kind() { + match self.data() { Bool | Char | Str @@ -50,7 +50,7 @@ impl<'tcx> TyS<'tcx> { /// `is_simple_ty` includes, it also accepts ADTs with no type arguments and references to /// ADTs with no type arguments. pub fn is_simple_text(&self) -> bool { - match self.kind() { + match self.data() { Adt(_, substs) => substs.types().next().is_none(), Ref(_, ty, _) => ty.is_simple_text(), _ => self.is_simple_ty(), @@ -60,7 +60,7 @@ impl<'tcx> TyS<'tcx> { /// Whether the type can be safely suggested during error recovery. pub fn is_suggestable(&self) -> bool { !matches!( - self.kind(), + self.data(), Opaque(..) | FnDef(..) | FnPtr(..) diff --git a/compiler/rustc_middle/src/ty/error.rs b/compiler/rustc_middle/src/ty/error.rs index 82d698b37ab1d..770d8fefb93b0 100644 --- a/compiler/rustc_middle/src/ty/error.rs +++ b/compiler/rustc_middle/src/ty/error.rs @@ -220,7 +220,7 @@ impl<'tcx> TypeError<'tcx> { impl<'tcx> ty::TyS<'tcx> { pub fn sort_string(&self, tcx: TyCtxt<'_>) -> Cow<'static, str> { - match *self.kind() { + match *self.data() { ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Str | ty::Never => { format!("`{}`", self).into() } @@ -284,7 +284,7 @@ impl<'tcx> ty::TyS<'tcx> { } pub fn prefix_string(&self) -> Cow<'static, str> { - match *self.kind() { + match *self.data() { ty::Infer(_) | ty::Error(_) | ty::Bool @@ -353,7 +353,7 @@ impl<'tcx> TyCtxt<'tcx> { ); } } - match (values.expected.kind(), values.found.kind()) { + match (values.expected.data(), values.found.data()) { (ty::Float(_), ty::Infer(ty::IntVar(_))) => { if let Ok( // Issue #53280 @@ -527,9 +527,9 @@ impl Trait for X { debug!( "note_and_explain_type_err expected={:?} ({:?}) found={:?} ({:?})", values.expected, - values.expected.kind(), + values.expected.data(), values.found, - values.found.kind(), + values.found.data(), ); } CyclicTy(ty) => { @@ -573,7 +573,7 @@ impl Trait for X { if let Some(hir_generics) = item.generics() { // Get the `DefId` for the type parameter corresponding to `A` in `::Foo`. // This will also work for `impl Trait`. - let def_id = if let ty::Param(param_ty) = proj_ty.self_ty().kind() { + let def_id = if let ty::Param(param_ty) = proj_ty.self_ty().data() { let generics = self.generics_of(body_owner_def_id); generics.type_param(param_ty, self).def_id } else { @@ -697,7 +697,7 @@ impl Trait for X { } } - if let ty::Opaque(def_id, _) = *proj_ty.self_ty().kind() { + if let ty::Opaque(def_id, _) = *proj_ty.self_ty().data() { // When the expected `impl Trait` is not defined in the current item, it will come from // a return type. This can occur when dealing with `TryStream` (#71035). if self.constrain_associated_type_structured_suggestion( @@ -767,7 +767,7 @@ fn foo(&self) -> Self::T { String::new() } }) .filter_map(|(_, item)| { let method = self.fn_sig(item.def_id); - match *method.output().skip_binder().kind() { + match *method.output().skip_binder().data() { ty::Projection(ty::ProjectionTy { item_def_id, .. }) if item_def_id == proj_ty_item_def_id => { diff --git a/compiler/rustc_middle/src/ty/fast_reject.rs b/compiler/rustc_middle/src/ty/fast_reject.rs index 860f91db2bf7a..7d172aafd2dac 100644 --- a/compiler/rustc_middle/src/ty/fast_reject.rs +++ b/compiler/rustc_middle/src/ty/fast_reject.rs @@ -60,7 +60,7 @@ pub fn simplify_type( ty: Ty<'_>, can_simplify_params: bool, ) -> Option { - match *ty.kind() { + match *ty.data() { ty::Bool => Some(BoolSimplifiedType), ty::Char => Some(CharSimplifiedType), ty::Int(int_type) => Some(IntSimplifiedType(int_type)), diff --git a/compiler/rustc_middle/src/ty/flags.rs b/compiler/rustc_middle/src/ty/flags.rs index c9a4022330a7a..55e563bd6f69f 100644 --- a/compiler/rustc_middle/src/ty/flags.rs +++ b/compiler/rustc_middle/src/ty/flags.rs @@ -15,10 +15,10 @@ impl FlagComputation { FlagComputation { flags: TypeFlags::empty(), outer_exclusive_binder: ty::INNERMOST } } - #[allow(rustc::usage_of_ty_tykind)] - pub fn for_kind(kind: &ty::TyKind<'_>) -> FlagComputation { + #[allow(rustc::usage_of_ty_tydata)] + pub fn for_data(data: &ty::TyData<'_>) -> FlagComputation { let mut result = FlagComputation::new(); - result.add_kind(kind); + result.add_kind(data); result } @@ -65,8 +65,8 @@ impl FlagComputation { } // otherwise, this binder captures nothing } - #[allow(rustc::usage_of_ty_tykind)] - fn add_kind(&mut self, kind: &ty::TyKind<'_>) { + #[allow(rustc::usage_of_ty_tydata)] + fn add_kind(&mut self, kind: &ty::TyData<'_>) { match kind { &ty::Bool | &ty::Char diff --git a/compiler/rustc_middle/src/ty/fold.rs b/compiler/rustc_middle/src/ty/fold.rs index 84134bedef0bc..6637c79f48d48 100644 --- a/compiler/rustc_middle/src/ty/fold.rs +++ b/compiler/rustc_middle/src/ty/fold.rs @@ -471,7 +471,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for BoundVarReplacer<'a, 'tcx> { } fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { - match *t.kind() { + match *t.data() { ty::Bound(debruijn, bound_ty) => { if debruijn == self.current_index { let fld_t = &mut self.fld_t; @@ -771,7 +771,7 @@ impl TypeFolder<'tcx> for Shifter<'tcx> { } fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { - match *ty.kind() { + match *ty.data() { ty::Bound(debruijn, bound_ty) => { if self.amount == 0 || debruijn < self.current_index { ty @@ -992,7 +992,7 @@ impl<'tcx> TypeVisitor<'tcx> for LateBoundRegionsCollector { // ignore the inputs to a projection, as they may not appear // in the normalized form if self.just_constrained { - if let ty::Projection(..) | ty::Opaque(..) = t.kind() { + if let ty::Projection(..) | ty::Opaque(..) = t.data() { return false; } } diff --git a/compiler/rustc_middle/src/ty/inhabitedness/mod.rs b/compiler/rustc_middle/src/ty/inhabitedness/mod.rs index 2c1179c21fb6a..0d1ada232efda 100644 --- a/compiler/rustc_middle/src/ty/inhabitedness/mod.rs +++ b/compiler/rustc_middle/src/ty/inhabitedness/mod.rs @@ -2,7 +2,7 @@ pub use self::def_id_forest::DefIdForest; use crate::ty; use crate::ty::context::TyCtxt; -use crate::ty::TyKind::*; +use crate::ty::TyData::*; use crate::ty::{AdtDef, FieldDef, Ty, TyS, VariantDef}; use crate::ty::{AdtKind, Visibility}; use crate::ty::{DefId, SubstsRef}; @@ -196,7 +196,7 @@ impl<'tcx> FieldDef { impl<'tcx> TyS<'tcx> { /// Calculates the forest of `DefId`s from which this type is visibly uninhabited. fn uninhabited_from(&self, tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> DefIdForest { - match *self.kind() { + match *self.data() { Adt(def, substs) => { ensure_sufficient_stack(|| def.uninhabited_from(tcx, substs, param_env)) } diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs index f8e8c209d373d..5c598ff8cf0cc 100644 --- a/compiler/rustc_middle/src/ty/instance.rs +++ b/compiler/rustc_middle/src/ty/instance.rs @@ -516,7 +516,7 @@ fn polymorphize<'tcx>( fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { debug!("fold_ty: ty={:?}", ty); - match ty.kind { + match ty.data { ty::Closure(def_id, substs) => { let polymorphized_substs = polymorphize(self.tcx, def_id, substs); if substs == polymorphized_substs { diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index f6f71d002a88a..b9a75c9d70fc2 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -477,7 +477,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { }; debug_assert!(!ty.has_infer_types_or_consts()); - Ok(match *ty.kind() { + Ok(match *ty.data() { // Basic scalars. ty::Bool => tcx.intern_layout(Layout::scalar( self, @@ -522,7 +522,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { } let unsized_part = tcx.struct_tail_erasing_lifetimes(pointee, param_env); - let metadata = match unsized_part.kind() { + let metadata = match unsized_part.data() { ty::Foreign(..) => { return Ok(tcx.intern_layout(Layout::scalar(self, data_ptr))); } @@ -1606,7 +1606,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { ); }; - let adt_def = match *layout.ty.kind() { + let adt_def = match *layout.ty.data() { ty::Adt(ref adt_def, _) => { debug!("print-type-size t: `{:?}` process adt", layout.ty); adt_def @@ -1749,11 +1749,11 @@ impl<'tcx> SizeSkeleton<'tcx> { Err(err) => err, }; - match *ty.kind() { + match *ty.data() { ty::Ref(_, pointee, _) | ty::RawPtr(ty::TypeAndMut { ty: pointee, .. }) => { let non_zero = !ty.is_unsafe_ptr(); let tail = tcx.struct_tail_erasing_lifetimes(pointee, param_env); - match tail.kind() { + match tail.data() { ty::Param(_) | ty::Projection(_) => { debug_assert!(tail.has_param_types_or_consts()); Ok(SizeSkeleton::Pointer { non_zero, tail: tcx.erase_regions(&tail) }) @@ -2000,7 +2000,7 @@ where assert_eq!(original_layout.variants, Variants::Single { index }); } - let fields = match this.ty.kind() { + let fields = match this.ty.data() { ty::Adt(def, _) if def.variants.is_empty() => bug!("for_variant called on zero-variant enum"), ty::Adt(def, _) => def.variants[variant_index].fields.len(), @@ -2038,7 +2038,7 @@ where })) }; - cx.layout_of(match *this.ty.kind() { + cx.layout_of(match *this.ty.data() { ty::Bool | ty::Char | ty::Int(_) @@ -2074,7 +2074,7 @@ where )); } - match tcx.struct_tail_erasing_lifetimes(pointee, cx.param_env()).kind() { + match tcx.struct_tail_erasing_lifetimes(pointee, cx.param_env()).data() { ty::Slice(_) | ty::Str => tcx.types.usize, ty::Dynamic(_, _) => { tcx.mk_imm_ref(tcx.lifetimes.re_static, tcx.mk_array(tcx.types.usize, 3)) @@ -2152,7 +2152,7 @@ where if ty.is_fn() { cx.data_layout().instruction_address_space } else { AddressSpace::DATA } }; - let pointee_info = match *this.ty.kind() { + let pointee_info = match *this.ty.data() { ty::RawPtr(mt) if offset.bytes() == 0 => { cx.layout_of(mt.ty).to_result().ok().map(|layout| PointeeInfo { size: layout.size, @@ -2268,7 +2268,7 @@ where // FIXME(eddyb) This should be for `ptr::Unique`, not `Box`. if let Some(ref mut pointee) = result { - if let ty::Adt(def, _) = this.ty.kind() { + if let ty::Adt(def, _) = this.ty.data() { if def.is_box() && offset.bytes() == 0 { pointee.safe = Some(PointerKind::UniqueOwned); } @@ -2282,7 +2282,7 @@ where debug!( "pointee_info_at (offset={:?}, type kind: {:?}) => {:?}", offset, - this.ty.kind(), + this.ty.data(), pointee_info ); @@ -2310,14 +2310,14 @@ impl<'tcx> ty::Instance<'tcx> { fn fn_sig_for_fn_abi(&self, tcx: TyCtxt<'tcx>) -> ty::PolyFnSig<'tcx> { // FIXME(davidtwco,eddyb): A `ParamEnv` should be passed through to this function. let ty = self.ty(tcx, ty::ParamEnv::reveal_all()); - match *ty.kind() { + match *ty.data() { 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` // (i.e. due to being inside a projection that got normalized, see // `src/test/ui/polymorphization/normalized_sig_types.rs`), and codegen not keeping // track of a polymorphization `ParamEnv` to allow normalizing later. - let mut sig = match *ty.kind() { + let mut sig = match *ty.data() { ty::FnDef(def_id, substs) => tcx .normalize_erasing_regions(tcx.param_env(def_id), tcx.fn_sig(def_id)) .subst(tcx, substs), @@ -2580,7 +2580,7 @@ where assert!(!sig.c_variadic && extra_args.is_empty()); if let Some(input) = sig.inputs().last() { - if let ty::Tuple(tupled_arguments) = input.kind() { + if let ty::Tuple(tupled_arguments) = input.data() { inputs = &sig.inputs()[0..sig.inputs().len() - 1]; tupled_arguments.iter().map(|k| k.expect_ty()).collect() } else { diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index f069faed9e200..3c5fd03d3a563 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -55,7 +55,7 @@ pub use self::sty::BoundRegion::*; pub use self::sty::InferTy::*; pub use self::sty::RegionKind; pub use self::sty::RegionKind::*; -pub use self::sty::TyKind::*; +pub use self::sty::TyData::*; pub use self::sty::{Binder, BoundTy, BoundTyKind, BoundVar, DebruijnIndex, INNERMOST}; pub use self::sty::{BoundRegion, EarlyBoundRegion, FreeRegion, Region}; pub use self::sty::{CanonicalPolyFnSig, FnSig, GenSig, PolyFnSig, PolyGenSig}; @@ -65,7 +65,7 @@ pub use self::sty::{ConstVid, FloatVid, IntVid, RegionVid, TyVid}; pub use self::sty::{ExistentialPredicate, InferTy, ParamConst, ParamTy, ProjectionTy}; pub use self::sty::{ExistentialProjection, PolyExistentialProjection}; pub use self::sty::{ExistentialTraitRef, PolyExistentialTraitRef}; -pub use self::sty::{PolyTraitRef, TraitRef, TyKind}; +pub use self::sty::{PolyTraitRef, TraitRef, TyData}; pub use crate::ty::diagnostics::*; pub use self::binding::BindingMode; @@ -578,11 +578,11 @@ bitflags! { } } -#[allow(rustc::usage_of_ty_tykind)] +#[allow(rustc::usage_of_ty_tydata)] pub struct TyS<'tcx> { /// This field shouldn't be used directly and may be removed in the future. - /// Use `TyS::kind()` instead. - kind: TyKind<'tcx>, + /// Use `TyS::data()` instead. + data: TyData<'tcx>, /// This field shouldn't be used directly and may be removed in the future. /// Use `TyS::flags()` instead. flags: TypeFlags, @@ -613,13 +613,13 @@ static_assert_size!(TyS<'_>, 32); impl<'tcx> Ord for TyS<'tcx> { fn cmp(&self, other: &TyS<'tcx>) -> Ordering { - self.kind().cmp(other.kind()) + self.data().cmp(other.data()) } } impl<'tcx> PartialOrd for TyS<'tcx> { fn partial_cmp(&self, other: &TyS<'tcx>) -> Option { - Some(self.kind().cmp(other.kind())) + Some(self.data().cmp(other.data())) } } @@ -640,7 +640,7 @@ impl<'tcx> Hash for TyS<'tcx> { impl<'a, 'tcx> HashStable> for TyS<'tcx> { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { let ty::TyS { - ref kind, + data: ref kind, // The other fields just provide fast access to information that is // also contained in `kind`, so no need to hash them. @@ -2643,7 +2643,7 @@ impl<'tcx> AdtDef { impl<'tcx> FieldDef { /// Returns the type of this field. The `subst` is typically obtained - /// via the second field of `TyKind::AdtDef`. + /// via the second field of `TyData::AdtDef`. pub fn ty(&self, tcx: TyCtxt<'tcx>, subst: SubstsRef<'tcx>) -> Ty<'tcx> { tcx.type_of(self.did).subst(tcx, subst) } diff --git a/compiler/rustc_middle/src/ty/outlives.rs b/compiler/rustc_middle/src/ty/outlives.rs index 4c20141bbe691..eddca9e92e72c 100644 --- a/compiler/rustc_middle/src/ty/outlives.rs +++ b/compiler/rustc_middle/src/ty/outlives.rs @@ -68,7 +68,7 @@ fn compute_components( // 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.data() { ty::FnDef(_, substs) => { // HACK(eddyb) ignore lifetimes found shallowly in `substs`. // This is inconsistent with `ty::Adt` (including all substs) diff --git a/compiler/rustc_middle/src/ty/print/mod.rs b/compiler/rustc_middle/src/ty/print/mod.rs index 2e00be2395b8c..cf86abe83ca2a 100644 --- a/compiler/rustc_middle/src/ty/print/mod.rs +++ b/compiler/rustc_middle/src/ty/print/mod.rs @@ -271,7 +271,7 @@ fn characteristic_def_id_of_type_cached<'a>( ty: Ty<'a>, visited: &mut SsoHashSet>, ) -> Option { - match *ty.kind() { + match *ty.data() { 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 e1f02d0f70418..cb2d10d03f1c9 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -460,7 +460,7 @@ pub trait PrettyPrinter<'tcx>: // Inherent impls. Try to print `Foo::bar` for an inherent // impl on `Foo`, but fallback to `::bar` if self-type is // anything other than a simple path. - match self_ty.kind() { + match self_ty.data() { ty::Adt(..) | ty::Foreign(_) | ty::Bool @@ -511,7 +511,7 @@ pub trait PrettyPrinter<'tcx>: fn pretty_print_type(mut self, ty: Ty<'tcx>) -> Result { define_scoped_cx!(self); - match *ty.kind() { + match *ty.data() { ty::Bool => p!("bool"), ty::Char => p!("char"), ty::Int(t) => p!(write("{}", t.name_str())), @@ -783,7 +783,7 @@ pub trait PrettyPrinter<'tcx>: // Special-case `Fn(...) -> ...` and resugar it. let fn_trait_kind = self.tcx().fn_trait_kind_from_lang_item(principal.def_id); if !self.tcx().sess.verbose() && fn_trait_kind.is_some() { - if let ty::Tuple(ref args) = principal.substs.type_at(0).kind() { + if let ty::Tuple(ref args) = principal.substs.type_at(0).data() { let mut projections = predicates.projection_bounds(); if let (Some(proj), None) = (projections.next(), projections.next()) { let tys: Vec<_> = args.iter().map(|k| k.expect_ty()).collect(); @@ -962,16 +962,16 @@ pub trait PrettyPrinter<'tcx>: ) -> Result { define_scoped_cx!(self); - match (scalar, &ty.kind()) { + match (scalar, &ty.data()) { // Byte strings (&[u8; N]) ( Scalar::Ptr(ptr), ty::Ref( _, ty::TyS { - kind: + data: ty::Array( - ty::TyS { kind: ty::Uint(ast::UintTy::U8), .. }, + ty::TyS { data: ty::Uint(ast::UintTy::U8), .. }, ty::Const { val: ty::ConstKind::Value(ConstValue::Scalar(Scalar::Raw { @@ -1122,11 +1122,11 @@ pub trait PrettyPrinter<'tcx>: let u8_type = self.tcx().types.u8; - match (ct, ty.kind()) { + match (ct, ty.data()) { // Byte/string slices, printed as (byte) string literals. ( ConstValue::Slice { data, start, end }, - ty::Ref(_, ty::TyS { kind: ty::Slice(t), .. }, _), + ty::Ref(_, ty::TyS { data: ty::Slice(t), .. }, _), ) if *t == u8_type => { // The `inspect` here is okay since we checked the bounds, and there are // no relocations (we have an active slice reference here). We don't use @@ -1136,7 +1136,7 @@ pub trait PrettyPrinter<'tcx>: } ( ConstValue::Slice { data, start, end }, - ty::Ref(_, ty::TyS { kind: ty::Str, .. }, _), + ty::Ref(_, ty::TyS { data: ty::Str, .. }, _), ) => { // The `inspect` here is okay since we checked the bounds, and there are no // relocations (we have an active `str` reference here). We don't use this @@ -1175,7 +1175,7 @@ pub trait PrettyPrinter<'tcx>: ); let fields = contents.fields.iter().copied(); - match *ty.kind() { + match *ty.data() { ty::Array(..) => { p!("[", comma_sep(fields), "]"); } diff --git a/compiler/rustc_middle/src/ty/relate.rs b/compiler/rustc_middle/src/ty/relate.rs index c4df0bba726cb..abe2544192142 100644 --- a/compiler/rustc_middle/src/ty/relate.rs +++ b/compiler/rustc_middle/src/ty/relate.rs @@ -325,7 +325,7 @@ pub fn super_relate_tys>( ) -> RelateResult<'tcx, Ty<'tcx>> { let tcx = relation.tcx(); debug!("super_relate_tys: a={:?} b={:?}", a, b); - match (a.kind(), b.kind()) { + match (a.data(), b.data()) { (&ty::Infer(_), _) | (_, &ty::Infer(_)) => { // The caller should handle these cases! bug!("var types encountered in super_relate_tys") @@ -516,7 +516,7 @@ pub fn super_relate_consts>( (ConstValue::Scalar(a_val), ConstValue::Scalar(b_val)) if a.ty == b.ty => { if a_val == b_val { Ok(ConstValue::Scalar(a_val)) - } else if let ty::FnPtr(_) = a.ty.kind() { + } else if let ty::FnPtr(_) = a.ty.data() { let a_instance = tcx.global_alloc(a_val.assert_ptr().alloc_id).unwrap_fn(); let b_instance = tcx.global_alloc(b_val.assert_ptr().alloc_id).unwrap_fn(); if a_instance == b_instance { @@ -540,7 +540,7 @@ pub fn super_relate_consts>( } (ConstValue::ByRef { .. }, ConstValue::ByRef { .. }) => { - match a.ty.kind() { + match a.ty.data() { ty::Array(..) | ty::Adt(..) | ty::Tuple(..) => { let a_destructured = tcx.destructure_const(relation.param_env().and(a)); let b_destructured = tcx.destructure_const(relation.param_env().and(b)); diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index 597ceac9386a0..64e3bd18cae50 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -933,7 +933,7 @@ impl<'tcx> TypeFoldable<'tcx> for interpret::GlobalId<'tcx> { impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> { fn super_fold_with>(&self, folder: &mut F) -> Self { - let kind = match self.kind() { + let data = match self.data() { ty::RawPtr(tm) => ty::RawPtr(tm.fold_with(folder)), ty::Array(typ, sz) => ty::Array(typ.fold_with(folder), sz.fold_with(folder)), ty::Slice(typ) => ty::Slice(typ.fold_with(folder)), @@ -968,7 +968,7 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> { | ty::Foreign(..) => return self, }; - if *self.kind() == kind { self } else { folder.tcx().mk_ty(kind) } + if *self.data() == data { self } else { folder.tcx().mk_ty(data) } } fn fold_with>(&self, folder: &mut F) -> Self { @@ -976,7 +976,7 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> { } fn super_visit_with>(&self, visitor: &mut V) -> bool { - match self.kind() { + match self.data() { ty::RawPtr(ref tm) => tm.visit_with(visitor), ty::Array(typ, sz) => typ.visit_with(visitor) || sz.visit_with(visitor), ty::Slice(typ) => typ.visit_with(visitor), diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 1af56972ad083..4ae08969ccecd 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -1,9 +1,9 @@ -//! This module contains `TyKind` and its major components. +//! This module contains `TyData` and its major components. -#![allow(rustc::usage_of_ty_tykind)] +#![allow(rustc::usage_of_ty_tydata)] use self::InferTy::*; -use self::TyKind::*; +use self::TyData::*; use crate::infer::canonical::Canonical; use crate::ty::subst::{GenericArg, InternalSubsts, Subst, SubstsRef}; @@ -84,8 +84,8 @@ impl BoundRegion { /// AST structure in `librustc_ast/ast.rs` as well. #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable, Debug)] #[derive(HashStable)] -#[rustc_diagnostic_item = "TyKind"] -pub enum TyKind<'tcx> { +#[rustc_diagnostic_item = "TyData"] +pub enum TyData<'tcx> { /// The primitive boolean type. Written as `bool`. Bool, @@ -202,7 +202,7 @@ pub enum TyKind<'tcx> { Error(DelaySpanBugEmitted), } -impl TyKind<'tcx> { +impl TyData<'tcx> { #[inline] pub fn is_primitive(&self) -> bool { match self { @@ -212,9 +212,9 @@ impl TyKind<'tcx> { } } -// `TyKind` is used a lot. Make sure it doesn't unintentionally get bigger. +// `TyData` is used a lot. Make sure it doesn't unintentionally get bigger. #[cfg(target_arch = "x86_64")] -static_assert_size!(TyKind<'_>, 24); +static_assert_size!(TyData<'_>, 24); /// A closure can be modeled as a struct that looks like: /// @@ -368,7 +368,7 @@ impl<'tcx> ClosureSubsts<'tcx> { /// types that haven't had their synthetic types substituted in. pub fn is_valid(self) -> bool { self.substs.len() >= 3 - && matches!(self.split().tupled_upvars_ty.expect_ty().kind(), Tuple(_)) + && matches!(self.split().tupled_upvars_ty.expect_ty().data(), Tuple(_)) } /// Returns the substitutions of the closure's parent. @@ -415,9 +415,9 @@ impl<'tcx> ClosureSubsts<'tcx> { /// Extracts the signature from the closure. pub fn sig(self) -> ty::PolyFnSig<'tcx> { let ty = self.sig_as_fn_ptr_ty(); - match ty.kind() { + match ty.data() { ty::FnPtr(sig) => *sig, - _ => bug!("closure_sig_as_fn_ptr_ty is not a fn-ptr: {:?}", ty.kind()), + _ => bug!("closure_sig_as_fn_ptr_ty is not a fn-ptr: {:?}", ty.data()), } } } @@ -486,7 +486,7 @@ impl<'tcx> GeneratorSubsts<'tcx> { /// types that haven't had their synthetic types substituted in. pub fn is_valid(self) -> bool { self.substs.len() >= 5 - && matches!(self.split().tupled_upvars_ty.expect_ty().kind(), Tuple(_)) + && matches!(self.split().tupled_upvars_ty.expect_ty().data(), Tuple(_)) } /// Returns the substitutions of the generator's parent. @@ -1138,7 +1138,7 @@ impl<'tcx> FnSig<'tcx> { self.inputs_and_output[self.inputs_and_output.len() - 1] } - // Creates a minimal `FnSig` to be used when encountering a `TyKind::Error` in a fallible + // Creates a minimal `FnSig` to be used when encountering a `TyData::Error` in a fallible // method. fn fake() -> FnSig<'tcx> { FnSig { @@ -1747,8 +1747,8 @@ impl RegionKind { /// Type utilities impl<'tcx> TyS<'tcx> { #[inline(always)] - pub fn kind(&self) -> &TyKind<'tcx> { - &self.kind + pub fn data(&self) -> &TyData<'tcx> { + &self.data } #[inline(always)] @@ -1758,7 +1758,7 @@ impl<'tcx> TyS<'tcx> { #[inline] pub fn is_unit(&self) -> bool { - match self.kind() { + match self.data() { Tuple(ref tys) => tys.is_empty(), _ => false, } @@ -1766,7 +1766,7 @@ impl<'tcx> TyS<'tcx> { #[inline] pub fn is_never(&self) -> bool { - matches!(self.kind(), Never) + matches!(self.data(), Never) } /// Checks whether a type is definitely uninhabited. This is @@ -1778,7 +1778,7 @@ impl<'tcx> TyS<'tcx> { pub fn conservative_is_privately_uninhabited(&self, tcx: TyCtxt<'tcx>) -> bool { // FIXME(varkor): we can make this less conversative by substituting concrete // type arguments. - match self.kind() { + match self.data() { ty::Never => true, ty::Adt(def, _) if def.is_union() => { // For now, `union`s are never considered uninhabited. @@ -1818,48 +1818,48 @@ impl<'tcx> TyS<'tcx> { #[inline] pub fn is_primitive(&self) -> bool { - self.kind().is_primitive() + self.data().is_primitive() } #[inline] pub fn is_adt(&self) -> bool { - matches!(self.kind(), Adt(..)) + matches!(self.data(), Adt(..)) } #[inline] pub fn is_ref(&self) -> bool { - matches!(self.kind(), Ref(..)) + matches!(self.data(), Ref(..)) } #[inline] pub fn is_ty_var(&self) -> bool { - matches!(self.kind(), Infer(TyVar(_))) + matches!(self.data(), Infer(TyVar(_))) } #[inline] pub fn is_ty_infer(&self) -> bool { - matches!(self.kind(), Infer(_)) + matches!(self.data(), Infer(_)) } #[inline] pub fn is_phantom_data(&self) -> bool { - if let Adt(def, _) = self.kind() { def.is_phantom_data() } else { false } + if let Adt(def, _) = self.data() { def.is_phantom_data() } else { false } } #[inline] pub fn is_bool(&self) -> bool { - *self.kind() == Bool + *self.data() == Bool } /// Returns `true` if this type is a `str`. #[inline] pub fn is_str(&self) -> bool { - *self.kind() == Str + *self.data() == Str } #[inline] pub fn is_param(&self, index: u32) -> bool { - match self.kind() { + match self.data() { ty::Param(ref data) => data.index == index, _ => false, } @@ -1867,27 +1867,27 @@ impl<'tcx> TyS<'tcx> { #[inline] pub fn is_slice(&self) -> bool { - match self.kind() { - RawPtr(TypeAndMut { ty, .. }) | Ref(_, ty, _) => matches!(ty.kind(), Slice(_) | Str), + match self.data() { + RawPtr(TypeAndMut { ty, .. }) | Ref(_, ty, _) => matches!(ty.data(), Slice(_) | Str), _ => false, } } #[inline] pub fn is_array(&self) -> bool { - matches!(self.kind(), Array(..)) + matches!(self.data(), Array(..)) } #[inline] pub fn is_simd(&self) -> bool { - match self.kind() { + match self.data() { Adt(def, _) => def.repr.simd(), _ => false, } } pub fn sequence_element_type(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { - match self.kind() { + match self.data() { Array(ty, _) | Slice(ty) => ty, Str => tcx.mk_mach_uint(ast::UintTy::U8), _ => bug!("`sequence_element_type` called on non-sequence value: {}", self), @@ -1895,7 +1895,7 @@ impl<'tcx> TyS<'tcx> { } pub fn simd_type(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { - match self.kind() { + match self.data() { Adt(def, substs) => def.non_enum_variant().fields[0].ty(tcx, substs), _ => bug!("`simd_type` called on invalid type"), } @@ -1904,14 +1904,14 @@ impl<'tcx> TyS<'tcx> { pub fn simd_size(&self, _tcx: TyCtxt<'tcx>) -> u64 { // Parameter currently unused, but probably needed in the future to // allow `#[repr(simd)] struct Simd([T; N]);`. - match self.kind() { + match self.data() { Adt(def, _) => def.non_enum_variant().fields.len() as u64, _ => bug!("`simd_size` called on invalid type"), } } pub fn simd_size_and_type(&self, tcx: TyCtxt<'tcx>) -> (u64, Ty<'tcx>) { - match self.kind() { + match self.data() { Adt(def, substs) => { let variant = def.non_enum_variant(); (variant.fields.len() as u64, variant.fields[0].ty(tcx, substs)) @@ -1922,13 +1922,13 @@ impl<'tcx> TyS<'tcx> { #[inline] pub fn is_region_ptr(&self) -> bool { - matches!(self.kind(), Ref(..)) + matches!(self.data(), Ref(..)) } #[inline] pub fn is_mutable_ptr(&self) -> bool { matches!( - self.kind(), + self.data(), RawPtr(TypeAndMut { mutbl: hir::Mutability::Mut, .. }) | Ref(_, _, hir::Mutability::Mut) ) @@ -1936,7 +1936,7 @@ impl<'tcx> TyS<'tcx> { #[inline] pub fn is_unsafe_ptr(&self) -> bool { - matches!(self.kind(), RawPtr(_)) + matches!(self.data(), RawPtr(_)) } /// Tests if this is any kind of primitive pointer type (reference, raw pointer, fn pointer). @@ -1947,7 +1947,7 @@ impl<'tcx> TyS<'tcx> { #[inline] pub fn is_box(&self) -> bool { - match self.kind() { + match self.data() { Adt(def, _) => def.is_box(), _ => false, } @@ -1955,7 +1955,7 @@ impl<'tcx> TyS<'tcx> { /// Panics if called on any type other than `Box`. pub fn boxed_ty(&self) -> Ty<'tcx> { - match self.kind() { + match self.data() { Adt(def, substs) if def.is_box() => substs.type_at(0), _ => bug!("`boxed_ty` is called on non-box type {:?}", self), } @@ -1967,7 +1967,7 @@ impl<'tcx> TyS<'tcx> { #[inline] pub fn is_scalar(&self) -> bool { matches!( - self.kind(), + self.data(), Bool | Char | Int(_) | Float(_) | Uint(_) | FnDef(..) | FnPtr(_) | RawPtr(_) | Infer(IntVar(_) | FloatVar(_)) ) @@ -1976,17 +1976,17 @@ impl<'tcx> TyS<'tcx> { /// Returns `true` if this type is a floating point type. #[inline] pub fn is_floating_point(&self) -> bool { - matches!(self.kind(), Float(_) | Infer(FloatVar(_))) + matches!(self.data(), Float(_) | Infer(FloatVar(_))) } #[inline] pub fn is_trait(&self) -> bool { - matches!(self.kind(), Dynamic(..)) + matches!(self.data(), Dynamic(..)) } #[inline] pub fn is_enum(&self) -> bool { - match self.kind() { + match self.data() { Adt(adt_def, _) => adt_def.is_enum(), _ => false, } @@ -1994,32 +1994,32 @@ impl<'tcx> TyS<'tcx> { #[inline] pub fn is_closure(&self) -> bool { - matches!(self.kind(), Closure(..)) + matches!(self.data(), Closure(..)) } #[inline] pub fn is_generator(&self) -> bool { - matches!(self.kind(), Generator(..)) + matches!(self.data(), Generator(..)) } #[inline] pub fn is_integral(&self) -> bool { - matches!(self.kind(), Infer(IntVar(_)) | Int(_) | Uint(_)) + matches!(self.data(), Infer(IntVar(_)) | Int(_) | Uint(_)) } #[inline] pub fn is_fresh_ty(&self) -> bool { - matches!(self.kind(), Infer(FreshTy(_))) + matches!(self.data(), Infer(FreshTy(_))) } #[inline] pub fn is_fresh(&self) -> bool { - matches!(self.kind(), Infer(FreshTy(_) | FreshIntTy(_) | FreshFloatTy(_))) + matches!(self.data(), Infer(FreshTy(_) | FreshIntTy(_) | FreshFloatTy(_))) } #[inline] pub fn is_char(&self) -> bool { - matches!(self.kind(), Char) + matches!(self.data(), Char) } #[inline] @@ -2029,22 +2029,22 @@ impl<'tcx> TyS<'tcx> { #[inline] pub fn is_signed(&self) -> bool { - matches!(self.kind(), Int(_)) + matches!(self.data(), Int(_)) } #[inline] pub fn is_ptr_sized_integral(&self) -> bool { - matches!(self.kind(), Int(ast::IntTy::Isize) | Uint(ast::UintTy::Usize)) + matches!(self.data(), Int(ast::IntTy::Isize) | Uint(ast::UintTy::Usize)) } #[inline] pub fn is_machine(&self) -> bool { - matches!(self.kind(), Int(..) | Uint(..) | Float(..)) + matches!(self.data(), Int(..) | Uint(..) | Float(..)) } #[inline] pub fn has_concrete_skeleton(&self) -> bool { - !matches!(self.kind(), Param(_) | Infer(_) | Error(_)) + !matches!(self.data(), Param(_) | Infer(_) | Error(_)) } /// Returns the type and mutability of `*ty`. @@ -2052,7 +2052,7 @@ impl<'tcx> TyS<'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.data() { Adt(def, _) if def.is_box() => { Some(TypeAndMut { ty: self.boxed_ty(), mutbl: hir::Mutability::Not }) } @@ -2064,14 +2064,14 @@ impl<'tcx> TyS<'tcx> { /// Returns the type of `ty[i]`. pub fn builtin_index(&self) -> Option> { - match self.kind() { + match self.data() { Array(ty, _) | Slice(ty) => Some(ty), _ => None, } } pub fn fn_sig(&self, tcx: TyCtxt<'tcx>) -> PolyFnSig<'tcx> { - match self.kind() { + match self.data() { FnDef(def_id, substs) => tcx.fn_sig(*def_id).subst(tcx, substs), FnPtr(f) => *f, Error(_) => { @@ -2087,22 +2087,22 @@ impl<'tcx> TyS<'tcx> { #[inline] pub fn is_fn(&self) -> bool { - matches!(self.kind(), FnDef(..) | FnPtr(_)) + matches!(self.data(), FnDef(..) | FnPtr(_)) } #[inline] pub fn is_fn_ptr(&self) -> bool { - matches!(self.kind(), FnPtr(_)) + matches!(self.data(), FnPtr(_)) } #[inline] pub fn is_impl_trait(&self) -> bool { - matches!(self.kind(), Opaque(..)) + matches!(self.data(), Opaque(..)) } #[inline] pub fn ty_adt_def(&self) -> Option<&'tcx AdtDef> { - match self.kind() { + match self.data() { Adt(adt, _) => Some(adt), _ => None, } @@ -2111,7 +2111,7 @@ impl<'tcx> TyS<'tcx> { /// Iterates over tuple fields. /// Panics when called on anything but a tuple. pub fn tuple_fields(&self) -> impl DoubleEndedIterator> { - match self.kind() { + match self.data() { Tuple(substs) => substs.iter().map(|field| field.expect_ty()), _ => bug!("tuple_fields called on non-tuple"), } @@ -2122,9 +2122,9 @@ impl<'tcx> TyS<'tcx> { // FIXME: This requires the optimized MIR in the case of generators. #[inline] pub fn variant_range(&self, tcx: TyCtxt<'tcx>) -> Option> { - match self.kind() { - TyKind::Adt(adt, _) => Some(adt.variant_range()), - TyKind::Generator(def_id, substs, _) => { + match self.data() { + TyData::Adt(adt, _) => Some(adt.variant_range()), + TyData::Generator(def_id, substs, _) => { Some(substs.as_generator().variant_range(*def_id, tcx)) } _ => None, @@ -2141,14 +2141,14 @@ impl<'tcx> TyS<'tcx> { tcx: TyCtxt<'tcx>, variant_index: VariantIdx, ) -> Option> { - match self.kind() { - TyKind::Adt(adt, _) if adt.variants.is_empty() => { + match self.data() { + TyData::Adt(adt, _) if adt.variants.is_empty() => { bug!("discriminant_for_variant called on zero variant enum"); } - TyKind::Adt(adt, _) if adt.is_enum() => { + TyData::Adt(adt, _) if adt.is_enum() => { Some(adt.discriminant_for_variant(tcx, variant_index)) } - TyKind::Generator(def_id, substs, _) => { + TyData::Generator(def_id, substs, _) => { Some(substs.as_generator().discriminant_for_variant(*def_id, tcx, variant_index)) } _ => None, @@ -2157,7 +2157,7 @@ impl<'tcx> TyS<'tcx> { /// Returns the type of the discriminant of this type. pub fn discriminant_ty(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { - match self.kind() { + match self.data() { ty::Adt(adt, _) if adt.is_enum() => adt.repr.discr_type().to_ty(tcx), ty::Generator(_, substs, _) => substs.as_generator().discr_ty(tcx), _ => { @@ -2180,7 +2180,7 @@ impl<'tcx> TyS<'tcx> { /// inferred. Once upvar inference (in `src/librustc_typeck/check/upvar.rs`) /// is complete, that type variable will be unified. pub fn to_opt_closure_kind(&self) -> Option { - match self.kind() { + match self.data() { Int(int_ty) => match int_ty { ast::IntTy::I8 => Some(ty::ClosureKind::Fn), ast::IntTy::I16 => Some(ty::ClosureKind::FnMut), @@ -2209,7 +2209,7 @@ impl<'tcx> TyS<'tcx> { /// can be called, but that doesn't mean it shouldn't typecheck. This is why /// this method doesn't return `Option`. pub fn is_trivially_sized(&self, tcx: TyCtxt<'tcx>) -> bool { - match self.kind() { + match self.data() { ty::Infer(ty::IntVar(_) | ty::FloatVar(_)) | ty::Uint(_) | ty::Int(_) diff --git a/compiler/rustc_middle/src/ty/subst.rs b/compiler/rustc_middle/src/ty/subst.rs index 1bd3bcb6a4d6d..2f819db20f358 100644 --- a/compiler/rustc_middle/src/ty/subst.rs +++ b/compiler/rustc_middle/src/ty/subst.rs @@ -486,7 +486,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> { return t; } - match *t.kind() { + match *t.data() { ty::Param(p) => self.ty_for_param(p, t), _ => t.super_fold_with(self), } diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index d8ea2f67393b2..671ffbe81c9f6 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -7,7 +7,7 @@ use crate::ty::fold::TypeFolder; use crate::ty::layout::IntegerExt; use crate::ty::query::TyCtxtAt; use crate::ty::subst::{GenericArgKind, InternalSubsts, Subst, SubstsRef}; -use crate::ty::TyKind::*; +use crate::ty::TyData::*; use crate::ty::{self, DefIdTree, GenericParamDefKind, List, Ty, TyCtxt, TypeFoldable}; use rustc_apfloat::Float as _; use rustc_ast as ast; @@ -33,7 +33,7 @@ pub struct Discr<'tcx> { impl<'tcx> fmt::Display for Discr<'tcx> { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { - match *self.ty.kind() { + match *self.ty.data() { ty::Int(ity) => { let size = ty::tls::with(|tcx| Integer::from_attr(&tcx, SignedInt(ity)).size()); let x = self.val; @@ -59,7 +59,7 @@ fn unsigned_max(size: Size) -> u128 { } fn int_size_and_signed<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> (Size, bool) { - let (int, signed) = match *ty.kind() { + let (int, signed) = match *ty.data() { Int(ity) => (Integer::from_attr(&tcx, SignedInt(ity)), true), Uint(uty) => (Integer::from_attr(&tcx, UnsignedInt(uty)), false), _ => bug!("non integer discriminant"), @@ -172,10 +172,10 @@ impl<'tcx> TyCtxt<'tcx> { } pub fn has_error_field(self, ty: Ty<'tcx>) -> bool { - if let ty::Adt(def, substs) = *ty.kind() { + if let ty::Adt(def, substs) = *ty.data() { for field in def.all_fields() { let field_ty = field.ty(self, substs); - if let Error(_) = field_ty.kind() { + if let Error(_) = field_ty.data() { return true; } } @@ -223,7 +223,7 @@ impl<'tcx> TyCtxt<'tcx> { normalize: impl Fn(Ty<'tcx>) -> Ty<'tcx>, ) -> Ty<'tcx> { loop { - match *ty.kind() { + match *ty.data() { ty::Adt(def, substs) => { if !def.is_struct() { break; @@ -296,7 +296,7 @@ impl<'tcx> TyCtxt<'tcx> { ) -> (Ty<'tcx>, Ty<'tcx>) { let (mut a, mut b) = (source, target); loop { - match (&a.kind(), &b.kind()) { + match (&a.data(), &b.data()) { (&Adt(a_def, a_substs), &Adt(b_def, b_substs)) if a_def == b_def && a_def.is_struct() => { @@ -399,12 +399,12 @@ impl<'tcx> TyCtxt<'tcx> { // , and then look up which of the impl substs refer to // parameters marked as pure. - let impl_substs = match *self.type_of(impl_def_id).kind() { + let impl_substs = match *self.type_of(impl_def_id).data() { ty::Adt(def_, substs) if def_ == def => substs, _ => bug!(), }; - let item_substs = match *self.type_of(def.did).kind() { + let item_substs = match *self.type_of(def.did).data() { ty::Adt(def_, substs) if def_ == def => substs, _ => bug!(), }; @@ -417,7 +417,7 @@ impl<'tcx> TyCtxt<'tcx> { GenericArgKind::Lifetime(&ty::RegionKind::ReEarlyBound(ref ebr)) => { !impl_generics.region_param(ebr, self).pure_wrt_drop } - GenericArgKind::Type(&ty::TyS { kind: ty::Param(ref pt), .. }) => { + GenericArgKind::Type(&ty::TyS { data: ty::Param(ref pt), .. }) => { !impl_generics.type_param(pt, self).pure_wrt_drop } GenericArgKind::Const(&ty::Const { @@ -624,7 +624,7 @@ impl<'tcx> TypeFolder<'tcx> for OpaqueTypeExpander<'tcx> { } fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { - if let ty::Opaque(def_id, substs) = t.kind { + if let ty::Opaque(def_id, substs) = t.data { self.expand_opaque_ty(def_id, substs).unwrap_or(t) } else if t.has_opaque_types() { t.super_fold_with(self) @@ -638,7 +638,7 @@ impl<'tcx> ty::TyS<'tcx> { /// Returns the maximum value for the given numeric type (including `char`s) /// or returns `None` if the type is not numeric. pub fn numeric_max_val(&'tcx self, tcx: TyCtxt<'tcx>) -> Option<&'tcx ty::Const<'tcx>> { - let val = match self.kind() { + let val = match self.data() { ty::Int(_) | ty::Uint(_) => { let (size, signed) = int_size_and_signed(tcx, self); let val = if signed { signed_max(size) as u128 } else { unsigned_max(size) }; @@ -657,7 +657,7 @@ impl<'tcx> ty::TyS<'tcx> { /// Returns the minimum value for the given numeric type (including `char`s) /// or returns `None` if the type is not numeric. pub fn numeric_min_val(&'tcx self, tcx: TyCtxt<'tcx>) -> Option<&'tcx ty::Const<'tcx>> { - let val = match self.kind() { + let val = match self.data() { ty::Int(_) | ty::Uint(_) => { let (size, signed) = int_size_and_signed(tcx, self); let val = if signed { truncate(signed_min(size) as u128, size) } else { 0 }; @@ -715,7 +715,7 @@ impl<'tcx> ty::TyS<'tcx> { /// Returning true means the type is known to be `Freeze`. Returning /// `false` means nothing -- could be `Freeze`, might not be. fn is_trivially_freeze(&self) -> bool { - match self.kind() { + match self.data() { ty::Int(_) | ty::Uint(_) | ty::Float(_) @@ -791,7 +791,7 @@ impl<'tcx> ty::TyS<'tcx> { /// down, you will need to use a type visitor. #[inline] pub fn is_structural_eq_shallow(&'tcx self, tcx: TyCtxt<'tcx>) -> bool { - match self.kind() { + match self.data() { // Look for an impl of both `PartialStructuralEq` and `StructuralEq`. Adt(..) => tcx.has_structural_eq_impls(self), @@ -826,7 +826,7 @@ impl<'tcx> ty::TyS<'tcx> { } pub fn same_type(a: Ty<'tcx>, b: Ty<'tcx>) -> bool { - match (&a.kind(), &b.kind()) { + match (&a.data(), &b.data()) { (&Adt(did_a, substs_a), &Adt(did_b, substs_b)) => { if did_a != did_b { return false; @@ -858,7 +858,7 @@ impl<'tcx> ty::TyS<'tcx> { representable_cache: &mut FxHashMap, Representability>, ty: Ty<'tcx>, ) -> Representability { - match ty.kind() { + match ty.data() { Tuple(..) => { // Find non representable fold_repr(ty.tuple_fields().map(|ty| { @@ -907,7 +907,7 @@ impl<'tcx> ty::TyS<'tcx> { } fn same_struct_or_enum<'tcx>(ty: Ty<'tcx>, def: &'tcx ty::AdtDef) -> bool { - match *ty.kind() { + match *ty.data() { Adt(ty_def, _) => ty_def == def, _ => false, } @@ -945,7 +945,7 @@ impl<'tcx> ty::TyS<'tcx> { representable_cache: &mut FxHashMap, Representability>, ty: Ty<'tcx>, ) -> Representability { - match ty.kind() { + match ty.data() { Adt(def, _) => { { // Iterate through stack of previously seen types. @@ -1022,7 +1022,7 @@ impl<'tcx> ty::TyS<'tcx> { /// - `&'a *const &'b u8 -> *const &'b u8` pub fn peel_refs(&'tcx self) -> Ty<'tcx> { let mut ty = self; - while let Ref(_, inner_ty, _) = ty.kind() { + while let Ref(_, inner_ty, _) = ty.data() { ty = inner_ty; } ty @@ -1068,7 +1068,7 @@ impl<'tcx> ExplicitSelf<'tcx> { { use self::ExplicitSelf::*; - match *self_arg_ty.kind() { + match *self_arg_ty.data() { _ if is_self_ty(self_arg_ty) => ByValue, ty::Ref(region, ty, mutbl) if is_self_ty(ty) => ByReference(region, mutbl), ty::RawPtr(ty::TypeAndMut { ty, mutbl }) if is_self_ty(ty) => ByRawPointer(mutbl), @@ -1085,7 +1085,7 @@ pub fn needs_drop_components( ty: Ty<'tcx>, target_layout: &TargetDataLayout, ) -> Result; 2]>, AlwaysRequiresDrop> { - match ty.kind() { + match ty.data() { ty::Infer(ty::FreshIntTy(_)) | ty::Infer(ty::FreshFloatTy(_)) | ty::Bool diff --git a/compiler/rustc_middle/src/ty/walk.rs b/compiler/rustc_middle/src/ty/walk.rs index 357a0dd65c414..f7865840e36cd 100644 --- a/compiler/rustc_middle/src/ty/walk.rs +++ b/compiler/rustc_middle/src/ty/walk.rs @@ -120,7 +120,7 @@ impl<'tcx> super::TyS<'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.data() { ty::Bool | ty::Char | ty::Int(_) diff --git a/compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs b/compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs index dca0d6d7790d4..f33433c49b659 100644 --- a/compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs +++ b/compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs @@ -296,7 +296,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let ty = Place::ty_from(used_place.local, used_place.projection, self.body, self.infcx.tcx) .ty; - let needs_note = match ty.kind() { + let needs_note = match ty.data() { ty::Closure(id, _) => { let tables = self.infcx.tcx.typeck(id.expect_local()); let hir_id = self.infcx.tcx.hir().local_def_id_to_hir_id(id.expect_local()); @@ -311,7 +311,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let ty = place.ty(self.body, self.infcx.tcx).ty; if is_loop_move { - if let ty::Ref(_, _, hir::Mutability::Mut) = ty.kind() { + if let ty::Ref(_, _, hir::Mutability::Mut) = ty.data() { // We have a `&mut` ref, we need to reborrow on each iteration (#62112). err.span_suggestion_verbose( span.shrink_to_lo(), @@ -334,7 +334,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { Some(ref name) => format!("`{}`", name), None => "value".to_owned(), }; - if let ty::Param(param_ty) = ty.kind() { + if let ty::Param(param_ty) = ty.data() { let tcx = self.infcx.tcx; let generics = tcx.generics_of(self.mir_def_id()); let param = generics.type_param(¶m_ty, tcx); @@ -1022,7 +1022,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { .tcx .typeck(self.mir_def_id()) .node_type(fn_hir_id) - .kind() + .data() { ty::Closure(..) => "enclosing closure", ty::Generator(..) => "enclosing generator", @@ -1650,7 +1650,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { }, ProjectionElem::Field(..) | ProjectionElem::Downcast(..) => { let base_ty = Place::ty_from(place.local, proj_base, self.body, tcx).ty; - match base_ty.kind() { + match base_ty.data() { ty::Adt(def, _) if def.has_dtor(tcx) => { // Report the outermost adt with a destructor match base_access { @@ -1714,7 +1714,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { None } else { let ty = self.infcx.tcx.type_of(self.mir_def_id()); - match ty.kind() { + match ty.data() { ty::FnDef(_, _) | ty::FnPtr(_) => self.annotate_fn_sig( self.mir_def_id().to_def_id(), self.infcx.tcx.fn_sig(self.mir_def_id()), @@ -1949,13 +1949,13 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // 3. The return type is not a reference. In this case, we don't highlight // anything. let return_ty = sig.output(); - match return_ty.skip_binder().kind() { + match return_ty.skip_binder().data() { ty::Ref(return_region, _, _) if return_region.has_name() && !is_closure => { // This is case 1 from above, return type is a named reference so we need to // search for relevant arguments. let mut arguments = Vec::new(); for (index, argument) in sig.inputs().skip_binder().iter().enumerate() { - if let ty::Ref(argument_region, _, _) = argument.kind() { + if let ty::Ref(argument_region, _, _) = argument.data() { if argument_region == return_region { // Need to use the `rustc_middle::ty` types to compare against the // `return_region`. Then use the `rustc_hir` type to get only @@ -2001,9 +2001,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // Closure arguments are wrapped in a tuple, so we need to get the first // from that. - if let ty::Tuple(elems) = argument_ty.kind() { + if let ty::Tuple(elems) = argument_ty.data() { let argument_ty = elems.first()?.expect_ty(); - if let ty::Ref(_, _, _) = argument_ty.kind() { + if let ty::Ref(_, _, _) = argument_ty.data() { return Some(AnnotatedBorrowFnSignature::Closure { argument_ty, argument_span, @@ -2023,7 +2023,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let return_ty = sig.output().skip_binder(); // We expect the first argument to be a reference. - match argument_ty.kind() { + match argument_ty.data() { ty::Ref(_, _, _) => {} _ => return None, } diff --git a/compiler/rustc_mir/src/borrow_check/diagnostics/explain_borrow.rs b/compiler/rustc_mir/src/borrow_check/diagnostics/explain_borrow.rs index eccb6168229c2..2e48f886a1415 100644 --- a/compiler/rustc_mir/src/borrow_check/diagnostics/explain_borrow.rs +++ b/compiler/rustc_mir/src/borrow_check/diagnostics/explain_borrow.rs @@ -102,7 +102,7 @@ impl BorrowExplanation { should_note_order, } => { let local_decl = &body.local_decls[dropped_local]; - let (dtor_desc, type_desc) = match local_decl.ty.kind() { + let (dtor_desc, type_desc) = match local_decl.ty.data() { // If type is an ADT that implements Drop, then // simplify output by reporting just the ADT name. ty::Adt(adt, _substs) if adt.has_dtor(tcx) && !adt.is_box() => { @@ -626,7 +626,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { if from == target { debug!("was_captured_by_trait_object: ty={:?}", ty); // Check the type for a trait object. - return match ty.kind() { + return match ty.data() { // `&dyn Trait` ty::Ref(_, ty, _) if ty.is_trait() => true, // `Box` diff --git a/compiler/rustc_mir/src/borrow_check/diagnostics/mod.rs b/compiler/rustc_mir/src/borrow_check/diagnostics/mod.rs index 4256f6e39d5e8..b628bc6d2f3ef 100644 --- a/compiler/rustc_mir/src/borrow_check/diagnostics/mod.rs +++ b/compiler/rustc_mir/src/borrow_check/diagnostics/mod.rs @@ -86,7 +86,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { .. } = &terminator.kind { - if let ty::FnDef(id, _) = *const_ty.kind() { + if let ty::FnDef(id, _) = *const_ty.data() { debug!("add_moved_or_invoked_closure_note: id={:?}", id); if self.infcx.tcx.parent(id) == self.infcx.tcx.lang_items().fn_once_trait() { let closure = match args.first() { @@ -99,7 +99,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { }; debug!("add_moved_or_invoked_closure_note: closure={:?}", closure); - if let ty::Closure(did, _) = self.body.local_decls[closure].ty.kind() { + if let ty::Closure(did, _) = self.body.local_decls[closure].ty.data() { let did = did.expect_local(); let hir_id = self.infcx.tcx.hir().local_def_id_to_hir_id(did); @@ -123,7 +123,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // Check if we are just moving a closure after it has been invoked. if let Some(target) = target { - if let ty::Closure(did, _) = self.body.local_decls[target].ty.kind() { + if let ty::Closure(did, _) = self.body.local_decls[target].ty.data() { let did = did.expect_local(); let hir_id = self.infcx.tcx.hir().local_def_id_to_hir_id(did); @@ -365,7 +365,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) } else { - match *ty.kind() { + match *ty.data() { ty::Adt(def, _) => { let variant = if let Some(idx) = variant_index { assert!(def.is_enum()); @@ -496,7 +496,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // We need to add synthesized lifetimes where appropriate. We do // this by hooking into the pretty printer and telling it to label the // lifetimes without names with the value `'0`. - match ty.kind() { + match ty.data() { ty::Ref( ty::RegionKind::ReLateBound(_, br) | ty::RegionKind::RePlaceholder(ty::PlaceholderRegion { name: br, .. }), @@ -516,7 +516,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let mut s = String::new(); let mut printer = ty::print::FmtPrinter::new(self.infcx.tcx, &mut s, Namespace::TypeNS); - let region = match ty.kind() { + let region = match ty.data() { ty::Ref(region, _, _) => { match region { ty::RegionKind::ReLateBound(_, br) @@ -693,7 +693,7 @@ impl BorrowedContentSource<'tcx> { BorrowedContentSource::DerefRawPointer => "a raw pointer".to_string(), BorrowedContentSource::DerefSharedRef => "a shared reference".to_string(), BorrowedContentSource::DerefMutableRef => "a mutable reference".to_string(), - BorrowedContentSource::OverloadedDeref(ty) => match ty.kind() { + BorrowedContentSource::OverloadedDeref(ty) => match ty.data() { ty::Adt(def, _) if tcx.is_diagnostic_item(sym::Rc, def.did) => { "an `Rc`".to_string() } @@ -725,7 +725,7 @@ impl BorrowedContentSource<'tcx> { BorrowedContentSource::DerefMutableRef => { bug!("describe_for_immutable_place: DerefMutableRef isn't immutable") } - BorrowedContentSource::OverloadedDeref(ty) => match ty.kind() { + BorrowedContentSource::OverloadedDeref(ty) => match ty.data() { ty::Adt(def, _) if tcx.is_diagnostic_item(sym::Rc, def.did) => { "an `Rc`".to_string() } @@ -739,7 +739,7 @@ impl BorrowedContentSource<'tcx> { } fn from_call(func: Ty<'tcx>, tcx: TyCtxt<'tcx>) -> Option { - match *func.kind() { + match *func.data() { ty::FnDef(def_id, substs) => { let trait_id = tcx.trait_of_item(def_id)?; diff --git a/compiler/rustc_mir/src/borrow_check/diagnostics/move_errors.rs b/compiler/rustc_mir/src/borrow_check/diagnostics/move_errors.rs index b1cebbd1f381b..139dec714e8a3 100644 --- a/compiler/rustc_mir/src/borrow_check/diagnostics/move_errors.rs +++ b/compiler/rustc_mir/src/borrow_check/diagnostics/move_errors.rs @@ -326,7 +326,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { } debug!("report: ty={:?}", ty); - let mut err = match ty.kind() { + let mut err = match ty.data() { ty::Array(..) | ty::Slice(..) => { self.cannot_move_out_of_interior_noncopy(span, ty, None) } @@ -385,7 +385,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { } }; if let Ok(snippet) = self.infcx.tcx.sess.source_map().span_to_snippet(span) { - let def_id = match *move_place.ty(self.body, self.infcx.tcx).ty.kind() { + let def_id = match *move_place.ty(self.body, self.infcx.tcx).ty.data() { ty::Adt(self_def, _) => self_def.did, ty::Foreign(def_id) | ty::FnDef(def_id, _) diff --git a/compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs b/compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs index e1af6fc07cf8f..e35b14521bb7f 100644 --- a/compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs +++ b/compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs @@ -485,7 +485,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { let def_id = hir.local_def_id(item_id); let tables = self.infcx.tcx.typeck(def_id); if let Some(ty::FnDef(def_id, _)) = - tables.node_type_opt(func.hir_id).as_ref().map(|ty| ty.kind()) + tables.node_type_opt(func.hir_id).as_ref().map(|ty| ty.data()) { let arg = match hir.get_if_local(*def_id) { Some( @@ -558,7 +558,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { } fn mut_borrow_of_mutable_ref(local_decl: &LocalDecl<'_>, local_name: Option) -> bool { - debug!("local_info: {:?}, ty.kind(): {:?}", local_decl.local_info, local_decl.ty.kind()); + debug!("local_info: {:?}, ty.kind(): {:?}", local_decl.local_info, local_decl.ty.data()); match local_decl.local_info.as_deref() { // Check if mutably borrowing a mutable reference. @@ -566,7 +566,7 @@ fn mut_borrow_of_mutable_ref(local_decl: &LocalDecl<'_>, local_name: Option matches!(local_decl.ty.kind(), ty::Ref(_, _, hir::Mutability::Mut)), + )))) => matches!(local_decl.ty.data(), ty::Ref(_, _, hir::Mutability::Mut)), Some(LocalInfo::User(ClearCrossCrate::Set(mir::BindingForm::ImplicitSelf(kind)))) => { // Check if the user variable is a `&mut self` and we can therefore // suggest removing the `&mut`. @@ -579,7 +579,7 @@ fn mut_borrow_of_mutable_ref(local_decl: &LocalDecl<'_>, local_name: Option false, } @@ -690,8 +690,8 @@ fn annotate_struct_field( field: &mir::Field, ) -> Option<(Span, String)> { // Expect our local to be a reference to a struct of some kind. - if let ty::Ref(_, ty, _) = ty.kind() { - if let ty::Adt(def, _) = ty.kind() { + if let ty::Ref(_, ty, _) = ty.data() { + if let ty::Adt(def, _) = ty.data() { let field = def.all_fields().nth(field.index())?; // Use the HIR types to construct the diagnostic message. let hir_id = tcx.hir().local_def_id_to_hir_id(field.did.as_local()?); diff --git a/compiler/rustc_mir/src/borrow_check/diagnostics/region_errors.rs b/compiler/rustc_mir/src/borrow_check/diagnostics/region_errors.rs index e22dab0151703..61d14a1c59835 100644 --- a/compiler/rustc_mir/src/borrow_check/diagnostics/region_errors.rs +++ b/compiler/rustc_mir/src/borrow_check/diagnostics/region_errors.rs @@ -365,13 +365,13 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { .struct_span_err(*span, "captured variable cannot escape `FnMut` closure body"); let mut output_ty = self.regioncx.universal_regions().unnormalized_output_ty; - if let ty::Opaque(def_id, _) = *output_ty.kind() { + if let ty::Opaque(def_id, _) = *output_ty.data() { output_ty = self.infcx.tcx.type_of(def_id) }; debug!("report_fnmut_error: output_ty={:?}", output_ty); - let message = match output_ty.kind() { + let message = match output_ty.data() { ty::Closure(_, _) => { "returns a closure that contains a reference to a captured variable, which then \ escapes the closure body" @@ -579,7 +579,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { .is_suitable_region(f) .map(|r| r.def_id) .and_then(|id| self.infcx.tcx.return_type_impl_trait(id)) - .map(|(ty, _)| ty.kind()) + .map(|(ty, _)| ty.data()) { // Check whether or not the impl trait return type is intended to capture // data with the static lifetime. diff --git a/compiler/rustc_mir/src/borrow_check/diagnostics/region_name.rs b/compiler/rustc_mir/src/borrow_check/diagnostics/region_name.rs index 2e5a231fef057..9ebfc012d56db 100644 --- a/compiler/rustc_mir/src/borrow_check/diagnostics/region_name.rs +++ b/compiler/rustc_mir/src/borrow_check/diagnostics/region_name.rs @@ -447,7 +447,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { let search_stack: &mut Vec<(Ty<'tcx>, &hir::Ty<'_>)> = &mut vec![(ty, hir_ty)]; while let Some((ty, hir_ty)) = search_stack.pop() { - match (&ty.kind(), &hir_ty.kind) { + match (&ty.data(), &hir_ty.kind) { // Check if the `ty` is `&'X ..` where `'X` // is the region we are looking for -- if so, and we have a `&T` // on the RHS, then we want to highlight the `&` like so: diff --git a/compiler/rustc_mir/src/borrow_check/mod.rs b/compiler/rustc_mir/src/borrow_check/mod.rs index 9b34db1de403f..b49f73afcf27f 100644 --- a/compiler/rustc_mir/src/borrow_check/mod.rs +++ b/compiler/rustc_mir/src/borrow_check/mod.rs @@ -1754,7 +1754,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { { let place_ty = Place::ty_from(place_span.0.local, base_proj, self.body(), self.infcx.tcx); - if let ty::Array(..) = place_ty.ty.kind() { + if let ty::Array(..) = place_ty.ty.data() { let array_place = PlaceRef { local: place_span.0.local, projection: base_proj }; self.check_if_subslice_element_is_moved( location, @@ -1872,7 +1872,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // be already initialized let tcx = self.infcx.tcx; let base_ty = Place::ty_from(place.local, proj_base, self.body(), tcx).ty; - match base_ty.kind() { + match base_ty.data() { ty::Adt(def, _) if def.has_dtor(tcx) => { self.check_if_path_or_subpath_is_moved( location, InitializationRequiringAction::Assignment, @@ -1975,7 +1975,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // of the union - we should error in that case. let tcx = this.infcx.tcx; if let ty::Adt(def, _) = - Place::ty_from(base.local, base.projection, this.body(), tcx).ty.kind() + Place::ty_from(base.local, base.projection, this.body(), tcx).ty.data() { if def.is_union() { if this.move_data.path_map[mpi].iter().any(|moi| { @@ -2202,7 +2202,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { Place::ty_from(place.local, proj_base, self.body(), self.infcx.tcx).ty; // Check the kind of deref to decide - match base_ty.kind() { + match base_ty.data() { ty::Ref(_, _, mutbl) => { match mutbl { // Shared borrowed data is never mutable diff --git a/compiler/rustc_mir/src/borrow_check/place_ext.rs b/compiler/rustc_mir/src/borrow_check/place_ext.rs index 52fac3e53ee65..77864d4e194bd 100644 --- a/compiler/rustc_mir/src/borrow_check/place_ext.rs +++ b/compiler/rustc_mir/src/borrow_check/place_ext.rs @@ -49,7 +49,7 @@ impl<'tcx> PlaceExt<'tcx> for Place<'tcx> { if elem == ProjectionElem::Deref { let ty = Place::ty_from(self.local, proj_base, body, tcx).ty; - match ty.kind() { + match ty.data() { ty::Ref(_, _, hir::Mutability::Not) if i == 0 => { // For references to thread-local statics, we do need // to track the borrow. diff --git a/compiler/rustc_mir/src/borrow_check/places_conflict.rs b/compiler/rustc_mir/src/borrow_check/places_conflict.rs index 02c7b7dc200c3..dcf031ab339ea 100644 --- a/compiler/rustc_mir/src/borrow_check/places_conflict.rs +++ b/compiler/rustc_mir/src/borrow_check/places_conflict.rs @@ -210,7 +210,7 @@ fn place_components_conflict<'tcx>( let proj_base = &borrow_place.projection[..access_place.projection.len() + i]; let base_ty = Place::ty_from(borrow_local, proj_base, body, tcx).ty; - match (elem, &base_ty.kind(), access) { + match (elem, &base_ty.data(), access) { (_, _, Shallow(Some(ArtificialField::ArrayLength))) | (_, _, Shallow(Some(ArtificialField::ShallowBorrow))) => { // The array length is like additional fields on the @@ -330,7 +330,7 @@ fn place_projection_conflict<'tcx>( Overlap::EqualOrDisjoint } else { let ty = Place::ty_from(pi1_local, pi1_proj_base, body, tcx).ty; - match ty.kind() { + match ty.data() { ty::Adt(def, _) if def.is_union() => { // Different fields of a union, we are basically stuck. debug!("place_element_conflict: STUCK-UNION"); diff --git a/compiler/rustc_mir/src/borrow_check/prefixes.rs b/compiler/rustc_mir/src/borrow_check/prefixes.rs index 6c5d42296f72b..8842b6c5c4a0b 100644 --- a/compiler/rustc_mir/src/borrow_check/prefixes.rs +++ b/compiler/rustc_mir/src/borrow_check/prefixes.rs @@ -120,7 +120,7 @@ impl<'cx, 'tcx> Iterator for Prefixes<'cx, 'tcx> { // reference. let ty = Place::ty_from(cursor.local, proj_base, self.body, self.tcx).ty; - match ty.kind() { + match ty.data() { ty::RawPtr(_) | ty::Ref(_ /*rgn*/, _ /*ty*/, hir::Mutability::Not) => { // don't continue traversing over derefs of raw pointers or shared // borrows. diff --git a/compiler/rustc_mir/src/borrow_check/type_check/mod.rs b/compiler/rustc_mir/src/borrow_check/type_check/mod.rs index f8a8801595a41..cc5782b9f0683 100644 --- a/compiler/rustc_mir/src/borrow_check/type_check/mod.rs +++ b/compiler/rustc_mir/src/borrow_check/type_check/mod.rs @@ -380,7 +380,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> { } } - if let ty::FnDef(def_id, substs) = *constant.literal.ty.kind() { + if let ty::FnDef(def_id, substs) = *constant.literal.ty.data() { let instantiated_predicates = tcx.predicates_of(def_id).instantiate(tcx, substs); self.cx.normalize_and_prove_instantiated_predicates( instantiated_predicates, @@ -406,7 +406,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> { // If we have a binding of the form `let ref x: T = ..` // 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() { + if let ty::Ref(_, rty, _) = local_decl.ty.data() { rty } else { bug!("{:?} with ref binding has wrong type {}", local, local_decl.ty); @@ -633,7 +633,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { })) } ProjectionElem::Subslice { from, to, from_end } => { - PlaceTy::from_ty(match base_ty.kind() { + PlaceTy::from_ty(match base_ty.data() { ty::Array(inner, _) => { assert!(!from_end, "array subslices should not use from_end"); tcx.mk_array(inner, to - from) @@ -645,7 +645,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { _ => span_mirbug_and_err!(self, place, "slice of non-array {:?}", base_ty), }) } - ProjectionElem::Downcast(maybe_name, index) => match base_ty.kind() { + ProjectionElem::Downcast(maybe_name, index) => match base_ty.data() { ty::Adt(adt_def, _substs) if adt_def.is_enum() => { if index.as_usize() >= adt_def.variants.len() { PlaceTy::from_ty(span_mirbug_and_err!( @@ -725,7 +725,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { let tcx = self.tcx(); let (variant, substs) = match base_ty { - PlaceTy { ty, variant_index: Some(variant_index) } => match *ty.kind() { + PlaceTy { ty, variant_index: Some(variant_index) } => match *ty.data() { ty::Adt(adt_def, substs) => (&adt_def.variants[variant_index], substs), ty::Generator(def_id, substs, _) => { let mut variants = substs.as_generator().state_tys(def_id, tcx); @@ -744,7 +744,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { } _ => bug!("can't have downcast of non-adt non-generator type"), }, - PlaceTy { ty, variant_index: None } => match *ty.kind() { + PlaceTy { ty, variant_index: None } => match *ty.data() { ty::Adt(adt_def, substs) if !adt_def.is_enum() => { (&adt_def.variants[VariantIdx::new(0)], substs) } @@ -1124,7 +1124,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { category: ConstraintCategory, ) -> Fallible<()> { if let Err(terr) = self.sub_types(sub, sup, locations, category) { - if let ty::Opaque(..) = sup.kind() { + if let ty::Opaque(..) = sup.data() { // When you have `let x: impl Foo = ...` in a closure, // the resulting inferend values are stored with the // def-id of the base function. @@ -1267,7 +1267,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { for (&opaque_def_id, opaque_decl) in &opaque_type_map { let resolved_ty = infcx.resolve_vars_if_possible(&opaque_decl.concrete_ty); - let concrete_is_opaque = if let ty::Opaque(def_id, _) = resolved_ty.kind() { + let concrete_is_opaque = if let ty::Opaque(def_id, _) = resolved_ty.data() { *def_id == opaque_def_id } else { false @@ -1470,7 +1470,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } StatementKind::SetDiscriminant { ref place, variant_index } => { let place_type = place.ty(body, tcx).ty; - let adt = match place_type.kind() { + let adt = match place_type.data() { ty::Adt(adt, _) if adt.is_enum() => adt, _ => { span_bug!( @@ -1586,7 +1586,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { TerminatorKind::Call { ref func, ref args, ref destination, from_hir_call, .. } => { let func_ty = func.ty(body, tcx); debug!("check_terminator: call, func_ty={:?}", func_ty); - let sig = match func_ty.kind() { + let sig = match func_ty.data() { ty::FnDef(..) | ty::FnPtr(_) => func_ty.fn_sig(tcx), _ => { span_mirbug!(self, term, "call to non-function {:?}", func_ty); @@ -2073,7 +2073,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } CastKind::Pointer(PointerCast::ClosureFnPointer(unsafety)) => { - let sig = match op.ty(body, tcx).kind() { + let sig = match op.ty(body, tcx).data() { ty::Closure(_, substs) => substs.as_closure().sig(), _ => bug!(), }; @@ -2141,7 +2141,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } CastKind::Pointer(PointerCast::MutToConstPointer) => { - let ty_from = match op.ty(body, tcx).kind() { + let ty_from = match op.ty(body, tcx).data() { ty::RawPtr(ty::TypeAndMut { ty: ty_from, mutbl: hir::Mutability::Mut, @@ -2156,7 +2156,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { return; } }; - let ty_to = match ty.kind() { + let ty_to = match ty.data() { ty::RawPtr(ty::TypeAndMut { ty: ty_to, mutbl: hir::Mutability::Not, @@ -2191,11 +2191,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { CastKind::Pointer(PointerCast::ArrayToPointer) => { let ty_from = op.ty(body, tcx); - let opt_ty_elem = match ty_from.kind() { + let opt_ty_elem = match ty_from.data() { ty::RawPtr(ty::TypeAndMut { mutbl: hir::Mutability::Not, ty: array_ty, - }) => match array_ty.kind() { + }) => match array_ty.data() { ty::Array(ty_elem, _) => Some(ty_elem), _ => None, }, @@ -2215,7 +2215,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } }; - let ty_to = match ty.kind() { + let ty_to = match ty.data() { ty::RawPtr(ty::TypeAndMut { mutbl: hir::Mutability::Not, ty: ty_to, @@ -2281,7 +2281,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { right, ) => { let ty_left = left.ty(body, tcx); - match ty_left.kind() { + match ty_left.data() { // Types with regions are comparable if they have a common super-type. ty::RawPtr(_) | ty::FnPtr(_) => { let ty_right = right.ty(body, tcx); @@ -2492,7 +2492,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { let base_ty = Place::ty_from(borrowed_place.local, proj_base, body, tcx).ty; debug!("add_reborrow_constraint - base_ty = {:?}", base_ty); - match base_ty.kind() { + match base_ty.data() { ty::Ref(ref_region, _, mutbl) => { constraints.outlives_constraints.push(OutlivesConstraint { sup: ref_region.to_region_vid(), diff --git a/compiler/rustc_mir/src/borrow_check/universal_regions.rs b/compiler/rustc_mir/src/borrow_check/universal_regions.rs index 4742113b1a552..685b031d15f9c 100644 --- a/compiler/rustc_mir/src/borrow_check/universal_regions.rs +++ b/compiler/rustc_mir/src/borrow_check/universal_regions.rs @@ -524,7 +524,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.data() { ty::Closure(def_id, substs) => DefiningTy::Closure(def_id, substs), ty::Generator(def_id, substs, movability) => { DefiningTy::Generator(def_id, substs, movability) @@ -603,7 +603,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { // flattens this tuple. let (&output, tuplized_inputs) = inputs_and_output.split_last().unwrap(); assert_eq!(tuplized_inputs.len(), 1, "multiple closure inputs"); - let inputs = match tuplized_inputs[0].kind() { + let inputs = match tuplized_inputs[0].data() { ty::Tuple(inputs) => inputs, _ => bug!("closure inputs not a tuple: {:?}", tuplized_inputs[0]), }; diff --git a/compiler/rustc_mir/src/const_eval/eval_queries.rs b/compiler/rustc_mir/src/const_eval/eval_queries.rs index 57aa216850aab..81f81c40afbab 100644 --- a/compiler/rustc_mir/src/const_eval/eval_queries.rs +++ b/compiler/rustc_mir/src/const_eval/eval_queries.rs @@ -119,8 +119,8 @@ pub(super) fn op_to_const<'tcx>( // `Undef` situation. let try_as_immediate = match op.layout.abi { Abi::Scalar(..) => true, - Abi::ScalarPair(..) => match op.layout.ty.kind() { - ty::Ref(_, inner, _) => match *inner.kind() { + Abi::ScalarPair(..) => match op.layout.ty.data() { + ty::Ref(_, inner, _) => match *inner.data() { ty::Slice(elem) => elem == ecx.tcx.types.u8, ty::Str => true, _ => false, @@ -226,7 +226,7 @@ pub fn eval_to_const_value_raw_provider<'tcx>( // Catch such calls and evaluate them instead of trying to load a constant's MIR. if let ty::InstanceDef::Intrinsic(def_id) = key.value.instance.def { let ty = key.value.instance.ty(tcx, key.param_env); - let substs = match ty.kind() { + let substs = match ty.data() { ty::FnDef(_, substs) => substs, _ => bug!("intrinsic with type {:?}", ty), }; diff --git a/compiler/rustc_mir/src/const_eval/mod.rs b/compiler/rustc_mir/src/const_eval/mod.rs index 978d2fe000468..82ec500a23f79 100644 --- a/compiler/rustc_mir/src/const_eval/mod.rs +++ b/compiler/rustc_mir/src/const_eval/mod.rs @@ -47,7 +47,7 @@ pub(crate) fn destructure_const<'tcx>( let op = ecx.const_to_op(val, None).unwrap(); // We go to `usize` as we cannot allocate anything bigger anyway. - let (field_count, variant, down) = match val.ty.kind() { + let (field_count, variant, down) = match val.ty.data() { ty::Array(_, len) => (usize::try_from(len.eval_usize(tcx, param_env)).unwrap(), None, op), ty::Adt(def, _) if def.variants.is_empty() => { return mir::DestructuredConst { variant: None, fields: tcx.arena.alloc_slice(&[]) }; @@ -93,7 +93,7 @@ pub(crate) fn deref_const<'tcx>( MemPlaceMeta::None => mplace.layout.ty, MemPlaceMeta::Poison => bug!("poison metadata in `deref_const`: {:#?}", mplace), // In case of unsized types, figure out the real type behind. - MemPlaceMeta::Meta(scalar) => match mplace.layout.ty.kind() { + MemPlaceMeta::Meta(scalar) => match mplace.layout.ty.data() { ty::Str => bug!("there's no sized equivalent of a `str`"), ty::Slice(elem_ty) => tcx.mk_array(elem_ty, scalar.to_machine_usize(&tcx).unwrap()), _ => bug!( diff --git a/compiler/rustc_mir/src/dataflow/drop_flag_effects.rs b/compiler/rustc_mir/src/dataflow/drop_flag_effects.rs index d1d507e54ef5f..a20cdffd8cd78 100644 --- a/compiler/rustc_mir/src/dataflow/drop_flag_effects.rs +++ b/compiler/rustc_mir/src/dataflow/drop_flag_effects.rs @@ -53,7 +53,7 @@ fn place_contents_drop_state_cannot_differ<'tcx>( place: mir::Place<'tcx>, ) -> bool { let ty = place.ty(body, tcx).ty; - match ty.kind() { + match ty.data() { ty::Array(..) => { debug!( "place_contents_drop_state_cannot_differ place: {:?} ty: {:?} => false", diff --git a/compiler/rustc_mir/src/dataflow/impls/mod.rs b/compiler/rustc_mir/src/dataflow/impls/mod.rs index 185f0edfeb6bc..2a789fda644de 100644 --- a/compiler/rustc_mir/src/dataflow/impls/mod.rs +++ b/compiler/rustc_mir/src/dataflow/impls/mod.rs @@ -700,7 +700,7 @@ fn switch_on_enum_discriminant( Some(mir::StatementKind::Assign(box (lhs, mir::Rvalue::Discriminant(discriminated)))) if *lhs == switch_on => { - match &discriminated.ty(body, tcx).ty.kind() { + match &discriminated.ty(body, tcx).ty.data() { ty::Adt(def, _) => Some((*discriminated, def)), // `Rvalue::Discriminant` is also used to get the active yield point for a diff --git a/compiler/rustc_mir/src/dataflow/move_paths/builder.rs b/compiler/rustc_mir/src/dataflow/move_paths/builder.rs index ab7fadac91e39..c7f42f4166dcb 100644 --- a/compiler/rustc_mir/src/dataflow/move_paths/builder.rs +++ b/compiler/rustc_mir/src/dataflow/move_paths/builder.rs @@ -109,7 +109,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> { let body = self.builder.body; let tcx = self.builder.tcx; let place_ty = Place::ty_from(place.local, proj_base, body, tcx).ty; - match place_ty.kind() { + match place_ty.data() { ty::Ref(..) | ty::RawPtr(..) => { let proj = &place.projection[..i + 1]; return Err(MoveError::cannot_move_out_of( @@ -480,7 +480,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> { } }; let base_ty = base_place.ty(self.builder.body, self.builder.tcx).ty; - let len: u64 = match base_ty.kind() { + let len: u64 = match base_ty.data() { ty::Array(_, size) => size.eval_usize(self.builder.tcx, self.builder.param_env), _ => bug!("from_end: false slice pattern of non-array type"), }; @@ -522,7 +522,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> { if let ty::Adt(def, _) = Place::ty_from(place.local, proj_base, self.builder.body, self.builder.tcx) .ty - .kind() + .data() { if def.is_union() { place = PlaceRef { local: place.local, projection: proj_base } diff --git a/compiler/rustc_mir/src/interpret/cast.rs b/compiler/rustc_mir/src/interpret/cast.rs index 0e16b0caefafa..fc769f4ecf310 100644 --- a/compiler/rustc_mir/src/interpret/cast.rs +++ b/compiler/rustc_mir/src/interpret/cast.rs @@ -47,7 +47,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { Pointer(PointerCast::ReifyFnPointer) => { // The src operand does not matter, just its type - match *src.layout.ty.kind() { + match *src.layout.ty.data() { ty::FnDef(def_id, substs) => { // All reifications must be monomorphic, bail out otherwise. ensure_monomorphic_enough(*self.tcx, src.layout.ty)?; @@ -76,7 +76,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { Pointer(PointerCast::UnsafeFnPointer) => { let src = self.read_immediate(src)?; - match cast_ty.kind() { + match cast_ty.data() { ty::FnPtr(_) => { // No change to value self.write_immediate(*src, dest)?; @@ -87,7 +87,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { Pointer(PointerCast::ClosureFnPointer(_)) => { // The src operand does not matter, just its type - match *src.layout.ty.kind() { + match *src.layout.ty.data() { ty::Closure(def_id, substs) => { // All reifications must be monomorphic, bail out otherwise. ensure_monomorphic_enough(*self.tcx, src.layout.ty)?; @@ -113,10 +113,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { src: ImmTy<'tcx, M::PointerTag>, cast_ty: Ty<'tcx>, ) -> InterpResult<'tcx, Immediate> { - use rustc_middle::ty::TyKind::*; + use rustc_middle::ty::TyData::*; trace!("Casting {:?}: {:?} to {:?}", *src, src.layout.ty, cast_ty); - match src.layout.ty.kind() { + match src.layout.ty.data() { // Floating point Float(FloatTy::F32) => { return Ok(self.cast_from_float(src.to_scalar()?.to_f32()?, cast_ty).into()); @@ -195,10 +195,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let signed = src_layout.abi.is_signed(); // Also asserts that abi is `Scalar`. let v = if signed { self.sign_extend(v, src_layout) } else { v }; trace!("cast_from_scalar: {}, {} -> {}", v, src_layout.ty, cast_ty); - use rustc_middle::ty::TyKind::*; - match *cast_ty.kind() { + use rustc_middle::ty::TyData::*; + match *cast_ty.data() { Int(_) | Uint(_) | RawPtr(_) => { - let size = match *cast_ty.kind() { + let size = match *cast_ty.data() { Int(t) => Integer::from_attr(self, attr::IntType::SignedInt(t)).size(), Uint(t) => Integer::from_attr(self, attr::IntType::UnsignedInt(t)).size(), RawPtr(_) => self.pointer_size(), @@ -227,8 +227,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { where F: Float + Into> + FloatConvert + FloatConvert, { - use rustc_middle::ty::TyKind::*; - match *dest_ty.kind() { + use rustc_middle::ty::TyData::*; + match *dest_ty.data() { // float -> uint Uint(t) => { let size = Integer::from_attr(self, attr::IntType::UnsignedInt(t)).size(); @@ -267,7 +267,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let (src_pointee_ty, dest_pointee_ty) = self.tcx.struct_lockstep_tails_erasing_lifetimes(source_ty, cast_ty, self.param_env); - match (&src_pointee_ty.kind(), &dest_pointee_ty.kind()) { + match (&src_pointee_ty.data(), &dest_pointee_ty.data()) { (&ty::Array(_, length), &ty::Slice(_)) => { let ptr = self.read_immediate(src)?.to_scalar()?; // u64 cast is from usize to u64, which is always good @@ -303,7 +303,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { dest: PlaceTy<'tcx, M::PointerTag>, ) -> InterpResult<'tcx> { trace!("Unsizing {:?} of type {} into {:?}", *src, src.layout.ty, cast_ty.ty); - match (&src.layout.ty.kind(), &cast_ty.ty.kind()) { + match (&src.layout.ty.data(), &cast_ty.ty.data()) { (&ty::Ref(_, s, _), &ty::Ref(_, c, _) | &ty::RawPtr(TypeAndMut { ty: c, .. })) | (&ty::RawPtr(TypeAndMut { ty: s, .. }), &ty::RawPtr(TypeAndMut { ty: c, .. })) => { self.unsize_into_ptr(src, dest, s, c) diff --git a/compiler/rustc_mir/src/interpret/eval_context.rs b/compiler/rustc_mir/src/interpret/eval_context.rs index 93da6e3d38a93..22e3538574aec 100644 --- a/compiler/rustc_mir/src/interpret/eval_context.rs +++ b/compiler/rustc_mir/src/interpret/eval_context.rs @@ -573,7 +573,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { if !layout.is_unsized() { return Ok(Some((layout.size, layout.align.abi))); } - match layout.ty.kind() { + match layout.ty.data() { ty::Adt(..) | ty::Tuple(..) => { // First get the size of all statically known fields. // Don't use type_of::sizing_type_of because that expects t to be sized, diff --git a/compiler/rustc_mir/src/interpret/intern.rs b/compiler/rustc_mir/src/interpret/intern.rs index dd5e9c9977437..84bca98c8a352 100644 --- a/compiler/rustc_mir/src/interpret/intern.rs +++ b/compiler/rustc_mir/src/interpret/intern.rs @@ -195,13 +195,13 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx>> ValueVisitor<'mir // Raw pointers (and boxes) are handled by the `leftover_relocations` logic. let tcx = self.ecx.tcx; let ty = mplace.layout.ty; - if let ty::Ref(_, referenced_ty, ref_mutability) = *ty.kind() { + if let ty::Ref(_, referenced_ty, ref_mutability) = *ty.data() { let value = self.ecx.read_immediate(mplace.into())?; let mplace = self.ecx.ref_to_mplace(value)?; assert_eq!(mplace.layout.ty, referenced_ty); // Handle trait object vtables. if let ty::Dynamic(..) = - tcx.struct_tail_erasing_lifetimes(referenced_ty, self.ecx.param_env).kind() + tcx.struct_tail_erasing_lifetimes(referenced_ty, self.ecx.param_env).data() { // Validation will error (with a better message) on an invalid vtable pointer // so we can safely not do anything if this is not a real pointer. @@ -253,7 +253,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx>> ValueVisitor<'mir // This helps to prevent users from accidentally exploiting UB that they // caused (by somehow getting a mutable reference in a `const`). if ref_mutability == Mutability::Mut { - match referenced_ty.kind() { + match referenced_ty.data() { ty::Array(_, n) if n.eval_usize(*tcx, self.ecx.param_env) == 0 => {} ty::Slice(_) if mplace.meta.unwrap_meta().to_machine_usize(self.ecx)? diff --git a/compiler/rustc_mir/src/interpret/intrinsics.rs b/compiler/rustc_mir/src/interpret/intrinsics.rs index d3b6d706337ed..9254c0de93b13 100644 --- a/compiler/rustc_mir/src/interpret/intrinsics.rs +++ b/compiler/rustc_mir/src/interpret/intrinsics.rs @@ -76,7 +76,7 @@ crate fn eval_nullary_intrinsic<'tcx>( ConstValue::from_u64(tcx.type_id_hash(tp_ty)) } sym::variant_count => { - if let ty::Adt(ref adt, _) = tp_ty.kind() { + if let ty::Adt(ref adt, _) = tp_ty.data() { ConstValue::from_machine_usize(adt.variants.len() as u64, &tcx) } else { ConstValue::from_machine_usize(0u64, &tcx) diff --git a/compiler/rustc_mir/src/interpret/intrinsics/type_name.rs b/compiler/rustc_mir/src/interpret/intrinsics/type_name.rs index 554ada1ab254c..2447aa16adba2 100644 --- a/compiler/rustc_mir/src/interpret/intrinsics/type_name.rs +++ b/compiler/rustc_mir/src/interpret/intrinsics/type_name.rs @@ -32,7 +32,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> { } fn print_type(mut self, ty: Ty<'tcx>) -> Result { - match *ty.kind() { + match *ty.data() { // Types without identity. ty::Bool | ty::Char diff --git a/compiler/rustc_mir/src/interpret/operand.rs b/compiler/rustc_mir/src/interpret/operand.rs index 735f890a33bdc..34e6423705976 100644 --- a/compiler/rustc_mir/src/interpret/operand.rs +++ b/compiler/rustc_mir/src/interpret/operand.rs @@ -654,7 +654,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let discr_val = self.cast_from_scalar(tag_bits, tag_layout, discr_layout.ty); let discr_bits = discr_val.assert_bits(discr_layout.size); // Convert discriminant to variant index, and catch invalid discriminants. - let index = match *op.layout.ty.kind() { + let index = match *op.layout.ty.data() { ty::Adt(adt, _) => { adt.discriminants(*self.tcx).find(|(_, var)| var.val == discr_bits) } diff --git a/compiler/rustc_mir/src/interpret/operator.rs b/compiler/rustc_mir/src/interpret/operator.rs index fc266fa74bfa9..bf7a33c499f5a 100644 --- a/compiler/rustc_mir/src/interpret/operator.rs +++ b/compiler/rustc_mir/src/interpret/operator.rs @@ -282,7 +282,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { right.layout.ty ); - match left.layout.ty.kind() { + match left.layout.ty.data() { ty::Char => { assert_eq!(left.layout.ty, right.layout.ty); let left = left.to_scalar()?; @@ -368,7 +368,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let val = val.to_scalar()?; trace!("Running unary op {:?}: {:?} ({:?})", un_op, val, layout.ty); - match layout.ty.kind() { + match layout.ty.data() { ty::Bool => { let val = val.to_bool()?; let res = match un_op { diff --git a/compiler/rustc_mir/src/interpret/place.rs b/compiler/rustc_mir/src/interpret/place.rs index 72551b23370dd..dfa6ae4937b95 100644 --- a/compiler/rustc_mir/src/interpret/place.rs +++ b/compiler/rustc_mir/src/interpret/place.rs @@ -202,7 +202,7 @@ impl<'tcx, Tag> MPlaceTy<'tcx, Tag> { pub(super) fn len(self, cx: &impl HasDataLayout) -> InterpResult<'tcx, u64> { if self.layout.is_unsized() { // We need to consult `meta` metadata - match self.layout.ty.kind() { + match self.layout.ty.data() { ty::Slice(..) | ty::Str => self.mplace.meta.unwrap_meta().to_machine_usize(cx), _ => bug!("len not supported on unsized type {:?}", self.layout.ty), } @@ -218,7 +218,7 @@ impl<'tcx, Tag> MPlaceTy<'tcx, Tag> { #[inline] pub(super) fn vtable(self) -> Scalar { - match self.layout.ty.kind() { + match self.layout.ty.data() { ty::Dynamic(..) => self.mplace.meta.unwrap_meta(), _ => bug!("vtable not supported on type {:?}", self.layout.ty), } @@ -498,7 +498,7 @@ where // Compute meta and new layout let inner_len = actual_to.checked_sub(from).unwrap(); - let (meta, ty) = match base.layout.ty.kind() { + let (meta, ty) = match base.layout.ty.data() { // 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, self.tcx.mk_array(inner, inner_len)), diff --git a/compiler/rustc_mir/src/interpret/terminator.rs b/compiler/rustc_mir/src/interpret/terminator.rs index 9f200ca62b8c6..5c19897c9790f 100644 --- a/compiler/rustc_mir/src/interpret/terminator.rs +++ b/compiler/rustc_mir/src/interpret/terminator.rs @@ -55,7 +55,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let old_stack = self.frame_idx(); let old_loc = self.frame().loc; let func = self.eval_operand(func, None)?; - let (fn_val, abi) = match *func.layout.ty.kind() { + let (fn_val, abi) = match *func.layout.ty.data() { ty::FnPtr(sig) => { let caller_abi = sig.abi(); let fn_ptr = self.read_scalar(func)?.check_init()?; @@ -227,7 +227,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { { let callee_abi = { let instance_ty = instance.ty(*self.tcx, self.param_env); - match instance_ty.kind() { + match instance_ty.data() { ty::FnDef(..) => instance_ty.fn_sig(*self.tcx).abi(), ty::Closure(..) => Abi::RustCall, ty::Generator(..) => Abi::Rust, @@ -436,7 +436,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { // implementation fail -- a problem shared by rustc. let place = self.force_allocation(place)?; - let (instance, place) = match place.layout.ty.kind() { + let (instance, place) = match place.layout.ty.data() { ty::Dynamic(..) => { // Dropping a trait object. self.unpack_dyn_trait(place)? diff --git a/compiler/rustc_mir/src/interpret/util.rs b/compiler/rustc_mir/src/interpret/util.rs index fc5a25ffbf251..a4629806c266f 100644 --- a/compiler/rustc_mir/src/interpret/util.rs +++ b/compiler/rustc_mir/src/interpret/util.rs @@ -33,7 +33,7 @@ where return false; } - match *ty.kind() { + match *ty.data() { ty::Param(_) => true, ty::Closure(def_id, substs) | ty::Generator(def_id, substs, ..) @@ -59,7 +59,7 @@ where // `ty::Param`/`ty::ConstKind::Param`. (false, true) if cfg!(debug_assertions) => match subst.unpack() { ty::subst::GenericArgKind::Type(ty) => { - assert!(matches!(ty.kind(), ty::Param(_))) + assert!(matches!(ty.data(), ty::Param(_))) } ty::subst::GenericArgKind::Const(ct) => { assert!(matches!(ct.val, ty::ConstKind::Param(_))) diff --git a/compiler/rustc_mir/src/interpret/validity.rs b/compiler/rustc_mir/src/interpret/validity.rs index 2b83e1c8134ef..dcbf006da5572 100644 --- a/compiler/rustc_mir/src/interpret/validity.rs +++ b/compiler/rustc_mir/src/interpret/validity.rs @@ -214,7 +214,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' match layout.variants { Variants::Multiple { tag_field, .. } => { if tag_field == field { - return match layout.ty.kind() { + return match layout.ty.data() { ty::Adt(def, ..) if def.is_enum() => PathElem::EnumTag, ty::Generator(..) => PathElem::GeneratorTag, _ => bug!("non-variant type {:?}", layout.ty), @@ -225,7 +225,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' } // Now we know we are projecting to a field, so figure out which one. - match layout.ty.kind() { + match layout.ty.data() { // generators and closures. ty::Closure(def_id, _) | ty::Generator(def_id, _, _) => { let mut name = None; @@ -303,7 +303,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' pointee: TyAndLayout<'tcx>, ) -> InterpResult<'tcx> { let tail = self.ecx.tcx.struct_tail_erasing_lifetimes(pointee.ty, self.ecx.param_env); - match tail.kind() { + match tail.data() { ty::Dynamic(..) => { let vtable = meta.unwrap_meta(); // Direct call to `check_ptr_access_align` checks alignment even on CTFE machines. @@ -479,7 +479,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' ) -> InterpResult<'tcx, bool> { // Go over all the primitive types let ty = value.layout.ty; - match ty.kind() { + match ty.data() { ty::Bool => { let value = self.ecx.read_scalar(value)?; try_validation!( @@ -694,7 +694,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M> variant_id: VariantIdx, new_op: OpTy<'tcx, M::PointerTag>, ) -> InterpResult<'tcx> { - let name = match old_op.layout.ty.kind() { + let name = match old_op.layout.ty.data() { ty::Adt(adt, _) => PathElem::Variant(adt.variants[variant_id].ident.name), // Generators also have variants ty::Generator(..) => PathElem::GeneratorState(variant_id), @@ -764,7 +764,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M> op: OpTy<'tcx, M::PointerTag>, fields: impl Iterator>, ) -> InterpResult<'tcx> { - match op.layout.ty.kind() { + match op.layout.ty.data() { ty::Str => { let mplace = op.assert_mem_place(self.ecx); // strings are never immediate let len = mplace.len(self.ecx)?; @@ -781,7 +781,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M> // FIXME(wesleywiser) This logic could be extended further to arbitrary structs // or tuples made up of integer/floating point types or inhabited ZSTs with no // padding. - match tys.kind() { + match tys.data() { ty::Int(..) | ty::Uint(..) | ty::Float(..) => true, _ => false, } diff --git a/compiler/rustc_mir/src/interpret/visitor.rs b/compiler/rustc_mir/src/interpret/visitor.rs index 097b9ae6ca1cd..015049a8adc71 100644 --- a/compiler/rustc_mir/src/interpret/visitor.rs +++ b/compiler/rustc_mir/src/interpret/visitor.rs @@ -203,7 +203,7 @@ macro_rules! make_value_visitor { trace!("walk_value: type: {}", v.layout().ty); // Special treatment for special types, where the (static) layout is not sufficient. - match *v.layout().ty.kind() { + match *v.layout().ty.data() { // If it is a trait object, switch to the real type that was used to create it. ty::Dynamic(..) => { // immediate trait objects are not a thing diff --git a/compiler/rustc_mir/src/monomorphize/collector.rs b/compiler/rustc_mir/src/monomorphize/collector.rs index 7e12cc9176ee1..d397bbee44d7f 100644 --- a/compiler/rustc_mir/src/monomorphize/collector.rs +++ b/compiler/rustc_mir/src/monomorphize/collector.rs @@ -600,7 +600,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> { ) => { let source_ty = operand.ty(self.body, self.tcx); let source_ty = self.monomorphize(source_ty); - match *source_ty.kind() { + match *source_ty.data() { ty::Closure(def_id, substs) => { let instance = Instance::resolve_closure( self.tcx, @@ -741,7 +741,7 @@ fn visit_fn_use<'tcx>( source: Span, output: &mut Vec>>, ) { - if let ty::FnDef(def_id, substs) = *ty.kind() { + if let ty::FnDef(def_id, substs) = *ty.data() { let instance = if is_direct_call { ty::Instance::resolve(tcx, ty::ParamEnv::reveal_all(), def_id, substs).unwrap().unwrap() } else { @@ -878,7 +878,7 @@ fn find_vtable_types_for_unsizing<'tcx>( return false; } let tail = tcx.struct_tail_erasing_lifetimes(ty, param_env); - match tail.kind() { + match tail.data() { ty::Foreign(..) => false, ty::Str | ty::Slice(..) | ty::Dynamic(..) => true, _ => bug!("unexpected unsized tail: {:?}", tail), @@ -891,7 +891,7 @@ fn find_vtable_types_for_unsizing<'tcx>( } }; - match (&source_ty.kind(), &target_ty.kind()) { + match (&source_ty.data(), &target_ty.data()) { (&ty::Ref(_, a, _), &ty::Ref(_, b, _) | &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) | (&ty::RawPtr(ty::TypeAndMut { ty: a, .. }), &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) => { ptr_vtable(a, b) @@ -947,7 +947,7 @@ fn create_mono_items_for_vtable_methods<'tcx>( ) { assert!(!trait_ty.has_escaping_bound_vars() && !impl_ty.has_escaping_bound_vars()); - if let ty::Dynamic(ref trait_ty, ..) = trait_ty.kind() { + if let ty::Dynamic(ref trait_ty, ..) = trait_ty.data() { if let Some(principal) = trait_ty.principal() { let poly_trait_ref = principal.with_self_ty(tcx, impl_ty); assert!(!poly_trait_ref.has_escaping_bound_vars()); diff --git a/compiler/rustc_mir/src/monomorphize/polymorphize.rs b/compiler/rustc_mir/src/monomorphize/polymorphize.rs index 3f6f117acdc1c..d52a6e26689fc 100644 --- a/compiler/rustc_mir/src/monomorphize/polymorphize.rs +++ b/compiler/rustc_mir/src/monomorphize/polymorphize.rs @@ -288,7 +288,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> { return false; } - match *ty.kind() { + match *ty.data() { ty::Closure(def_id, substs) | ty::Generator(def_id, substs, ..) => { debug!("visit_ty: def_id={:?}", def_id); // Avoid cycle errors with generators. @@ -337,7 +337,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for HasUsedGenericParams<'a> { return false; } - match ty.kind() { + match ty.data() { ty::Param(param) => !self.unused_parameters.contains(param.index).unwrap_or(false), _ => ty.super_visit_with(self), } diff --git a/compiler/rustc_mir/src/shim.rs b/compiler/rustc_mir/src/shim.rs index 5431d22e70320..c0b0c10687a88 100644 --- a/compiler/rustc_mir/src/shim.rs +++ b/compiler/rustc_mir/src/shim.rs @@ -133,7 +133,7 @@ fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option>) debug!("build_drop_shim(def_id={:?}, ty={:?})", def_id, ty); // Check if this is a generator, if so, return the drop glue for it - if let Some(&ty::Generator(gen_def_id, substs, _)) = ty.map(|ty| ty.kind()) { + if let Some(&ty::Generator(gen_def_id, substs, _)) = ty.map(|ty| ty.data()) { let body = &**tcx.optimized_mir(gen_def_id).generator_drop.as_ref().unwrap(); return body.subst(tcx, substs); } @@ -300,7 +300,7 @@ fn build_clone_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, self_ty: Ty<'tcx>) - let dest = Place::return_place(); let src = tcx.mk_place_deref(Place::from(Local::new(1 + 0))); - match self_ty.kind() { + match self_ty.data() { _ if is_copy => builder.copy_shim(), ty::Array(ty, len) => { let len = len.eval_usize(tcx, param_env); @@ -862,7 +862,7 @@ pub fn build_adt_ctor(tcx: TyCtxt<'_>, ctor_id: DefId) -> Body<'_> { let sig = tcx.fn_sig(ctor_id).no_bound_vars().expect("LBR in ADT constructor signature"); let sig = tcx.normalize_erasing_regions(param_env, sig); - let (adt_def, substs) = match sig.output().kind() { + let (adt_def, substs) = match sig.output().data() { ty::Adt(adt_def, substs) => (adt_def, substs), _ => bug!("unexpected type for ADT ctor {:?}", sig.output()), }; diff --git a/compiler/rustc_mir/src/transform/add_retag.rs b/compiler/rustc_mir/src/transform/add_retag.rs index eec704e6cb775..2e7eed8e6c708 100644 --- a/compiler/rustc_mir/src/transform/add_retag.rs +++ b/compiler/rustc_mir/src/transform/add_retag.rs @@ -35,7 +35,7 @@ fn is_stable(place: PlaceRef<'_>) -> bool { /// Determine whether this type may be a reference (or box), and thus needs retagging. fn may_be_reference(ty: Ty<'tcx>) -> bool { - match ty.kind() { + match ty.data() { // Primitive types that are not references ty::Bool | ty::Char diff --git a/compiler/rustc_mir/src/transform/check_consts/qualifs.rs b/compiler/rustc_mir/src/transform/check_consts/qualifs.rs index b3d9beb3742b2..4617cce003e56 100644 --- a/compiler/rustc_mir/src/transform/check_consts/qualifs.rs +++ b/compiler/rustc_mir/src/transform/check_consts/qualifs.rs @@ -170,7 +170,7 @@ where // Special-case reborrows to be more like a copy of the reference. if let &[ref proj_base @ .., ProjectionElem::Deref] = place.projection.as_ref() { let base_ty = Place::ty_from(place.local, proj_base, cx.body, cx.tcx).ty; - if let ty::Ref(..) = base_ty.kind() { + if let ty::Ref(..) = base_ty.data() { return in_place::( cx, in_local, diff --git a/compiler/rustc_mir/src/transform/check_consts/validation.rs b/compiler/rustc_mir/src/transform/check_consts/validation.rs index 587b5b381288a..987d98fd7ce58 100644 --- a/compiler/rustc_mir/src/transform/check_consts/validation.rs +++ b/compiler/rustc_mir/src/transform/check_consts/validation.rs @@ -342,7 +342,7 @@ impl Validator<'mir, 'tcx> { GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => continue, }; - match *ty.kind() { + match *ty.data() { ty::Ref(_, _, hir::Mutability::Mut) => self.check_op(ops::ty::MutRef(kind)), ty::Opaque(..) => self.check_op(ops::ty::ImplTrait), ty::FnPtr(..) => self.check_op(ops::ty::FnPtr(kind)), @@ -395,7 +395,7 @@ impl Validator<'mir, 'tcx> { if Some(pred.def_id()) == tcx.lang_items().sized_trait() { continue; } - match pred.self_ty().kind() { + match pred.self_ty().data() { ty::Param(p) => { let generics = tcx.generics_of(current); let def = generics.type_param(p, tcx); @@ -505,7 +505,7 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> { Rvalue::Ref(_, kind @ BorrowKind::Mut { .. }, ref place) | Rvalue::Ref(_, kind @ BorrowKind::Unique, ref place) => { let ty = place.ty(self.body, self.tcx).ty; - let is_allowed = match ty.kind() { + let is_allowed = match ty.data() { // Inside a `static mut`, `&mut [...]` is allowed. ty::Array(..) | ty::Slice(_) if self.const_kind() == hir::ConstContext::Static(hir::Mutability::Mut) => @@ -568,7 +568,7 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> { let unsized_ty = self.tcx.struct_tail_erasing_lifetimes(ty, self.param_env); // Casting/coercing things to slices is fine. - if let ty::Slice(_) | ty::Str = unsized_ty.kind() { + if let ty::Slice(_) | ty::Str = unsized_ty.data() { return; } } @@ -665,7 +665,7 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> { match elem { ProjectionElem::Deref => { let base_ty = Place::ty_from(place_local, proj_base, self.body, self.tcx).ty; - if let ty::RawPtr(_) = base_ty.kind() { + if let ty::RawPtr(_) = base_ty.data() { if proj_base.is_empty() { if let (local, []) = (place_local, proj_base) { let decl = &self.body.local_decls[local]; @@ -742,7 +742,7 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> { let fn_ty = func.ty(body, tcx); - let (mut callee, substs) = match *fn_ty.kind() { + let (mut callee, substs) = match *fn_ty.data() { ty::FnDef(def_id, substs) => (def_id, substs), ty::FnPtr(_) => { @@ -933,7 +933,7 @@ fn place_as_reborrow( // This is sufficient to prevent an access to a `static mut` from being marked as a // reborrow, even if the check above were to disappear. let inner_ty = Place::ty_from(place.local, inner, body, tcx).ty; - match inner_ty.kind() { + match inner_ty.data() { ty::Ref(..) => Some(inner), _ => None, } diff --git a/compiler/rustc_mir/src/transform/check_unsafety.rs b/compiler/rustc_mir/src/transform/check_unsafety.rs index 7309a4129e468..2e05bb2ce2965 100644 --- a/compiler/rustc_mir/src/transform/check_unsafety.rs +++ b/compiler/rustc_mir/src/transform/check_unsafety.rs @@ -91,7 +91,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> { ) } - if let ty::FnDef(func_id, _) = func_ty.kind() { + if let ty::FnDef(func_id, _) = func_ty.data() { self.check_target_features(*func_id); } } @@ -227,7 +227,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> { } } let base_ty = Place::ty_from(place.local, proj_base, self.body, self.tcx).ty; - match base_ty.kind() { + match base_ty.data() { ty::RawPtr(..) => self.require_unsafe( UnsafetyViolationKind::GeneralAndConstFn, UnsafetyViolationDetails::DerefOfRawPointer, @@ -394,7 +394,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> { ProjectionElem::Field(..) => { let ty = Place::ty_from(place.local, proj_base, &self.body.local_decls, self.tcx).ty; - if let ty::Adt(def, _) = ty.kind() { + if let ty::Adt(def, _) = ty.data() { if self.tcx.layout_scalar_valid_range(def.did) != (Bound::Unbounded, Bound::Unbounded) { diff --git a/compiler/rustc_mir/src/transform/const_prop.rs b/compiler/rustc_mir/src/transform/const_prop.rs index 14b310cda939e..558f5c93a860b 100644 --- a/compiler/rustc_mir/src/transform/const_prop.rs +++ b/compiler/rustc_mir/src/transform/const_prop.rs @@ -833,7 +833,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { // FIXME: enable the general case stated above ^. let ty = &value.layout.ty; // Only do it for tuples - if let ty::Tuple(substs) = ty.kind() { + if let ty::Tuple(substs) = ty.data() { // Only do it if tuple is also a pair with two scalars if substs.len() == 2 { let alloc = self.use_ecx(|this| { diff --git a/compiler/rustc_mir/src/transform/dest_prop.rs b/compiler/rustc_mir/src/transform/dest_prop.rs index 410f462ed469f..ff337fa397123 100644 --- a/compiler/rustc_mir/src/transform/dest_prop.rs +++ b/compiler/rustc_mir/src/transform/dest_prop.rs @@ -907,7 +907,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindAssignments<'a, 'tcx> { // Handle the "subtle case" described above by rejecting any `dest` that is or // projects through a union. let is_union = |ty: Ty<'_>| { - if let ty::Adt(def, _) = ty.kind() { + if let ty::Adt(def, _) = ty.data() { if def.is_union() { return true; } diff --git a/compiler/rustc_mir/src/transform/generator.rs b/compiler/rustc_mir/src/transform/generator.rs index 924bb4996fc35..e3301f6ddc319 100644 --- a/compiler/rustc_mir/src/transform/generator.rs +++ b/compiler/rustc_mir/src/transform/generator.rs @@ -726,12 +726,12 @@ fn sanitize_witness<'tcx>( ) { let did = body.source.def_id(); let allowed_upvars = tcx.erase_regions(upvars); - let allowed = match witness.kind() { + let allowed = match witness.data() { ty::GeneratorWitness(s) => tcx.erase_late_bound_regions(&s), _ => { tcx.sess.delay_span_bug( body.span, - &format!("unexpected generator witness type {:?}", witness.kind()), + &format!("unexpected generator witness type {:?}", witness.data()), ); return; } @@ -1249,7 +1249,7 @@ impl<'tcx> MirPass<'tcx> for StateTransform { let gen_ty = body.local_decls.raw[1].ty; // Get the interior types and substs which typeck computed - let (upvars, interior, discr_ty, movable) = match *gen_ty.kind() { + let (upvars, interior, discr_ty, movable) = match *gen_ty.data() { ty::Generator(_, substs, movability) => { let substs = substs.as_generator(); ( diff --git a/compiler/rustc_mir/src/transform/inline.rs b/compiler/rustc_mir/src/transform/inline.rs index bec1eb790478c..bd316d89e1abf 100644 --- a/compiler/rustc_mir/src/transform/inline.rs +++ b/compiler/rustc_mir/src/transform/inline.rs @@ -200,7 +200,7 @@ impl Inliner<'tcx> { // Only consider direct calls to functions let terminator = bb_data.terminator(); if let TerminatorKind::Call { func: ref op, .. } = terminator.kind { - if let ty::FnDef(callee_def_id, substs) = *op.ty(caller_body, self.tcx).kind() { + if let ty::FnDef(callee_def_id, substs) = *op.ty(caller_body, self.tcx).data() { let instance = Instance::resolve(self.tcx, self.param_env, callee_def_id, substs) .ok() .flatten()?; @@ -353,7 +353,7 @@ impl Inliner<'tcx> { } TerminatorKind::Call { func: Operand::Constant(ref f), cleanup, .. } => { - if let ty::FnDef(def_id, _) = *f.literal.ty.kind() { + if let ty::FnDef(def_id, _) = *f.literal.ty.data() { // Don't give intrinsics the extra penalty for calls let f = tcx.fn_sig(def_id); if f.abi() == Abi::RustIntrinsic || f.abi() == Abi::PlatformIntrinsic { @@ -596,7 +596,7 @@ impl Inliner<'tcx> { assert!(args.next().is_none()); let tuple = Place::from(tuple); - let tuple_tys = if let ty::Tuple(s) = tuple.ty(caller_body, tcx).ty.kind() { + let tuple_tys = if let ty::Tuple(s) = tuple.ty(caller_body, tcx).ty.data() { s } else { bug!("Closure arguments are not passed as a tuple"); diff --git a/compiler/rustc_mir/src/transform/instcombine.rs b/compiler/rustc_mir/src/transform/instcombine.rs index 1a8e281d417df..70a4b39a63fc1 100644 --- a/compiler/rustc_mir/src/transform/instcombine.rs +++ b/compiler/rustc_mir/src/transform/instcombine.rs @@ -248,7 +248,7 @@ impl Visitor<'tcx> for OptimizationFinder<'b, 'tcx> { { // The dereferenced place must have type `&_`. let ty = Place::ty_from(local, proj_base, self.body, self.tcx).ty; - if let ty::Ref(_, _, Mutability::Not) = ty.kind() { + if let ty::Ref(_, _, Mutability::Not) = ty.data() { self.optimizations.and_stars.insert(location); } } @@ -256,7 +256,7 @@ impl Visitor<'tcx> for OptimizationFinder<'b, 'tcx> { if let Rvalue::Len(ref place) = *rvalue { let place_ty = place.ty(&self.body.local_decls, self.tcx).ty; - if let ty::Array(_, len) = place_ty.kind() { + if let ty::Array(_, len) = place_ty.data() { let span = self.body.source_info(location).span; let constant = Constant { span, literal: len, user_ty: None }; self.optimizations.arrays_lengths.insert(location, constant); diff --git a/compiler/rustc_mir/src/transform/promote_consts.rs b/compiler/rustc_mir/src/transform/promote_consts.rs index 7abc998d3882f..16a114be39ab6 100644 --- a/compiler/rustc_mir/src/transform/promote_consts.rs +++ b/compiler/rustc_mir/src/transform/promote_consts.rs @@ -218,7 +218,7 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> { match terminator.kind { TerminatorKind::Call { ref func, .. } => { - if let ty::FnDef(def_id, _) = *func.ty(self.ccx.body, self.ccx.tcx).kind() { + if let ty::FnDef(def_id, _) = *func.ty(self.ccx.body, self.ccx.tcx).data() { let fn_sig = self.ccx.tcx.fn_sig(def_id); if let Abi::RustIntrinsic | Abi::PlatformIntrinsic = fn_sig.abi() { let name = self.ccx.tcx.item_name(def_id); @@ -370,7 +370,7 @@ impl<'tcx> Validator<'_, 'tcx> { // In theory, any zero-sized value could be borrowed // mutably without consequences. However, only &mut [] // is allowed right now. - if let ty::Array(_, len) = ty.kind() { + if let ty::Array(_, len) = ty.data() { match len.try_eval_usize(self.tcx, self.param_env) { Some(0) => {} _ => return Err(Unpromotable), @@ -614,7 +614,7 @@ impl<'tcx> Validator<'_, 'tcx> { } Rvalue::BinaryOp(op, ref lhs, _) => { - if let ty::RawPtr(_) | ty::FnPtr(..) = lhs.ty(self.body, self.tcx).kind() { + if let ty::RawPtr(_) | ty::FnPtr(..) = lhs.ty(self.body, self.tcx).data() { assert!( op == BinOp::Eq || op == BinOp::Ne @@ -658,7 +658,7 @@ impl<'tcx> Validator<'_, 'tcx> { // no problem, only using it is. if let [proj_base @ .., ProjectionElem::Deref] = place.projection.as_ref() { let base_ty = Place::ty_from(place.local, proj_base, self.body, self.tcx).ty; - if let ty::Ref(..) = base_ty.kind() { + if let ty::Ref(..) = base_ty.data() { return self.validate_place(PlaceRef { local: place.local, projection: proj_base, @@ -675,7 +675,7 @@ impl<'tcx> Validator<'_, 'tcx> { // In theory, any zero-sized value could be borrowed // mutably without consequences. However, only &mut [] // is allowed right now. - if let ty::Array(_, len) = ty.kind() { + if let ty::Array(_, len) = ty.data() { match len.try_eval_usize(self.tcx, self.param_env) { Some(0) => {} _ => return Err(Unpromotable), @@ -689,7 +689,7 @@ impl<'tcx> Validator<'_, 'tcx> { let mut place = place.as_ref(); if let [proj_base @ .., ProjectionElem::Deref] = &place.projection { let base_ty = Place::ty_from(place.local, proj_base, self.body, self.tcx).ty; - if let ty::Ref(..) = base_ty.kind() { + if let ty::Ref(..) = base_ty.data() { place = PlaceRef { local: place.local, projection: proj_base }; } } @@ -743,7 +743,7 @@ impl<'tcx> Validator<'_, 'tcx> { let fn_ty = callee.ty(self.body, self.tcx); if !self.explicit && self.maybe_runtime() { - if let ty::FnDef(def_id, _) = *fn_ty.kind() { + if let ty::FnDef(def_id, _) = *fn_ty.data() { // Never promote runtime `const fn` calls of // functions without `#[rustc_promotable]`. if !self.tcx.is_promotable_const_fn(def_id) { @@ -752,7 +752,7 @@ impl<'tcx> Validator<'_, 'tcx> { } } - let is_const_fn = match *fn_ty.kind() { + let is_const_fn = match *fn_ty.data() { ty::FnDef(def_id, _) => { is_const_fn(self.tcx, def_id) || is_unstable_const_fn(self.tcx, def_id).is_some() diff --git a/compiler/rustc_mir/src/transform/rustc_peek.rs b/compiler/rustc_mir/src/transform/rustc_peek.rs index 205f718d6e446..1f72601729157 100644 --- a/compiler/rustc_mir/src/transform/rustc_peek.rs +++ b/compiler/rustc_mir/src/transform/rustc_peek.rs @@ -180,7 +180,7 @@ enum PeekCallKind { impl PeekCallKind { fn from_arg_ty(arg: Ty<'_>) -> Self { - match arg.kind() { + match arg.data() { ty::Ref(_, _, _) => PeekCallKind::ByRef, _ => PeekCallKind::ByVal, } @@ -205,7 +205,7 @@ impl PeekCall { if let mir::TerminatorKind::Call { func: Operand::Constant(func), args, .. } = &terminator.kind { - if let ty::FnDef(def_id, substs) = *func.literal.ty.kind() { + if let ty::FnDef(def_id, substs) = *func.literal.ty.data() { let sig = tcx.fn_sig(def_id); let name = tcx.item_name(def_id); if sig.abi() != Abi::RustIntrinsic || name != sym::rustc_peek { diff --git a/compiler/rustc_mir/src/transform/simplify_try.rs b/compiler/rustc_mir/src/transform/simplify_try.rs index a4e7a5a94533d..d9b35553ac36c 100644 --- a/compiler/rustc_mir/src/transform/simplify_try.rs +++ b/compiler/rustc_mir/src/transform/simplify_try.rs @@ -700,7 +700,7 @@ impl<'a, 'tcx> SimplifyBranchSameOptimizationFinder<'a, 'tcx> { variant_index: &VariantIdx, side_to_choose| { let place_type = place.ty(self.body, self.tcx).ty; - let adt = match *place_type.kind() { + let adt = match *place_type.data() { ty::Adt(adt, _) if adt.is_enum() => adt, _ => return StatementEquality::NotEqual, }; diff --git a/compiler/rustc_mir/src/transform/validate.rs b/compiler/rustc_mir/src/transform/validate.rs index cf51e86c5bc8f..88ee7cb2b199e 100644 --- a/compiler/rustc_mir/src/transform/validate.rs +++ b/compiler/rustc_mir/src/transform/validate.rs @@ -379,7 +379,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { } TerminatorKind::Call { func, destination, cleanup, .. } => { let func_ty = func.ty(&self.body.local_decls, self.tcx); - match func_ty.kind() { + match func_ty.data() { ty::FnPtr(..) | ty::FnDef(..) => {} _ => self.fail( location, diff --git a/compiler/rustc_mir/src/util/alignment.rs b/compiler/rustc_mir/src/util/alignment.rs index a0728a6a63015..c5fac100d0d9d 100644 --- a/compiler/rustc_mir/src/util/alignment.rs +++ b/compiler/rustc_mir/src/util/alignment.rs @@ -47,7 +47,7 @@ where ProjectionElem::Deref => break, ProjectionElem::Field(..) => { let ty = Place::ty_from(place.local, proj_base, local_decls, tcx).ty; - match ty.kind() { + match ty.data() { ty::Adt(def, _) if def.repr.packed() => return true, _ => {} } diff --git a/compiler/rustc_mir/src/util/borrowck_errors.rs b/compiler/rustc_mir/src/util/borrowck_errors.rs index 83bf7584f2e2f..a9379a2f4d836 100644 --- a/compiler/rustc_mir/src/util/borrowck_errors.rs +++ b/compiler/rustc_mir/src/util/borrowck_errors.rs @@ -287,7 +287,7 @@ impl<'cx, 'tcx> crate::borrow_check::MirBorrowckCtxt<'cx, 'tcx> { ty: Ty<'_>, is_index: Option, ) -> DiagnosticBuilder<'cx> { - let type_name = match (&ty.kind(), is_index) { + let type_name = match (&ty.data(), is_index) { (&ty::Array(_, _), Some(true)) | (&ty::Array(_, _), None) => "array", (&ty::Slice(_), _) => "slice", _ => span_bug!(move_from_span, "this path should not cause illegal move"), diff --git a/compiler/rustc_mir/src/util/elaborate_drops.rs b/compiler/rustc_mir/src/util/elaborate_drops.rs index 43fa15d7e4912..58a1dcce04b86 100644 --- a/compiler/rustc_mir/src/util/elaborate_drops.rs +++ b/compiler/rustc_mir/src/util/elaborate_drops.rs @@ -848,7 +848,7 @@ where /// ADT, both in the success case or if one of the destructors fail. fn open_drop(&mut self) -> BasicBlock { let ty = self.place_ty(self.place); - match ty.kind() { + match ty.data() { ty::Closure(_, substs) => { let tys: Vec<_> = substs.as_closure().upvar_tys().collect(); self.open_drop_for_tuple(&tys) diff --git a/compiler/rustc_mir/src/util/find_self_call.rs b/compiler/rustc_mir/src/util/find_self_call.rs index 5b146eeb87c04..0b583b5cc51ce 100644 --- a/compiler/rustc_mir/src/util/find_self_call.rs +++ b/compiler/rustc_mir/src/util/find_self_call.rs @@ -18,7 +18,7 @@ pub fn find_self_call<'tcx>( { debug!("find_self_call: func={:?}", func); if let Operand::Constant(box Constant { literal: ty::Const { ty, .. }, .. }) = func { - if let ty::FnDef(def_id, substs) = *ty.kind() { + if let ty::FnDef(def_id, substs) = *ty.data() { if let Some(ty::AssocItem { fn_has_self_parameter: true, .. }) = tcx.opt_associated_item(def_id) { diff --git a/compiler/rustc_mir/src/util/pretty.rs b/compiler/rustc_mir/src/util/pretty.rs index bd7c25bf25043..03bcda8ca8bbe 100644 --- a/compiler/rustc_mir/src/util/pretty.rs +++ b/compiler/rustc_mir/src/util/pretty.rs @@ -411,7 +411,7 @@ impl Visitor<'tcx> for ExtraComments<'tcx> { fn visit_constant(&mut self, constant: &Constant<'tcx>, location: Location) { self.super_constant(constant, location); let Constant { span, user_ty, literal } = constant; - match literal.ty.kind() { + match literal.ty.data() { ty::Int(_) | ty::Uint(_) | ty::Bool | ty::Char => {} // Unit type ty::Tuple(tys) if tys.is_empty() => {} @@ -429,7 +429,7 @@ impl Visitor<'tcx> for ExtraComments<'tcx> { fn visit_const(&mut self, constant: &&'tcx ty::Const<'tcx>, _: Location) { self.super_const(constant); let ty::Const { ty, val, .. } = constant; - match ty.kind() { + match ty.data() { ty::Int(_) | ty::Uint(_) | ty::Bool | ty::Char | ty::Float(_) => {} // Unit type ty::Tuple(tys) if tys.is_empty() => {} 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 39dbb6dd3ff92..c70d3e6284e71 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_place.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_place.rs @@ -367,7 +367,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let tcx = self.hir.tcx(); let place_ty = Place::ty_from(base_place.local, &base_place.projection, &self.local_decls, tcx); - if let ty::Slice(_) = place_ty.ty.kind() { + if let ty::Slice(_) = place_ty.ty.data() { // We need to create fake borrows to ensure that the bounds // check that we just did stays valid. Since we can't assign to // unsized values, we only need to ensure that none of the @@ -406,7 +406,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { &self.local_decls, tcx, ); - match index_ty.ty.kind() { + match index_ty.ty.data() { // The previous index expression has already // done any index expressions needed here. ty::Slice(_) => break, diff --git a/compiler/rustc_mir_build/src/build/expr/into.rs b/compiler/rustc_mir_build/src/build/expr/into.rs index a12c22fb850e4..c1ecd237793b4 100644 --- a/compiler/rustc_mir_build/src/build/expr/into.rs +++ b/compiler/rustc_mir_build/src/build/expr/into.rs @@ -166,7 +166,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { }) } ExprKind::Call { ty, fun, args, from_hir_call, fn_span } => { - let intrinsic = match *ty.kind() { + let intrinsic = match *ty.data() { ty::FnDef(def_id, _) => { let f = ty.fn_sig(this.hir.tcx()); if f.abi() == Abi::RustIntrinsic || f.abi() == Abi::PlatformIntrinsic { diff --git a/compiler/rustc_mir_build/src/build/matches/simplify.rs b/compiler/rustc_mir_build/src/build/matches/simplify.rs index a28a181e93504..ae70d1e10d774 100644 --- a/compiler/rustc_mir_build/src/build/matches/simplify.rs +++ b/compiler/rustc_mir_build/src/build/matches/simplify.rs @@ -154,7 +154,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } PatKind::Range(PatRange { lo, hi, end }) => { - let (range, bias) = match *lo.ty.kind() { + let (range, bias) = match *lo.ty.data() { ty::Char => { (Some(('\u{0000}' as u128, '\u{10FFFF}' as u128, Size::from_bits(32))), 0) } diff --git a/compiler/rustc_mir_build/src/build/matches/test.rs b/compiler/rustc_mir_build/src/build/matches/test.rs index 02dcf0394f641..9e8646aaf8cda 100644 --- a/compiler/rustc_mir_build/src/build/matches/test.rs +++ b/compiler/rustc_mir_build/src/build/matches/test.rs @@ -215,7 +215,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { TestKind::SwitchInt { switch_ty, ref options } => { let target_blocks = make_target_blocks(self); - let terminator = if *switch_ty.kind() == ty::Bool { + let terminator = if *switch_ty.data() == ty::Bool { assert!(!options.is_empty() && options.len() <= 2); if let [first_bb, second_bb] = *target_blocks { let (true_bb, false_bb) = match options[0] { @@ -368,8 +368,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // We want to do this even when the scrutinee is a reference to an // array, so we can call `<[u8]>::eq` rather than having to find an // `<[u8; N]>::eq`. - let unsize = |ty: Ty<'tcx>| match ty.kind() { - ty::Ref(region, rty, _) => match rty.kind() { + let unsize = |ty: Ty<'tcx>| match ty.data() { + ty::Ref(region, rty, _) => match rty.data() { ty::Array(inner_ty, n) => Some((region, inner_ty, n)), _ => None, }, @@ -407,7 +407,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - let deref_ty = match *ty.kind() { + let deref_ty = match *ty.data() { ty::Ref(_, deref_ty, _) => deref_ty, _ => bug!("non_scalar_compare called on non-reference type: {}", ty), }; diff --git a/compiler/rustc_mir_build/src/build/matches/util.rs b/compiler/rustc_mir_build/src/build/matches/util.rs index 4ef88c25cadf3..0f60f0fec1611 100644 --- a/compiler/rustc_mir_build/src/build/matches/util.rs +++ b/compiler/rustc_mir_build/src/build/matches/util.rs @@ -31,7 +31,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { suffix: &'pat [Pat<'tcx>], ) { let tcx = self.hir.tcx(); - let (min_length, exact_size) = match place.ty(&self.local_decls, tcx).ty.kind() { + let (min_length, exact_size) = match place.ty(&self.local_decls, tcx).ty.data() { ty::Array(_, length) => { (length.eval_usize(tcx, self.hir.param_env), true) } diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs index 220e3b11a6adb..cf2e0f62d5efa 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/build/mod.rs @@ -102,7 +102,7 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam) -> Body<'_ let body = tcx.hir().body(body_id); let ty = tcx.type_of(fn_def_id); let mut abi = fn_sig.abi; - let implicit_argument = match ty.kind() { + let implicit_argument = match ty.data() { ty::Closure(..) => { // HACK(eddyb) Avoid having RustCall on closures, // as it adds unnecessary (and wrong) auto-tupling. @@ -165,7 +165,7 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam) -> Body<'_ let (yield_ty, return_ty) = if body.generator_kind.is_some() { let gen_ty = tcx.typeck_body(body_id).node_type(id); - let gen_sig = match gen_ty.kind() { + let gen_sig = match gen_ty.data() { ty::Generator(_, gen_substs, ..) => gen_substs.as_generator().sig(), _ => span_bug!(tcx.hir().span(id), "generator w/o generator type: {:?}", ty), }; @@ -234,7 +234,7 @@ fn liberated_closure_env_ty( ) -> Ty<'_> { let closure_ty = tcx.typeck_body(body_id).node_type(closure_expr_id); - let (closure_def_id, closure_substs) = match *closure_ty.kind() { + let (closure_def_id, closure_substs) = match *closure_ty.data() { ty::Closure(closure_def_id, closure_substs) => (closure_def_id, closure_substs), _ => bug!("closure expr does not have closure type: {:?}", closure_ty), }; @@ -829,11 +829,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let closure_env_arg = Local::new(1); let mut closure_env_projs = vec![]; let mut closure_ty = self.local_decls[closure_env_arg].ty; - if let ty::Ref(_, ty, _) = closure_ty.kind() { + if let ty::Ref(_, ty, _) = closure_ty.data() { closure_env_projs.push(ProjectionElem::Deref); closure_ty = ty; } - let upvar_substs = match closure_ty.kind() { + let upvar_substs = match closure_ty.data() { ty::Closure(_, substs) => ty::UpvarSubsts::Closure(substs), ty::Generator(_, substs, _) => ty::UpvarSubsts::Generator(substs), _ => span_bug!(self.fn_span, "upvars with non-closure env ty {:?}", closure_ty), diff --git a/compiler/rustc_mir_build/src/lints.rs b/compiler/rustc_mir_build/src/lints.rs index bdef02a011bac..06c57798a09dd 100644 --- a/compiler/rustc_mir_build/src/lints.rs +++ b/compiler/rustc_mir_build/src/lints.rs @@ -70,7 +70,7 @@ impl<'mir, 'tcx> Search<'mir, 'tcx> { let param_env = tcx.param_env(caller); let func_ty = func.ty(body, tcx); - if let ty::FnDef(callee, substs) = *func_ty.kind() { + if let ty::FnDef(callee, substs) = *func_ty.data() { let (callee, call_substs) = if let Ok(Some(instance)) = Instance::resolve(tcx, param_env, callee, substs) { (instance.def_id(), instance.substs) diff --git a/compiler/rustc_mir_build/src/thir/constant.rs b/compiler/rustc_mir_build/src/thir/constant.rs index b71ff6e755749..d46329ed999ad 100644 --- a/compiler/rustc_mir_build/src/thir/constant.rs +++ b/compiler/rustc_mir_build/src/thir/constant.rs @@ -21,7 +21,7 @@ crate fn lit_to_const<'tcx>( Ok(ConstValue::Scalar(Scalar::from_uint(result, width))) }; - let lit = match (lit, &ty.kind()) { + let lit = match (lit, &ty.data()) { (ast::LitKind::Str(s, _), ty::Ref(_, inner_ty, _)) if inner_ty.is_str() => { let s = s.as_str(); let allocation = Allocation::from_byte_aligned_bytes(s.as_bytes()); @@ -29,7 +29,7 @@ crate fn lit_to_const<'tcx>( ConstValue::Slice { data: allocation, start: 0, end: s.len() } } (ast::LitKind::ByteStr(data), ty::Ref(_, inner_ty, _)) - if matches!(inner_ty.kind(), ty::Slice(_)) => + if matches!(inner_ty.data(), ty::Slice(_)) => { let allocation = Allocation::from_byte_aligned_bytes(data as &[u8]); let allocation = tcx.intern_const_alloc(allocation); diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index 13e69474cfb96..d9efa0fc419a9 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -329,7 +329,7 @@ fn make_mirror_unadjusted<'a, 'tcx>( } } - hir::ExprKind::Struct(ref qpath, ref fields, ref base) => match expr_ty.kind() { + hir::ExprKind::Struct(ref qpath, ref fields, ref base) => match expr_ty.data() { ty::Adt(adt, substs) => match adt.adt_kind() { AdtKind::Struct | AdtKind::Union => { let user_provided_types = cx.typeck_results().user_provided_types(); @@ -379,7 +379,7 @@ fn make_mirror_unadjusted<'a, 'tcx>( hir::ExprKind::Closure(..) => { let closure_ty = cx.typeck_results().expr_ty(expr); - let (def_id, substs, movability) = match *closure_ty.kind() { + let (def_id, substs, movability) = match *closure_ty.data() { ty::Closure(def_id, substs) => (def_id, UpvarSubsts::Closure(substs), None), ty::Generator(def_id, substs, movability) => { (def_id, UpvarSubsts::Generator(substs), Some(movability)) @@ -843,7 +843,7 @@ fn convert_path_expr<'a, 'tcx>( let user_provided_type = user_provided_types.get(expr.hir_id).copied(); debug!("convert_path_expr: user_provided_type={:?}", user_provided_type); let ty = cx.typeck_results().node_type(expr.hir_id); - match ty.kind() { + match ty.data() { // 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, substs) => ExprKind::Adt { @@ -924,7 +924,7 @@ fn convert_var<'tcx>( }); let region = cx.tcx.mk_region(region); - let self_expr = if let ty::Closure(_, closure_substs) = closure_ty.kind() { + let self_expr = if let ty::Closure(_, closure_substs) = closure_ty.data() { match cx.infcx.closure_kind(closure_substs).unwrap() { ty::ClosureKind::Fn => { let ref_closure_ty = cx.tcx.mk_ref( @@ -1053,7 +1053,7 @@ fn overloaded_place<'a, '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 (region, mutbl) = match *recv_ty.kind() { + let (region, mutbl) = match *recv_ty.data() { ty::Ref(region, _, mutbl) => (region, mutbl), _ => span_bug!(span, "overloaded_place: receiver is not a reference"), }; diff --git a/compiler/rustc_mir_build/src/thir/pattern/_match.rs b/compiler/rustc_mir_build/src/thir/pattern/_match.rs index 04de9a7a58dda..da89279f17bb8 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/_match.rs @@ -327,7 +327,7 @@ impl<'tcx> LiteralExpander<'tcx> { crty: Ty<'tcx>, ) -> ConstValue<'tcx> { debug!("fold_const_value_deref {:?} {:?} {:?}", val, rty, crty); - match (val, &crty.kind(), &rty.kind()) { + match (val, &crty.data(), &rty.data()) { // the easy case, deref a reference (ConstValue::Scalar(p), x, y) if x == y => { match p { @@ -368,13 +368,13 @@ impl<'tcx> LiteralExpander<'tcx> { impl<'tcx> PatternFolder<'tcx> for LiteralExpander<'tcx> { fn fold_pattern(&mut self, pat: &Pat<'tcx>) -> Pat<'tcx> { - debug!("fold_pattern {:?} {:?} {:?}", pat, pat.ty.kind(), pat.kind); - match (pat.ty.kind(), &*pat.kind) { + debug!("fold_pattern {:?} {:?} {:?}", pat, pat.ty.data(), pat.kind); + match (pat.ty.data(), &*pat.kind) { (&ty::Ref(_, rty, _), &PatKind::Constant { value: Const { val, ty: const_ty } }) if const_ty.is_ref() => { let crty = - if let ty::Ref(_, crty, _) = const_ty.kind() { crty } else { unreachable!() }; + if let ty::Ref(_, crty, _) = const_ty.data() { crty } else { unreachable!() }; if let ty::ConstKind::Value(val) = val { Pat { ty: pat.ty, @@ -776,7 +776,7 @@ impl<'a, 'tcx> MatchCheckCtxt<'a, 'tcx> { /// Returns whether the given type is an enum from another crate declared `#[non_exhaustive]`. crate fn is_foreign_non_exhaustive_enum(&self, ty: Ty<'tcx>) -> bool { - match ty.kind() { + match ty.data() { ty::Adt(def, ..) => { def.is_enum() && def.is_variant_list_non_exhaustive() && !def.did.is_local() } @@ -1057,14 +1057,14 @@ impl<'tcx> Constructor<'tcx> { let mut subpatterns = fields.all_patterns(); let pat = match self { - Single | Variant(_) => match ty.kind() { + Single | Variant(_) => match ty.data() { ty::Adt(..) | ty::Tuple(..) => { let subpatterns = subpatterns .enumerate() .map(|(i, p)| FieldPat { field: Field::new(i), pattern: p }) .collect(); - if let ty::Adt(adt, substs) = ty.kind() { + if let ty::Adt(adt, substs) = ty.data() { if adt.is_enum() { PatKind::Variant { adt_def: adt, @@ -1211,7 +1211,7 @@ impl<'p, 'tcx> Fields<'p, 'tcx> { let wildcard_from_ty = |ty| &*cx.pattern_arena.alloc(Pat::wildcard_from_ty(ty)); let ret = match constructor { - Single | Variant(_) => match ty.kind() { + Single | Variant(_) => match ty.data() { ty::Tuple(ref fs) => { Fields::wildcards_from_tys(cx, fs.into_iter().map(|ty| ty.expect_ty())) } @@ -1262,7 +1262,7 @@ impl<'p, 'tcx> Fields<'p, 'tcx> { } _ => Fields::empty(), }, - Slice(slice) => match *ty.kind() { + Slice(slice) => match *ty.data() { ty::Slice(ty) | ty::Array(ty, _) => { let arity = slice.arity(); Fields::wildcards_from_tys(cx, (0..arity).map(|_| ty)) @@ -1580,7 +1580,7 @@ fn all_constructors<'a, 'tcx>( .unwrap(), ) }; - match *pcx.ty.kind() { + match *pcx.ty.data() { ty::Bool => { [true, false].iter().map(|&b| ConstantValue(ty::Const::from_bool(cx.tcx, b))).collect() } @@ -1695,7 +1695,7 @@ struct IntRange<'tcx> { impl<'tcx> IntRange<'tcx> { #[inline] fn is_integral(ty: Ty<'_>) -> bool { - match ty.kind() { + match ty.data() { ty::Char | ty::Int(_) | ty::Uint(_) => true, _ => false, } @@ -1717,7 +1717,7 @@ impl<'tcx> IntRange<'tcx> { #[inline] fn integral_size_and_signed_bias(tcx: TyCtxt<'tcx>, ty: Ty<'_>) -> Option<(Size, u128)> { - match *ty.kind() { + match *ty.data() { ty::Char => Some((Size::from_bytes(4), 0)), ty::Int(ity) => { let size = Integer::from_attr(&tcx, SignedInt(ity)).size(); @@ -1818,7 +1818,7 @@ impl<'tcx> IntRange<'tcx> { // The return value of `signed_bias` should be XORed with an endpoint to encode/decode it. fn signed_bias(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> u128 { - match *ty.kind() { + match *ty.data() { ty::Int(ity) => { let bits = Integer::from_attr(&tcx, SignedInt(ity)).size().bits() as u128; 1u128 << (bits - 1) @@ -2231,7 +2231,7 @@ fn pat_constructor<'tcx>( if let Some(int_range) = IntRange::from_const(tcx, param_env, value, pat.span) { Some(IntRange(int_range)) } else { - match (value.val, &value.ty.kind()) { + match (value.val, &value.ty.data()) { (_, ty::Array(_, n)) => { let len = n.eval_usize(tcx, param_env); Some(Slice(Slice { array_len: Some(len), kind: FixedLen(len) })) @@ -2263,7 +2263,7 @@ fn pat_constructor<'tcx>( } PatKind::Array { ref prefix, ref slice, ref suffix } | PatKind::Slice { ref prefix, ref slice, ref suffix } => { - let array_len = match pat.ty.kind() { + let array_len = match pat.ty.data() { ty::Array(_, length) => Some(length.eval_usize(tcx, param_env)), ty::Slice(_) => None, _ => span_bug!(pat.span, "bad ty {:?} for slice pattern", pat.ty), @@ -2302,7 +2302,7 @@ fn slice_pat_covered_by_const<'tcx>( ) }; - let data: &[u8] = match (const_val_val, &const_val.ty.kind()) { + let data: &[u8] = match (const_val_val, &const_val.ty.data()) { (ConstValue::ByRef { offset, alloc, .. }, ty::Array(t, n)) => { assert_eq!(*t, tcx.types.u8); let n = n.eval_usize(tcx, param_env); @@ -2722,7 +2722,7 @@ fn specialize_one_pattern<'p, 'tcx>( // elements don't necessarily point to memory, they are usually // just integers. The only time they should be pointing to memory // is when they are subslices of nonzero slices. - let (alloc, offset, n, ty) = match value.ty.kind() { + let (alloc, offset, n, ty) = match value.ty.data() { ty::Array(t, n) => { let n = n.eval_usize(cx.tcx, cx.param_env); // Shortcut for `n == 0` where no matter what `alloc` and `offset` we produce, 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 047bf7db4c867..535dd5f4bfc71 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -289,7 +289,7 @@ fn check_for_bindings_named_same_as_variants(cx: &MatchVisitor<'_, '_>, pat: &Pa cx.typeck_results.extract_binding_mode(cx.tcx.sess, p.hir_id, p.span) { let pat_ty = cx.typeck_results.pat_ty(p).peel_refs(); - if let ty::Adt(edef, _) = pat_ty.kind() { + if let ty::Adt(edef, _) = pat_ty.data() { if edef.is_enum() && edef.variants.iter().any(|variant| { variant.ident == ident && variant.ctor_kind == CtorKind::Const @@ -442,7 +442,7 @@ fn check_exhaustive<'p, 'tcx>( // In the absence of the `exhaustive_patterns` feature, empty matches are not detected by // `is_useful` to exhaustively match uninhabited types, so we manually check here. if is_empty_match && !cx.tcx.features().exhaustive_patterns { - let scrutinee_is_visibly_uninhabited = match scrut_ty.kind() { + let scrutinee_is_visibly_uninhabited = match scrut_ty.data() { ty::Never => true, ty::Adt(def, _) => { def.is_enum() @@ -462,7 +462,7 @@ fn check_exhaustive<'p, 'tcx>( Err(err) => err, }; - let non_empty_enum = match scrut_ty.kind() { + let non_empty_enum = match scrut_ty.data() { ty::Adt(def, _) => def.is_enum() && !def.variants.is_empty(), _ => false, }; @@ -541,7 +541,7 @@ fn adt_defined_here( witnesses: &[super::Pat<'_>], ) { let ty = ty.peel_refs(); - if let ty::Adt(def, _) = ty.kind() { + if let ty::Adt(def, _) = ty.data() { if let Some(sp) = cx.tcx.hir().span_if_local(def.did) { err.span_label(sp, format!("`{}` defined here", ty)); } @@ -556,7 +556,7 @@ fn adt_defined_here( fn maybe_point_at_variant(ty: Ty<'_>, patterns: &[super::Pat<'_>]) -> Vec { let mut covered = vec![]; - if let ty::Adt(def, _) = ty.kind() { + if let ty::Adt(def, _) = ty.data() { // Don't point at variants that have already been covered due to other patterns to avoid // visual clutter. for pattern in patterns { 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 a203b3a142863..a727b844d1f77 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 @@ -261,7 +261,7 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> { .collect() }; - let kind = match cv.ty.kind() { + let kind = match cv.ty.data() { ty::Float(_) => { tcx.struct_span_lint_hir( lint::builtin::ILLEGAL_FLOATING_POINT_LITERAL_PATTERN, @@ -372,7 +372,7 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> { slice: None, suffix: Vec::new(), }, - ty::Ref(_, pointee_ty, ..) => match *pointee_ty.kind() { + ty::Ref(_, pointee_ty, ..) => match *pointee_ty.data() { // These are not allowed and will error elsewhere anyway. ty::Dynamic(..) => { self.saw_const_match_error.set(true); diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs index 718ed78889f09..30896d5053623 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs @@ -237,7 +237,7 @@ impl<'tcx> fmt::Display for Pat<'tcx> { Some(&adt_def.variants[variant_index]) } _ => { - if let ty::Adt(adt, _) = self.ty.kind() { + if let ty::Adt(adt, _) = self.ty.data() { if !adt.is_enum() { Some(&adt.variants[VariantIdx::new(0)]) } else { @@ -302,7 +302,7 @@ impl<'tcx> fmt::Display for Pat<'tcx> { Ok(()) } PatKind::Deref { ref subpattern } => { - match self.ty.kind() { + match self.ty.data() { ty::Adt(def, _) if def.is_box() => write!(f, "box ")?, ty::Ref(_, _, mutbl) => { write!(f, "&{}", mutbl.prefix_str())?; @@ -559,7 +559,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { } hir::PatKind::Tuple(ref pats, ddpos) => { - let tys = match ty.kind() { + let tys = match ty.data() { ty::Tuple(ref tys) => tys, _ => span_bug!(pat.span, "unexpected type for tuple pattern: {:?}", ty), }; @@ -588,7 +588,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { // x's type, which is &T, where we want T (the type being matched). let var_ty = ty; if let ty::BindByReference(_) = bm { - if let ty::Ref(_, rty, _) = ty.kind() { + if let ty::Ref(_, rty, _) = ty.data() { ty = rty; } else { bug!("`ref {}` has wrong type {}", ident, ty); @@ -608,7 +608,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { hir::PatKind::TupleStruct(ref qpath, ref pats, ddpos) => { let res = self.typeck_results.qpath_res(qpath, pat.hir_id); - let adt_def = match ty.kind() { + let adt_def = match ty.data() { ty::Adt(adt_def, _) => adt_def, _ => span_bug!(pat.span, "tuple struct pattern not applied to an ADT {:?}", ty), }; @@ -670,7 +670,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { let prefix = self.lower_patterns(prefix); let slice = self.lower_opt_pattern(slice); let suffix = self.lower_patterns(suffix); - match ty.kind() { + match ty.data() { // Matching a slice, `[T]`. ty::Slice(..) => PatKind::Slice { prefix, slice, suffix }, // Fixed-length array, `[T; len]`. @@ -704,7 +704,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { let enum_id = self.tcx.parent(variant_id).unwrap(); let adt_def = self.tcx.adt_def(enum_id); if adt_def.is_enum() { - let substs = match ty.kind() { + let substs = match ty.data() { ty::Adt(_, substs) | ty::FnDef(_, substs) => substs, ty::Error(_) => { // Avoid ICE (#50585) @@ -1058,7 +1058,7 @@ crate fn compare_const_vals<'tcx>( if let (Some(a), Some(b)) = (a_bits, b_bits) { use rustc_apfloat::Float; - return match *ty.kind() { + return match *ty.data() { ty::Float(ast::FloatTy::F32) => { let l = ::rustc_apfloat::ieee::Single::from_bits(a); let r = ::rustc_apfloat::ieee::Single::from_bits(b); @@ -1081,7 +1081,7 @@ crate fn compare_const_vals<'tcx>( }; } - if let ty::Str = ty.kind() { + if let ty::Str = ty.data() { if let ( ty::ConstKind::Value(a_val @ ConstValue::Slice { .. }), ty::ConstKind::Value(b_val @ ConstValue::Slice { .. }), diff --git a/compiler/rustc_mir_build/src/thir/util.rs b/compiler/rustc_mir_build/src/thir/util.rs index aea8667314f48..c63e256dd4490 100644 --- a/compiler/rustc_mir_build/src/thir/util.rs +++ b/compiler/rustc_mir_build/src/thir/util.rs @@ -17,7 +17,7 @@ crate trait UserAnnotatedTyHelpers<'tcx> { let mut user_ty = *user_provided_types.get(hir_id)?; debug!("user_subts_applied_to_ty_of_hir_id: user_ty={:?}", user_ty); let ty = self.typeck_results().node_type(hir_id); - match ty.kind() { + match ty.data() { ty::Adt(adt_def, ..) => { if let UserType::TypeOf(ref mut did, _) = &mut user_ty.value { *did = adt_def.did; diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index 98ded4189cf19..18293ebd77872 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -124,7 +124,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> { } fn handle_field_access(&mut self, lhs: &hir::Expr<'_>, hir_id: hir::HirId) { - match self.typeck_results().expr_ty_adjusted(lhs).kind() { + match self.typeck_results().expr_ty_adjusted(lhs).data() { ty::Adt(def, _) => { let index = self.tcx.field_index(hir_id, self.typeck_results()); self.insert_def_id(def.non_enum_variant().fields[index].did); @@ -140,7 +140,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> { res: Res, pats: &[hir::FieldPat<'_>], ) { - let variant = match self.typeck_results().node_type(lhs.hir_id).kind() { + let variant = match self.typeck_results().node_type(lhs.hir_id).data() { ty::Adt(adt, _) => adt.variant_of_res(res), _ => span_bug!(lhs.span, "non-ADT in struct pattern"), }; @@ -269,7 +269,7 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> { hir::ExprKind::Struct(ref qpath, ref fields, _) => { let res = self.typeck_results().qpath_res(qpath, expr.hir_id); self.handle_res(res); - if let ty::Adt(ref adt, _) = self.typeck_results().expr_ty(expr).kind() { + if let ty::Adt(ref adt, _) = self.typeck_results().expr_ty(expr).data() { self.mark_as_used_if_union(adt, fields); } } diff --git a/compiler/rustc_passes/src/intrinsicck.rs b/compiler/rustc_passes/src/intrinsicck.rs index 79f1c2b9da8da..99e7918d1802c 100644 --- a/compiler/rustc_passes/src/intrinsicck.rs +++ b/compiler/rustc_passes/src/intrinsicck.rs @@ -35,7 +35,7 @@ struct ExprVisitor<'tcx> { /// 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 (def, substs) = match *ty.kind() { + let (def, substs) = match *ty.data() { ty::Adt(def, substs) => (def, substs), _ => return ty, }; @@ -81,7 +81,7 @@ impl ExprVisitor<'tcx> { // Special-case transmutting from `typeof(function)` and // `Option` to present a clearer error. let from = unpack_option_like(self.tcx, from); - if let (&ty::FnDef(..), SizeSkeleton::Known(size_to)) = (from.kind(), sk_to) { + if let (&ty::FnDef(..), SizeSkeleton::Known(size_to)) = (from.data(), sk_to) { if size_to == Pointer.size(&self.tcx) { struct_span_err!(self.tcx.sess, span, E0591, "can't transmute zero-sized type") .note(&format!("source type: {}", from)) @@ -127,7 +127,7 @@ impl ExprVisitor<'tcx> { if ty.is_sized(self.tcx.at(DUMMY_SP), self.param_env) { return true; } - if let ty::Foreign(..) = ty.kind() { + if let ty::Foreign(..) = ty.data() { return true; } false @@ -149,7 +149,7 @@ impl ExprVisitor<'tcx> { 64 => InlineAsmType::I64, _ => unreachable!(), }; - let asm_ty = match *ty.kind() { + let asm_ty = match *ty.data() { ty::Never | ty::Error(_) => return None, ty::Int(IntTy::I8) | ty::Uint(UintTy::U8) => Some(InlineAsmType::I8), ty::Int(IntTy::I16) | ty::Uint(UintTy::U16) => Some(InlineAsmType::I16), @@ -166,7 +166,7 @@ impl ExprVisitor<'tcx> { ty::Adt(adt, substs) if adt.repr.simd() => { let fields = &adt.non_enum_variant().fields; let elem_ty = fields[0].ty(self.tcx, substs); - match elem_ty.kind() { + match elem_ty.data() { ty::Never | ty::Error(_) => return None, ty::Int(IntTy::I8) | ty::Uint(UintTy::U8) => { Some(InlineAsmType::VecI8(fields.len() as u64)) @@ -374,7 +374,7 @@ impl ExprVisitor<'tcx> { } hir::InlineAsmOperand::Const { ref expr } => { let ty = self.typeck_results.expr_ty_adjusted(expr); - match ty.kind() { + match ty.data() { ty::Int(_) | ty::Uint(_) | ty::Float(_) => {} _ => { let msg = diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs index e8b97d7dc7d50..79ae5883862f9 100644 --- a/compiler/rustc_passes/src/liveness.rs +++ b/compiler/rustc_passes/src/liveness.rs @@ -876,7 +876,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { } let ty = self.typeck_results.node_type(hir_id); - match ty.kind() { + match ty.data() { ty::Closure(_def_id, substs) => match substs.as_closure().kind() { ty::ClosureKind::Fn => {} ty::ClosureKind::FnMut => {} diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 8f93bce6e9923..69a781f687ceb 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -127,7 +127,7 @@ where fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool { let tcx = self.def_id_visitor.tcx(); // InternalSubsts are not visited here because they are visited below in `super_visit_with`. - match *ty.kind() { + match *ty.data() { ty::Adt(&ty::AdtDef { did: def_id, .. }, ..) | ty::Foreign(def_id) | ty::FnDef(def_id, ..) @@ -142,7 +142,7 @@ where // Default type visitor doesn't visit signatures of fn types. // Something like `fn() -> Priv {my_func}` is considered a private type even if // `my_func` is public, so we need to visit signatures. - if let ty::FnDef(..) = ty.kind() { + if let ty::FnDef(..) = ty.data() { if tcx.fn_sig(def_id).visit_with(self) { return true; } diff --git a/compiler/rustc_save_analysis/src/lib.rs b/compiler/rustc_save_analysis/src/lib.rs index f6434689fec01..ba3ef9a28e4a3 100644 --- a/compiler/rustc_save_analysis/src/lib.rs +++ b/compiler/rustc_save_analysis/src/lib.rs @@ -524,12 +524,12 @@ impl<'tcx> SaveContext<'tcx> { pub fn get_expr_data(&self, expr: &hir::Expr<'_>) -> Option { let ty = self.typeck_results().expr_ty_adjusted_opt(expr)?; - if matches!(ty.kind(), ty::Error(_)) { + if matches!(ty.data(), ty::Error(_)) { return None; } match expr.kind { hir::ExprKind::Field(ref sub_ex, ident) => { - match self.typeck_results().expr_ty_adjusted(&sub_ex).kind() { + match self.typeck_results().expr_ty_adjusted(&sub_ex).data() { ty::Adt(def, _) if !def.is_enum() => { let variant = &def.non_enum_variant(); filter!(self.span_utils, ident.span); @@ -551,7 +551,7 @@ impl<'tcx> SaveContext<'tcx> { } } } - hir::ExprKind::Struct(qpath, ..) => match ty.kind() { + hir::ExprKind::Struct(qpath, ..) => match ty.data() { ty::Adt(def, _) => { let sub_span = qpath.last_segment_span(); filter!(self.span_utils, sub_span); diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 223a0758f008b..b049ad2a0f6c9 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -198,7 +198,7 @@ symbols! { Try, Ty, TyCtxt, - TyKind, + TyData, Unknown, Vec, Yield, diff --git a/compiler/rustc_symbol_mangling/src/legacy.rs b/compiler/rustc_symbol_mangling/src/legacy.rs index b96e318bd3ea1..138ef08c6e466 100644 --- a/compiler/rustc_symbol_mangling/src/legacy.rs +++ b/compiler/rustc_symbol_mangling/src/legacy.rs @@ -110,7 +110,7 @@ fn get_symbol_hash<'tcx>( // If this is a function, we hash the signature as well. // This is not *strictly* needed, but it may help in some // situations, see the `run-make/a-b-a-linker-guard` test. - if let ty::FnDef(..) = item_type.kind() { + if let ty::FnDef(..) = item_type.data() { item_type.fn_sig(tcx).hash_stable(&mut hcx, &mut hasher); } @@ -210,7 +210,7 @@ impl Printer<'tcx> for SymbolPrinter<'tcx> { } fn print_type(self, ty: Ty<'tcx>) -> Result { - match *ty.kind() { + match *ty.data() { // Print all nominal types as paths (unlike `pretty_print_type`). ty::FnDef(def_id, substs) | ty::Opaque(def_id, substs) @@ -258,7 +258,7 @@ impl Printer<'tcx> for SymbolPrinter<'tcx> { ) -> Result { // Similar to `pretty_path_qualified`, but for the other // types that are printed as paths (see `print_type` above). - match self_ty.kind() { + match self_ty.data() { ty::FnDef(..) | ty::Opaque(..) | ty::Projection(_) diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index da9c93143bfb3..079ece550167b 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -320,7 +320,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> { fn print_type(mut self, ty: Ty<'tcx>) -> Result { // Basic types, never cached (single-character). - let basic_type = match ty.kind() { + let basic_type = match ty.data() { ty::Bool => "b", ty::Char => "c", ty::Str => "e", @@ -356,7 +356,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> { } let start = self.out.len(); - match *ty.kind() { + match *ty.data() { // Basic types, handled above. ty::Bool | ty::Char | ty::Str | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Never => { unreachable!() @@ -502,7 +502,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> { } let start = self.out.len(); - match ct.ty.kind() { + match ct.ty.data() { ty::Uint(_) => {} ty::Bool => {} _ => { diff --git a/compiler/rustc_trait_selection/src/opaque_types.rs b/compiler/rustc_trait_selection/src/opaque_types.rs index 610c6fd7e35f8..482d95f773a07 100644 --- a/compiler/rustc_trait_selection/src/opaque_types.rs +++ b/compiler/rustc_trait_selection/src/opaque_types.rs @@ -713,7 +713,7 @@ where return false; // keep visiting } - match ty.kind() { + match ty.data() { ty::Closure(_, ref substs) => { // Skip lifetime parameters of the enclosing item(s) @@ -867,7 +867,7 @@ impl TypeFolder<'tcx> for ReverseMapper<'tcx> { } fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { - match *ty.kind() { + match *ty.data() { ty::Closure(def_id, substs) => { // I am a horrible monster and I pray for death. When // we encounter a closure here, it is always a closure @@ -1004,7 +1004,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> { ty_op: |ty| { if ty.references_error() { return tcx.ty_error(); - } else if let ty::Opaque(def_id, substs) = ty.kind() { + } else if let ty::Opaque(def_id, substs) = ty.data() { // Check that this is `impl Trait` type is // declared by `parent_def_id` -- i.e., one whose // value we are inferring. At present, this is diff --git a/compiler/rustc_trait_selection/src/traits/auto_trait.rs b/compiler/rustc_trait_selection/src/traits/auto_trait.rs index e40067202e112..3d94c0b8e0dfe 100644 --- a/compiler/rustc_trait_selection/src/traits/auto_trait.rs +++ b/compiler/rustc_trait_selection/src/traits/auto_trait.rs @@ -596,7 +596,7 @@ impl AutoTraitFinder<'tcx> { } pub fn is_of_param(&self, ty: Ty<'_>) -> bool { - match ty.kind() { + match ty.data() { ty::Param(_) => true, ty::Projection(p) => self.is_of_param(p.self_ty()), _ => false, @@ -604,7 +604,7 @@ impl AutoTraitFinder<'tcx> { } fn is_self_referential_projection(&self, p: ty::PolyProjectionPredicate<'_>) -> bool { - match *p.ty().skip_binder().kind() { + match *p.ty().skip_binder().data() { ty::Projection(proj) if proj == p.skip_binder().projection_ty => true, _ => false, } diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs index c53c65c00b769..2144d65ce3996 100644 --- a/compiler/rustc_trait_selection/src/traits/coherence.rs +++ b/compiler/rustc_trait_selection/src/traits/coherence.rs @@ -412,7 +412,7 @@ fn orphan_check_trait_ref<'tcx>( if non_local_tys.is_empty() { debug!("orphan_check_trait_ref: ty_is_local `{:?}`", input_ty); return Ok(()); - } else if let ty::Param(_) = input_ty.kind() { + } else if let ty::Param(_) = input_ty.data() { debug!("orphan_check_trait_ref: uncovered ty: `{:?}`", input_ty); let local_type = trait_ref .substs @@ -467,7 +467,7 @@ fn fundamental_ty_inner_tys( tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, ) -> Option>> { - let (first_ty, rest_tys) = match *ty.kind() { + let (first_ty, rest_tys) = match *ty.data() { ty::Ref(_, ty, _) => (ty, ty::subst::InternalSubsts::empty().types()), ty::Adt(def, substs) if def.is_fundamental() => { let mut types = substs.types(); @@ -504,7 +504,7 @@ fn def_id_is_local(def_id: DefId, in_crate: InCrate) -> bool { fn ty_is_local_constructor(ty: Ty<'_>, in_crate: InCrate) -> bool { debug!("ty_is_local_constructor({:?})", ty); - match *ty.kind() { + match *ty.data() { ty::Bool | ty::Char | ty::Int(..) diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index 05e3ed3435113..db3ec62995639 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -381,7 +381,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { // If it has a custom `#[rustc_on_unimplemented]` // error message, let's display it as the label! err.span_label(span, s.as_str()); - if !matches!(trait_ref.skip_binder().self_ty().kind(), ty::Param(_)) { + if !matches!(trait_ref.skip_binder().self_ty().data(), ty::Param(_)) { // When the self type is a type param We don't need to "the trait // `std::marker::Sized` is not implemented for `T`" as we will point // at the type param with a label to suggest constraining it. @@ -446,7 +446,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { ] .contains(&Some(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().data() { !self.tcx.codegen_fn_attrs(def_id).target_features.is_empty() } else { @@ -683,7 +683,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { None => return, }; - let found_did = match *found_trait_ty.kind() { + let found_did = match *found_trait_ty.data() { ty::Closure(did, _) | ty::Foreign(did) | ty::FnDef(did, _) => Some(did), ty::Adt(def, _) => Some(def.did), _ => None, @@ -701,13 +701,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { self.reported_closure_mismatch.borrow_mut().insert((span, found_span)); - let found = match found_trait_ref.skip_binder().substs.type_at(1).kind() { + let found = match found_trait_ref.skip_binder().substs.type_at(1).data() { ty::Tuple(ref tys) => vec![ArgKind::empty(); tys.len()], _ => vec![ArgKind::empty()], }; let expected_ty = expected_trait_ref.skip_binder().substs.type_at(1); - let expected = match expected_ty.kind() { + let expected = match expected_ty.data() { ty::Tuple(ref tys) => tys .iter() .map(|t| ArgKind::from_expected_ty(t.expect_ty(), Some(span))) @@ -1241,7 +1241,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> { /// returns the fuzzy category of a given type, or None /// if the type can be equated to any type. fn type_category(t: Ty<'_>) -> Option { - match t.kind() { + match t.data() { ty::Bool => Some(0), ty::Char => Some(1), ty::Str => Some(2), @@ -1270,7 +1270,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> { } match (type_category(a), type_category(b)) { - (Some(cat_a), Some(cat_b)) => match (a.kind(), b.kind()) { + (Some(cat_a), Some(cat_b)) => match (a.data(), b.data()) { (&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => def_a == def_b, _ => cat_a == cat_b, }, @@ -1459,7 +1459,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> { ty::PredicateAtom::Trait(data, _) => { let trait_ref = ty::Binder::bind(data.trait_ref); let self_ty = trait_ref.skip_binder().self_ty(); - debug!("self_ty {:?} {:?} trait_ref {:?}", self_ty, self_ty.kind(), trait_ref); + debug!("self_ty {:?} {:?} trait_ref {:?}", self_ty, self_ty.data(), trait_ref); if predicate.references_error() { return; @@ -1648,7 +1648,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> { } fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { - if let ty::Param(ty::ParamTy { name, .. }) = *ty.kind() { + if let ty::Param(ty::ParamTy { name, .. }) = *ty.data() { let infcx = self.infcx; self.var_map.entry(ty).or_insert_with(|| { infcx.next_ty_var(TypeVariableOrigin { @@ -1922,7 +1922,7 @@ impl ArgKind { /// Creates an `ArgKind` from the expected type of an /// argument. It has no name (`_`) and an optional source span. pub fn from_expected_ty(t: Ty<'_>, span: Option) -> ArgKind { - match t.kind() { + match t.data() { ty::Tuple(tys) => ArgKind::Tuple( span, tys.iter().map(|ty| ("_".to_owned(), ty.to_string())).collect::>(), diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs index 0f5aad5af1229..64a589df5862e 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs @@ -194,7 +194,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { flags.push((sym::_Self, Some("{integral}".to_owned()))); } - if let ty::Array(aty, len) = self_ty.kind() { + if let ty::Array(aty, len) = self_ty.data() { flags.push((sym::_Self, Some("[]".to_owned()))); flags.push((sym::_Self, Some(format!("[{}]", aty)))); if let Some(def) = aty.ty_adt_def() { @@ -218,7 +218,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { } } } - if let ty::Dynamic(traits, _) = self_ty.kind() { + if let ty::Dynamic(traits, _) = self_ty.data() { for t in traits.skip_binder() { if let ty::ExistentialPredicate::Trait(trait_ref) = t { flags.push((sym::_Self, Some(self.tcx.def_path_str(trait_ref.def_id)))) 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 967374ffdc2c0..c027dfb4c169d 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -207,7 +207,7 @@ fn suggest_restriction( } // Given `fn foo(t: impl Trait)` where `Trait` requires assoc type `A`... if let Some((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().data() { // Shenanigans to get the `Trait` from the `impl Trait`. ty::Param(param) => { // `fn foo(t: impl Trait)` @@ -323,7 +323,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { body_id: hir::HirId, ) { let self_ty = trait_ref.skip_binder().self_ty(); - let (param_ty, projection) = match self_ty.kind() { + let (param_ty, projection) = match self_ty.data() { ty::Param(_) => (true, None), ty::Projection(projection) => (false, Some(projection)), _ => return, @@ -482,7 +482,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { None => return, }; - if let ty::Ref(region, base_ty, mutbl) = *real_ty.kind() { + if let ty::Ref(region, base_ty, mutbl) = *real_ty.data() { let mut autoderef = Autoderef::new(self, param_env, body_id, span, base_ty, span); if let Some(steps) = autoderef.find_map(|(ty, steps)| { // Re-add the `&` @@ -563,7 +563,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { Some(ty) => ty, }; - let (def_id, output_ty, callable) = match *self_ty.kind() { + let (def_id, output_ty, callable) = match *self_ty.data() { ty::Closure(def_id, substs) => (def_id, substs.as_closure().sig().output(), "closure"), ty::FnDef(def_id, _) => (def_id, self_ty.fn_sig(self.tcx).output(), "function"), _ => return, @@ -751,7 +751,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { }; for refs_remaining in 0..refs_number { - if let ty::Ref(_, inner_ty, _) = suggested_ty.kind() { + if let ty::Ref(_, inner_ty, _) = suggested_ty.data() { suggested_ty = inner_ty; let new_obligation = self.mk_trait_obligation_with_new_self_ty( @@ -814,7 +814,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { return; } - if let ty::Ref(region, t_type, mutability) = *trait_ref.skip_binder().self_ty().kind() { + if let ty::Ref(region, t_type, mutability) = *trait_ref.skip_binder().self_ty().data() { if region.is_late_bound() || t_type.has_escaping_bound_vars() { // Avoid debug assertion in `mk_obligation_for_def_id`. // @@ -871,7 +871,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { trait_ref: &ty::Binder>, ) { let is_empty_tuple = - |ty: ty::Binder>| *ty.skip_binder().kind() == ty::Tuple(ty::List::empty()); + |ty: ty::Binder>| *ty.skip_binder().data() == ty::Tuple(ty::List::empty()); let hir = self.tcx.hir(); let parent_node = hir.get_parent_node(obligation.cause.body_id); @@ -941,7 +941,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { let body = hir.body(*body_id); let trait_ref = self.resolve_vars_if_possible(trait_ref); let ty = trait_ref.skip_binder().self_ty(); - let is_object_safe = match ty.kind() { + let is_object_safe = match ty.data() { ty::Dynamic(predicates, _) => { // If the `dyn Trait` is not object safe, do not suggest `Box`. predicates @@ -982,11 +982,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { ty| { let ty = self.resolve_vars_if_possible(&ty); same &= - !matches!(ty.kind(), ty::Error(_)) + !matches!(ty.data(), ty::Error(_)) && last_ty.map_or(true, |last_ty| { // FIXME: ideally we would use `can_coerce` here instead, but `typeck` comes // *after* in the dependency graph. - match (ty.kind(), last_ty.kind()) { + match (ty.data(), last_ty.data()) { (Infer(InferTy::IntVar(_)), Infer(InferTy::IntVar(_))) | (Infer(InferTy::FloatVar(_)), Infer(InferTy::FloatVar(_))) | (Infer(InferTy::FreshIntTy(_)), Infer(InferTy::FreshIntTy(_))) @@ -997,12 +997,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { _ => ty == last_ty, } }); - (Some(ty), same, only_never_return && matches!(ty.kind(), ty::Never)) + (Some(ty), same, only_never_return && matches!(ty.data(), ty::Never)) }, ); let all_returns_conform_to_trait = if let Some(ty_ret_ty) = typeck_results.node_type_opt(ret_ty.hir_id) { - match ty_ret_ty.kind() { + match ty_ret_ty.data() { ty::Dynamic(predicates, _) => { let cause = ObligationCause::misc(ret_ty.span, ret_ty.hir_id); let param_env = ty::ParamEnv::empty(); @@ -1151,7 +1151,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { trait_ref: ty::TraitRef<'tcx>, ) -> String { let inputs = trait_ref.substs.type_at(1); - let sig = if let ty::Tuple(inputs) = inputs.kind() { + let sig = if let ty::Tuple(inputs) = inputs.data() { tcx.mk_fn_sig( inputs.iter().map(|k| k.expect_ty()), tcx.mk_ty_infer(ty::TyVar(ty::TyVid { index: 0 })), @@ -1318,10 +1318,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { "maybe_note_obligation_cause_for_async_await: \ parent_trait_ref={:?} self_ty.kind={:?}", derived_obligation.parent_trait_ref, - ty.kind() + ty.data() ); - match *ty.kind() { + match *ty.data() { ty::Generator(did, ..) => { generator = generator.or(Some(did)); outer_generator = Some(did); diff --git a/compiler/rustc_trait_selection/src/traits/misc.rs b/compiler/rustc_trait_selection/src/traits/misc.rs index e23f5a583b23b..50df39e3c483c 100644 --- a/compiler/rustc_trait_selection/src/traits/misc.rs +++ b/compiler/rustc_trait_selection/src/traits/misc.rs @@ -23,7 +23,7 @@ pub fn can_type_implement_copy( ) -> Result<(), CopyImplementationError<'tcx>> { // FIXME: (@jroesch) float this code up tcx.infer_ctxt().enter(|infcx| { - let (adt, substs) = match self_type.kind() { + let (adt, substs) = match self_type.data() { // These types used to have a builtin impl. // Now libcore provides that impl. ty::Uint(_) diff --git a/compiler/rustc_trait_selection/src/traits/object_safety.rs b/compiler/rustc_trait_selection/src/traits/object_safety.rs index 0e43f1655ddb2..addc0b8cc1b0c 100644 --- a/compiler/rustc_trait_selection/src/traits/object_safety.rs +++ b/compiler/rustc_trait_selection/src/traits/object_safety.rs @@ -753,7 +753,7 @@ fn contains_illegal_self_type_reference<'tcx>( impl<'tcx> TypeVisitor<'tcx> for IllegalSelfTypeVisitor<'tcx> { fn visit_ty(&mut self, t: Ty<'tcx>) -> bool { - match t.kind() { + match t.data() { ty::Param(_) => t == self.self_ty, ty::Projection(ref data) => { // This is a projected type `::X`. diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index de42aa0e6b764..fa16ae69fea03 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -346,7 +346,7 @@ impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> { // should occur eventually). let ty = ty.super_fold_with(self); - match *ty.kind() { + match *ty.data() { ty::Opaque(def_id, substs) => { // Only normalize `impl Trait` after type-checking, usually in codegen. match self.param_env.reveal() { @@ -872,7 +872,7 @@ fn assemble_candidates_from_trait_def<'cx, 'tcx>( let tcx = selcx.tcx(); // Check whether the self-type is itself a projection. // If so, extract what we know from the trait and try to come up with a good answer. - let bounds = match *obligation_trait_ref.self_ty().kind() { + let bounds = match *obligation_trait_ref.self_ty().data() { ty::Projection(ref data) => tcx.item_bounds(data.item_def_id).subst(tcx, data.substs), ty::Opaque(def_id, substs) => tcx.item_bounds(def_id).subst(tcx, substs), ty::Infer(ty::TyVar(_)) => { @@ -916,7 +916,7 @@ fn assemble_candidates_from_object_ty<'cx, 'tcx>( let self_ty = obligation_trait_ref.self_ty(); let object_ty = selcx.infcx().shallow_resolve(self_ty); - let data = match object_ty.kind() { + let data = match object_ty.data() { ty::Dynamic(data, ..) => data, ty::Infer(ty::TyVar(_)) => { // If the self-type is an inference variable, then it MAY wind up @@ -1082,7 +1082,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>( // Any type with multiple potential discriminant types is therefore not eligible. let self_ty = selcx.infcx().shallow_resolve(obligation.predicate.self_ty()); - match self_ty.kind() { + match self_ty.data() { ty::Bool | ty::Char | ty::Int(_) 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 424b3bd67ffad..1c8eab5bbf95f 100644 --- a/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs +++ b/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs @@ -82,7 +82,7 @@ impl<'cx, 'tcx> AtExt<'tcx> for At<'cx, 'tcx> { /// Note also that `needs_drop` requires a "global" type (i.e., one /// with erased regions), but this function does not. pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { - match ty.kind() { + match ty.data() { // None of these types have a destructor and hence they do not // require anything in particular to outlive the dtor's // execution. diff --git a/compiler/rustc_trait_selection/src/traits/query/normalize.rs b/compiler/rustc_trait_selection/src/traits/query/normalize.rs index bdbf45f78a23b..b83acf846ef09 100644 --- a/compiler/rustc_trait_selection/src/traits/query/normalize.rs +++ b/compiler/rustc_trait_selection/src/traits/query/normalize.rs @@ -107,7 +107,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> { } let ty = ty.super_fold_with(self); - let res = (|| match *ty.kind() { + let res = (|| match *ty.data() { ty::Opaque(def_id, substs) => { // Only normalize `impl Trait` after type-checking, usually in codegen. match self.param_env.reveal() { 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 038ba431c47d3..a5931c5268094 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -312,7 +312,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // Before we go into the whole placeholder thing, just // quickly check if the self-type is a projection at all. - match obligation.predicate.skip_binder().trait_ref.self_ty().kind() { + match obligation.predicate.skip_binder().trait_ref.self_ty().data() { ty::Projection(_) | ty::Opaque(..) => {} ty::Infer(ty::TyVar(_)) => { span_bug!( @@ -381,7 +381,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.data() { ty::Generator(..) => { debug!( "assemble_generator_candidates: self_ty={:?} obligation={:?}", @@ -421,7 +421,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // Okay to skip binder because the substs on closure types never // touch bound regions, they just capture the in-scope // type/region parameters - match *obligation.self_ty().skip_binder().kind() { + match *obligation.self_ty().skip_binder().data() { ty::Closure(_, closure_substs) => { debug!("assemble_unboxed_candidates: kind={:?} obligation={:?}", kind, obligation); match self.infcx.closure_kind(closure_substs) { @@ -460,7 +460,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.data() { ty::Infer(ty::TyVar(_)) => { debug!("assemble_fn_pointer_candidates: ambiguous self-type"); candidates.ambiguous = true; // Could wind up being a fn() type. @@ -542,7 +542,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.data() { ty::Dynamic(..) => { // For object types, we don't know what the closed // over types are. This means we conservatively @@ -613,7 +613,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // self-ty here doesn't escape this probe, so just erase // any LBR. let self_ty = self.tcx().erase_late_bound_regions(&obligation.self_ty()); - let poly_trait_ref = match self_ty.kind() { + let poly_trait_ref = match self_ty.data() { ty::Dynamic(ref data, ..) => { if data.auto_traits().any(|did| did == obligation.predicate.def_id()) { debug!( @@ -699,7 +699,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { debug!("assemble_candidates_for_unsizing(source={:?}, target={:?})", source, target); - let may_apply = match (source.kind(), target.kind()) { + let may_apply = match (source.data(), target.data()) { // Trait+Kx+'a -> Trait+Ky+'b (upcasts). (&ty::Dynamic(ref data_a, ..), &ty::Dynamic(ref data_b, ..)) => { // Upcasts permit two things: diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index 96f0bedf6f1a7..8432c49fb72fc 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -129,7 +129,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let placeholder_trait_predicate = self.infcx().replace_bound_vars_with_placeholders(&trait_predicate); let placeholder_self_ty = placeholder_trait_predicate.self_ty(); - let (def_id, substs) = match *placeholder_self_ty.kind() { + let (def_id, substs) = match *placeholder_self_ty.data() { ty::Projection(proj) => (proj.item_def_id, proj.substs), ty::Opaque(def_id, substs) => (def_id, substs), _ => bug!("projection candidate for unexpected type: {:?}", placeholder_self_ty), @@ -163,7 +163,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { }), ); - if let ty::Projection(..) = placeholder_self_ty.kind() { + if let ty::Projection(..) = placeholder_self_ty.data() { for predicate in tcx.predicates_of(def_id).instantiate_own(tcx, substs).predicates { let normalized = normalize_with_depth_to( self, @@ -386,7 +386,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { self.infcx.replace_bound_vars_with_placeholders(&obligation.predicate); let self_ty = self.infcx.shallow_resolve(trait_predicate.self_ty()); let obligation_trait_ref = ty::Binder::dummy(trait_predicate.trait_ref); - let data = match self_ty.kind() { + let data = match self_ty.data() { ty::Dynamic(data, ..) => { self.infcx .replace_bound_vars_with_fresh_vars( @@ -589,7 +589,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // touch bound regions, they just capture the in-scope // type/region parameters. let self_ty = self.infcx.shallow_resolve(obligation.self_ty().skip_binder()); - let (generator_def_id, substs) = match *self_ty.kind() { + let (generator_def_id, substs) = match *self_ty.data() { ty::Generator(id, substs, _) => (id, substs), _ => bug!("closure candidate for non-closure {:?}", obligation), }; @@ -638,7 +638,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // touch bound regions, they just capture the in-scope // type/region parameters. let self_ty = self.infcx.shallow_resolve(obligation.self_ty().skip_binder()); - let (closure_def_id, substs) = match *self_ty.kind() { + let (closure_def_id, substs) = match *self_ty.data() { ty::Closure(id, substs) => (id, substs), _ => bug!("closure candidate for non-closure {:?}", obligation), }; @@ -734,7 +734,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { debug!("confirm_builtin_unsize_candidate(source={:?}, target={:?})", source, target); let mut nested = vec![]; - match (source.kind(), target.kind()) { + match (source.data(), target.data()) { // Trait+Kx+'a -> Trait+Ky+'b (upcasts). (&ty::Dynamic(ref data_a, r_a), &ty::Dynamic(ref data_b, r_b)) => { // See `assemble_candidates_for_unsizing` for more info. @@ -833,7 +833,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // `Struct` -> `Struct` (&ty::Adt(def, substs_a), &ty::Adt(_, substs_b)) => { let maybe_unsizing_param_idx = |arg: GenericArg<'tcx>| match arg.unpack() { - GenericArgKind::Type(ty) => match ty.kind() { + GenericArgKind::Type(ty) => match ty.data() { ty::Param(p) => Some(p.index), _ => None, }, diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index a142ba58a6904..3331f5589a404 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -1178,7 +1178,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { ); let tcx = self.infcx.tcx; - let (def_id, substs) = match *placeholder_trait_predicate.trait_ref.self_ty().kind() { + let (def_id, substs) = match *placeholder_trait_predicate.trait_ref.self_ty().data() { ty::Projection(ref data) => (data.item_def_id, data.substs), ty::Opaque(def_id, substs) => (def_id, substs), _ => { @@ -1537,7 +1537,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // NOTE: binder moved to (*) let self_ty = self.infcx.shallow_resolve(obligation.predicate.skip_binder().self_ty()); - match self_ty.kind() { + match self_ty.data() { ty::Infer(ty::IntVar(_) | ty::FloatVar(_)) | ty::Uint(_) | ty::Int(_) @@ -1592,7 +1592,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { use self::BuiltinImplConditions::{Ambiguous, None, Where}; - match self_ty.kind() { + match self_ty.data() { ty::Infer(ty::IntVar(_)) | ty::Infer(ty::FloatVar(_)) | ty::FnDef(..) @@ -1666,7 +1666,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { /// Zed where enum Zed { A(T), B(u32) } -> [i32, u32] /// ``` fn constituent_types_for_ty(&self, t: Ty<'tcx>) -> Vec> { - match *t.kind() { + match *t.data() { ty::Uint(_) | ty::Int(_) | ty::Bool diff --git a/compiler/rustc_trait_selection/src/traits/structural_match.rs b/compiler/rustc_trait_selection/src/traits/structural_match.rs index 4f7fa2c3988ff..3821c44e51919 100644 --- a/compiler/rustc_trait_selection/src/traits/structural_match.rs +++ b/compiler/rustc_trait_selection/src/traits/structural_match.rs @@ -137,7 +137,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> { fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool { debug!("Search visiting ty: {:?}", ty); - let (adt_def, substs) = match *ty.kind() { + let (adt_def, substs) = match *ty.data() { ty::Adt(adt_def, substs) => (adt_def, substs), ty::Param(_) => { self.found = Some(NonStructuralMatchTy::Param); diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index d66bfd482069d..0934eae64ecc3 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -27,7 +27,7 @@ pub fn obligations<'a, 'tcx>( // Handle the "livelock" case (see comment above) by bailing out if necessary. let arg = match arg.unpack() { GenericArgKind::Type(ty) => { - match ty.kind() { + match ty.data() { ty::Infer(ty::TyVar(_)) => { let resolved_ty = infcx.shallow_resolve(ty); if resolved_ty == ty { @@ -216,7 +216,7 @@ fn extend_cause_with_original_assoc_item_obligation<'tcx>( // projection coming from another associated type. See // `src/test/ui/associated-types/point-at-type-on-obligation-failure.rs` and // `traits-assoc-type-in-supertrait-bad.rs`. - if let ty::Projection(projection_ty) = proj.ty.kind() { + if let ty::Projection(projection_ty) = proj.ty.data() { let trait_assoc_item = tcx.associated_item(projection_ty.item_def_id); if let Some(impl_item_span) = items.iter().find(|item| item.ident == trait_assoc_item.ident).map(fix_span) @@ -229,7 +229,7 @@ fn extend_cause_with_original_assoc_item_obligation<'tcx>( // An associated item obligation born out of the `trait` failed to be met. An example // can be seen in `ui/associated-types/point-at-type-on-obligation-failure-2.rs`. debug!("extended_cause_with_original_assoc_item_obligation trait proj {:?}", pred); - if let ty::Projection(ty::ProjectionTy { item_def_id, .. }) = *pred.self_ty().kind() { + if let ty::Projection(ty::ProjectionTy { item_def_id, .. }) = *pred.self_ty().data() { if let Some(impl_item_span) = trait_assoc_items .find(|i| i.def_id == item_def_id) .and_then(|trait_assoc_item| { @@ -477,7 +477,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { } }; - match *ty.kind() { + match *ty.data() { ty::Bool | ty::Char | ty::Int(..) @@ -657,7 +657,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { // prevention, which happens before this can be reached. ty::Infer(_) => { let ty = self.infcx.shallow_resolve(ty); - if let ty::Infer(ty::TyVar(_)) = ty.kind() { + if let ty::Infer(ty::TyVar(_)) = ty.data() { // Not yet resolved, but we've made progress. let cause = self.cause(traits::MiscObligation); self.out.push(traits::Obligation::with_depth( diff --git a/compiler/rustc_traits/src/chalk/db.rs b/compiler/rustc_traits/src/chalk/db.rs index 3368c5b769902..02763bca10709 100644 --- a/compiler/rustc_traits/src/chalk/db.rs +++ b/compiler/rustc_traits/src/chalk/db.rs @@ -334,7 +334,7 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t for impl_def_id in all_impls { let trait_ref = self.interner.tcx.impl_trait_ref(impl_def_id).unwrap(); let self_ty = trait_ref.self_ty(); - let provides = match (self_ty.kind(), app_ty.name) { + let provides = match (self_ty.data(), app_ty.name) { (&ty::Adt(impl_adt_def, ..), Adt(id)) => impl_adt_def.did == id.0.did, (_, AssociatedType(_ty_id)) => { // FIXME(chalk): See https://github.com/rust-lang/rust/pull/77152#discussion_r494484774 diff --git a/compiler/rustc_traits/src/chalk/lowering.rs b/compiler/rustc_traits/src/chalk/lowering.rs index 391251b6fa554..3465fba7db383 100644 --- a/compiler/rustc_traits/src/chalk/lowering.rs +++ b/compiler/rustc_traits/src/chalk/lowering.rs @@ -35,7 +35,7 @@ use rustc_middle::traits::{ChalkEnvironmentAndGoal, ChalkRustInterner as RustInt use rustc_middle::ty::fold::TypeFolder; use rustc_middle::ty::subst::{GenericArg, GenericArgKind, SubstsRef}; use rustc_middle::ty::{ - self, Binder, BoundRegion, Region, RegionKind, Ty, TyCtxt, TyKind, TypeFoldable, TypeVisitor, + self, Binder, BoundRegion, Region, RegionKind, Ty, TyCtxt, TypeFoldable, TypeVisitor, }; use rustc_span::def_id::DefId; @@ -164,7 +164,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData>> for ty::Predi )) } ty::PredicateAtom::WellFormed(arg) => match arg.unpack() { - GenericArgKind::Type(ty) => match ty.kind() { + GenericArgKind::Type(ty) => match ty.data() { // FIXME(chalk): In Chalk, a placeholder is WellFormed if it // `FromEnv`. However, when we "lower" Params, we don't update // the environment. @@ -235,7 +235,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty>> for Ty<'tcx> { fn lower_into(self, interner: &RustInterner<'tcx>) -> chalk_ir::Ty> { use chalk_ir::TyData; use rustc_ast as ast; - use TyKind::*; + use ty::TyData::*; let empty = || chalk_ir::Substitution::empty(interner); let struct_ty = @@ -247,7 +247,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty>> for Ty<'tcx> { let uint = |i| apply(chalk_ir::TypeName::Scalar(chalk_ir::Scalar::Uint(i)), empty()); let float = |f| apply(chalk_ir::TypeName::Scalar(chalk_ir::Scalar::Float(f)), empty()); - match *self.kind() { + match *self.data() { Bool => apply(chalk_ir::TypeName::Scalar(chalk_ir::Scalar::Bool), empty()), Char => apply(chalk_ir::TypeName::Scalar(chalk_ir::Scalar::Char), empty()), Int(ty) => match ty { @@ -490,7 +490,7 @@ impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty> { universe: ty::UniverseIndex::from_usize(placeholder.ui.counter), name: ty::BoundVar::from_usize(placeholder.idx), }), - chalk_ir::TyData::Alias(alias_ty) => match alias_ty { + TyData::Alias(alias_ty) => match alias_ty { chalk_ir::AliasTy::Projection(projection) => ty::Projection(ty::ProjectionTy { item_def_id: projection.associated_ty_id.0, substs: projection.substitution.lower_into(interner), @@ -901,7 +901,7 @@ impl<'tcx> TypeVisitor<'tcx> for BoundVarsCollector<'tcx> { } fn visit_ty(&mut self, t: Ty<'tcx>) -> bool { - match *t.kind() { + match *t.data() { ty::Bound(debruijn, bound_ty) if debruijn == self.binder_index => { match self.parameters.entry(bound_ty.var.as_u32()) { Entry::Vacant(entry) => { @@ -1043,7 +1043,7 @@ impl<'tcx> TypeFolder<'tcx> for ParamsSubstitutor<'tcx> { } fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { - match *t.kind() { + match *t.data() { // FIXME(chalk): currently we convert params to placeholders starting at // index `0`. To support placeholders, we'll actually need to do a // first pass to collect placeholders. Then we can insert params after. @@ -1111,7 +1111,7 @@ impl PlaceholdersCollector { impl<'tcx> TypeVisitor<'tcx> for PlaceholdersCollector { fn visit_ty(&mut self, t: Ty<'tcx>) -> bool { - match t.kind() { + match t.data() { ty::Placeholder(p) if p.universe == self.universe_index => { self.next_ty_placeholder = self.next_ty_placeholder.max(p.name.as_usize() + 1); } diff --git a/compiler/rustc_traits/src/dropck_outlives.rs b/compiler/rustc_traits/src/dropck_outlives.rs index 3ee391d6dc714..52121602e8bba 100644 --- a/compiler/rustc_traits/src/dropck_outlives.rs +++ b/compiler/rustc_traits/src/dropck_outlives.rs @@ -112,7 +112,7 @@ fn dropck_outlives<'tcx>( debug!("dropck_outlives: ty from dtorck_types = {:?}", ty); - match ty.kind() { + match ty.data() { // All parameters live for the duration of the // function. ty::Param(..) => {} @@ -172,7 +172,7 @@ fn dtorck_constraint_for_ty<'tcx>( return Ok(()); } - match ty.kind() { + match ty.data() { ty::Bool | ty::Char | ty::Int(_) diff --git a/compiler/rustc_ty/src/instance.rs b/compiler/rustc_ty/src/instance.rs index 220f4cec742f1..ae0cb66f63c44 100644 --- a/compiler/rustc_ty/src/instance.rs +++ b/compiler/rustc_ty/src/instance.rs @@ -53,7 +53,7 @@ fn inner_resolve_instance<'tcx>( let ty = tcx.type_of(def.def_id_for_type_of()); let item_type = tcx.subst_and_normalize_erasing_regions(substs, param_env, &ty); - let def = match *item_type.kind() { + let def = match *item_type.data() { ty::FnDef(..) if { let f = item_type.fn_sig(tcx); @@ -68,7 +68,7 @@ fn inner_resolve_instance<'tcx>( if ty.needs_drop(tcx, param_env) { debug!(" => nontrivial drop glue"); - match *ty.kind() { + match *ty.data() { ty::Closure(..) | ty::Generator(..) | ty::Tuple(..) @@ -231,7 +231,7 @@ fn resolve_associated_item<'tcx>( trait_closure_kind, )) } - traits::ImplSource::FnPointer(ref data) => match data.fn_ty.kind() { + traits::ImplSource::FnPointer(ref data) => match data.fn_ty.data() { ty::FnDef(..) | ty::FnPtr(..) => Some(Instance { def: ty::InstanceDef::FnPtrShim(trait_item.def_id, data.fn_ty), substs: rcvr_substs, @@ -250,7 +250,7 @@ fn resolve_associated_item<'tcx>( let self_ty = trait_ref.self_ty(); let is_copy = self_ty.is_copy_modulo_regions(tcx.at(DUMMY_SP), param_env); - match self_ty.kind() { + match self_ty.data() { _ if is_copy => (), ty::Array(..) | ty::Closure(..) | ty::Tuple(..) => {} _ => return Ok(None), diff --git a/compiler/rustc_ty/src/needs_drop.rs b/compiler/rustc_ty/src/needs_drop.rs index 0356bcec5498b..497ac81572c69 100644 --- a/compiler/rustc_ty/src/needs_drop.rs +++ b/compiler/rustc_ty/src/needs_drop.rs @@ -90,7 +90,7 @@ where }; for component in components { - match *component.kind() { + match *component.data() { _ if component.is_copy_modulo_regions(tcx.at(DUMMY_SP), self.param_env) => (), ty::Closure(_, substs) => { @@ -106,7 +106,7 @@ where } let witness = substs.witness(); - let interior_tys = match witness.kind() { + let interior_tys = match witness.data() { ty::GeneratorWitness(tys) => tcx.erase_late_bound_regions(tys), _ => { tcx.sess.delay_span_bug( diff --git a/compiler/rustc_ty/src/ty.rs b/compiler/rustc_ty/src/ty.rs index 1f21d9488a454..d0f7e43a680b1 100644 --- a/compiler/rustc_ty/src/ty.rs +++ b/compiler/rustc_ty/src/ty.rs @@ -17,9 +17,9 @@ fn sized_constraint_for_ty<'tcx>( adtdef: &ty::AdtDef, ty: Ty<'tcx>, ) -> Vec> { - use ty::TyKind::*; + use ty::TyData::*; - let result = match ty.kind() { + let result = match ty.data() { Bool | Char | Int(..) | Uint(..) | Float(..) | RawPtr(..) | Ref(..) | FnDef(..) | FnPtr(_) | Array(..) | Closure(..) | Generator(..) | Never => vec![], @@ -463,7 +463,7 @@ fn issue33140_self_ty(tcx: TyCtxt<'_>, def_id: DefId) -> Option> { } let self_ty = trait_ref.self_ty(); - let self_ty_matches = match self_ty.kind() { + let self_ty_matches = match self_ty.data() { ty::Dynamic(ref data, ty::ReStatic) => data.principal().is_none(), _ => false, }; diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs index 170ca2ce744cd..f34140c824c46 100644 --- a/compiler/rustc_typeck/src/astconv/mod.rs +++ b/compiler/rustc_typeck/src/astconv/mod.rs @@ -1453,7 +1453,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { // Check if we have an enum variant. let mut variant_resolution = None; - if let ty::Adt(adt_def, _) = qself_ty.kind() { + if let ty::Adt(adt_def, _) = qself_ty.data() { if adt_def.is_enum() { let variant_def = adt_def .variants @@ -1473,7 +1473,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { // Find the type of the associated item, and the trait where the associated // item is declared. - let bound = match (&qself_ty.kind(), qself_res) { + let bound = match (&qself_ty.data(), qself_res) { (_, Res::SelfTy(Some(_), Some((impl_def_id, _)))) => { // `Self` in an impl of a trait -- we have a concrete self type and a // trait reference. diff --git a/compiler/rustc_typeck/src/check/autoderef.rs b/compiler/rustc_typeck/src/check/autoderef.rs index 59c366ad7d776..1ac98c1b6c20d 100644 --- a/compiler/rustc_typeck/src/check/autoderef.rs +++ b/compiler/rustc_typeck/src/check/autoderef.rs @@ -54,7 +54,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().data() { Some(OverloadedDeref { region, mutbl, diff --git a/compiler/rustc_typeck/src/check/callee.rs b/compiler/rustc_typeck/src/check/callee.rs index 740783aeb9d1e..052e6f138cf91 100644 --- a/compiler/rustc_typeck/src/check/callee.rs +++ b/compiler/rustc_typeck/src/check/callee.rs @@ -114,7 +114,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); // If the callee is a bare function or a closure, then we're all set. - match *adjusted_ty.kind() { + match *adjusted_ty.data() { ty::FnDef(..) | ty::FnPtr(_) => { let adjustments = self.adjust_steps(autoderef); self.apply_adjustments(callee_expr, adjustments); @@ -224,7 +224,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Check for &self vs &mut self in the method signature. Since this is either // the Fn or FnMut trait, it should be one of those. let (region, mutbl) = - if let ty::Ref(r, _, mutbl) = method.sig.inputs()[0].kind() { + if let ty::Ref(r, _, mutbl) = method.sig.inputs()[0].data() { (r, mutbl) } else { span_bug!(call_expr.span, "input to call/call_mut is not a ref?"); @@ -285,7 +285,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { arg_exprs: &'tcx [hir::Expr<'tcx>], expected: Expectation<'tcx>, ) -> Ty<'tcx> { - let (fn_sig, def_span) = match *callee_ty.kind() { + let (fn_sig, def_span) = match *callee_ty.data() { ty::FnDef(def_id, _) => { (callee_ty.fn_sig(self.tcx), self.tcx.hir().span_if_local(def_id)) } diff --git a/compiler/rustc_typeck/src/check/cast.rs b/compiler/rustc_typeck/src/check/cast.rs index 5c2bdb86f76c9..2c9f508a8aa17 100644 --- a/compiler/rustc_typeck/src/check/cast.rs +++ b/compiler/rustc_typeck/src/check/cast.rs @@ -97,7 +97,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return Ok(Some(PointerKind::Thin)); } - Ok(match *t.kind() { + Ok(match *t.data() { ty::Slice(_) | ty::Str => Some(PointerKind::Length), ty::Dynamic(ref tty, ..) => Some(PointerKind::Vtable(tty.principal_def_id())), ty::Adt(def, substs) if def.is_struct() => match def.non_enum_variant().fields.last() { @@ -203,7 +203,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { // For better error messages, check for some obviously unsized // cases now. We do a more thorough check at the end, once // inference is more completely known. - match cast_ty.kind() { + match cast_ty.data() { ty::Dynamic(..) | ty::Slice(..) => { check.report_cast_to_unsized_type(fcx); Err(ErrorReported) @@ -348,7 +348,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { fcx.ty_to_string(self.cast_ty) ); let mut sugg = None; - if let ty::Ref(reg, _, mutbl) = *self.cast_ty.kind() { + if let ty::Ref(reg, _, mutbl) = *self.cast_ty.data() { if fcx .try_coerce( self.expr, @@ -370,7 +370,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { Applicability::MachineApplicable, ); } else if !matches!( - self.cast_ty.kind(), + self.cast_ty.data(), ty::FnDef(..) | ty::FnPtr(..) | ty::Closure(..) ) { let mut label = true; @@ -474,7 +474,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { fcx.resolve_vars_if_possible(&self.expr_ty), tstr ); - match self.expr_ty.kind() { + match self.expr_ty.data() { ty::Ref(_, _, mt) => { let mtstr = mt.prefix_str(); if self.cast_ty.is_trait() { @@ -602,7 +602,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.data() { ty::FnDef(..) => { // Attempt a coercion to a fn pointer type. let f = fcx.normalize_associated_types_in( @@ -629,7 +629,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.data() { ty::Int(_) | ty::Uint(_) | ty::Float(_) @@ -768,7 +768,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { // array-ptr-cast. if m_expr.mutbl == hir::Mutability::Not && m_cast.mutbl == hir::Mutability::Not { - if let ty::Array(ety, _) = m_expr.ty.kind() { + if let ty::Array(ety, _) = m_expr.ty.data() { // Due to the limitations of LLVM global constants, // region pointers end up pointing at copies of // vector elements instead of the original values. @@ -817,7 +817,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { } fn cenum_impl_drop_lint(&self, fcx: &FnCtxt<'a, 'tcx>) { - if let ty::Adt(d, _) = self.expr_ty.kind() { + if let ty::Adt(d, _) = self.expr_ty.data() { if d.has_dtor(fcx.tcx) { fcx.tcx.struct_span_lint_hir( lint::builtin::CENUM_IMPL_DROP_CAST, diff --git a/compiler/rustc_typeck/src/check/check.rs b/compiler/rustc_typeck/src/check/check.rs index d319ac2cba654..77ae3ebbd93c1 100644 --- a/compiler/rustc_typeck/src/check/check.rs +++ b/compiler/rustc_typeck/src/check/check.rs @@ -76,7 +76,7 @@ pub(super) fn check_fn<'a, 'tcx>( debug!("check_fn: declared_ret_ty: {}, revealed_ret_ty: {}", declared_ret_ty, revealed_ret_ty); fcx.ret_coercion = Some(RefCell::new(CoerceMany::new(revealed_ret_ty))); fcx.ret_type_span = Some(decl.output.span()); - if let ty::Opaque(..) = declared_ret_ty.kind() { + if let ty::Opaque(..) = declared_ret_ty.data() { fcx.ret_coercion_impl_trait = Some(declared_ret_ty); } fn_sig = tcx.mk_fn_sig( @@ -140,7 +140,7 @@ pub(super) fn check_fn<'a, 'tcx>( inherited.typeck_results.borrow_mut().liberated_fn_sigs_mut().insert(fn_id, fn_sig); fcx.in_tail_expr = true; - if let ty::Dynamic(..) = declared_ret_ty.kind() { + if let ty::Dynamic(..) = declared_ret_ty.data() { // FIXME: We need to verify that the return type is `Sized` after the return expression has // been evaluated so that we have types available for all the nodes being returned, but that // requires the coerced evaluated type to be stored. Moving `check_return_expr` before this @@ -240,15 +240,15 @@ pub(super) fn check_fn<'a, 'tcx>( if let Some(panic_impl_did) = tcx.lang_items().panic_impl() { if panic_impl_did == hir.local_def_id(fn_id).to_def_id() { if let Some(panic_info_did) = tcx.lang_items().panic_info() { - if *declared_ret_ty.kind() != ty::Never { + if *declared_ret_ty.data() != ty::Never { sess.span_err(decl.output.span(), "return type should be `!`"); } let inputs = fn_sig.inputs(); let span = hir.span(fn_id); if inputs.len() == 1 { - let arg_is_panic_info = match *inputs[0].kind() { - ty::Ref(region, ty, mutbl) => match *ty.kind() { + let arg_is_panic_info = match *inputs[0].data() { + ty::Ref(region, ty, mutbl) => match *ty.data() { ty::Adt(ref adt, _) => { adt.did == panic_info_did && mutbl == hir::Mutability::Not @@ -284,14 +284,14 @@ pub(super) fn check_fn<'a, 'tcx>( if let Some(alloc_error_handler_did) = tcx.lang_items().oom() { if alloc_error_handler_did == hir.local_def_id(fn_id).to_def_id() { if let Some(alloc_layout_did) = tcx.lang_items().alloc_layout() { - if *declared_ret_ty.kind() != ty::Never { + if *declared_ret_ty.data() != ty::Never { sess.span_err(decl.output.span(), "return type should be `!`"); } let inputs = fn_sig.inputs(); let span = hir.span(fn_id); if inputs.len() == 1 { - let arg_is_alloc_layout = match inputs[0].kind() { + let arg_is_alloc_layout = match inputs[0].data() { ty::Adt(ref adt, _) => adt.did == alloc_layout_did, _ => false, }; @@ -352,7 +352,7 @@ pub(super) fn check_union(tcx: TyCtxt<'_>, id: hir::HirId, span: Span) { /// check that the fields of the `union` does not contain fields that need dropping. pub(super) fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> bool { let item_type = tcx.type_of(item_def_id); - if let ty::Adt(def, substs) = item_type.kind() { + if let ty::Adt(def, substs) = item_type.data() { assert!(def.is_union()); let fields = &def.non_enum_variant().fields; let param_env = tcx.param_env(item_def_id); @@ -373,7 +373,7 @@ pub(super) fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: Local } } } else { - span_bug!(span, "unions must be ty::Adt, but got {:?}", item_type.kind()); + span_bug!(span, "unions must be ty::Adt, but got {:?}", item_type.data()); } true } @@ -1004,7 +1004,7 @@ pub(super) fn check_representable(tcx: TyCtxt<'_>, sp: Span, item_def_id: LocalD pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) { let t = tcx.type_of(def_id); - if let ty::Adt(def, substs) = t.kind() { + if let ty::Adt(def, substs) = t.data() { if def.is_struct() { let fields = &def.non_enum_variant().fields; if fields.is_empty() { @@ -1018,7 +1018,7 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) { .emit(); return; } - match e.kind() { + match e.data() { ty::Param(_) => { /* struct(T, T, T, T) is ok */ } _ if e.is_machine() => { /* struct(u8, u8, u8, u8) is ok */ } _ => { @@ -1112,7 +1112,7 @@ pub(super) fn check_packed_inner( def_id: DefId, stack: &mut Vec, ) -> Option> { - if let ty::Adt(def, substs) = tcx.type_of(def_id).kind() { + if let ty::Adt(def, substs) = tcx.type_of(def_id).data() { if def.is_struct() || def.is_union() { if def.repr.align.is_some() { return Some(vec![(def.did, DUMMY_SP)]); @@ -1120,7 +1120,7 @@ pub(super) fn check_packed_inner( stack.push(def_id); for field in &def.non_enum_variant().fields { - if let ty::Adt(def, _) = field.ty(tcx, substs).kind() { + if let ty::Adt(def, _) = field.ty(tcx, substs).data() { if !stack.contains(&def.did) { if let Some(mut defs) = check_packed_inner(tcx, def.did, stack) { defs.push((def.did, field.ident.span)); @@ -1312,7 +1312,7 @@ pub(super) fn check_type_params_are_used<'tcx>( for leaf in ty.walk() { if let GenericArgKind::Type(leaf_ty) = leaf.unpack() { - if let ty::Param(param) = leaf_ty.kind() { + if let ty::Param(param) = leaf_ty.data() { debug!("found use of ty param {:?}", param); params_used.insert(param.index); } @@ -1378,7 +1378,7 @@ fn opaque_type_cycle_error(tcx: TyCtxt<'tcx>, def_id: LocalDefId, span: Span) { .returns .iter() .filter_map(|expr| typeck_results.node_type_opt(expr.hir_id)) - .all(|ty| matches!(ty.kind(), ty::Never)) + .all(|ty| matches!(ty.data(), ty::Never)) { let spans = visitor .returns @@ -1407,12 +1407,12 @@ fn opaque_type_cycle_error(tcx: TyCtxt<'tcx>, def_id: LocalDefId, span: Span) { .returns .iter() .filter_map(|e| typeck_results.node_type_opt(e.hir_id).map(|t| (e.span, t))) - .filter(|(_, ty)| !matches!(ty.kind(), ty::Never)) + .filter(|(_, ty)| !matches!(ty.data(), ty::Never)) { struct VisitTypes(Vec); impl<'tcx> ty::fold::TypeVisitor<'tcx> for VisitTypes { fn visit_ty(&mut self, t: Ty<'tcx>) -> bool { - match *t.kind() { + match *t.data() { ty::Opaque(def, _) => { self.0.push(def); false diff --git a/compiler/rustc_typeck/src/check/closure.rs b/compiler/rustc_typeck/src/check/closure.rs index 8898a5452282c..9d8945b9d3d8c 100644 --- a/compiler/rustc_typeck/src/check/closure.rs +++ b/compiler/rustc_typeck/src/check/closure.rs @@ -170,7 +170,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) -> (Option>, Option) { debug!("deduce_expectations_from_expected_type(expected_ty={:?})", expected_ty); - match *expected_ty.kind() { + match *expected_ty.data() { ty::Dynamic(ref object_type, ..) => { let sig = object_type.projection_bounds().find_map(|pb| { let pb = pb.with_self_ty(self.tcx, self.tcx.types.trait_object_dummy_self); @@ -268,7 +268,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let arg_param_ty = self.resolve_vars_if_possible(&arg_param_ty); debug!("deduce_sig_from_projection: arg_param_ty={:?}", arg_param_ty); - match arg_param_ty.kind() { + match arg_param_ty.data() { ty::Tuple(tys) => tys.into_iter().map(|k| k.expect_ty()).collect::>(), _ => return None, } @@ -611,7 +611,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // be inferring. let ret_ty = ret_coercion.borrow().expected_ty(); let ret_ty = self.inh.infcx.shallow_resolve(ret_ty); - let ret_vid = match *ret_ty.kind() { + let ret_vid = match *ret_ty.data() { ty::Infer(ty::TyVar(ret_vid)) => ret_vid, _ => span_bug!( self.tcx.def_span(expr_def_id), diff --git a/compiler/rustc_typeck/src/check/coercion.rs b/compiler/rustc_typeck/src/check/coercion.rs index 4addee1a4c976..d7e3170b18aa9 100644 --- a/compiler/rustc_typeck/src/check/coercion.rs +++ b/compiler/rustc_typeck/src/check/coercion.rs @@ -197,7 +197,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { // // Note: does not attempt to resolve type variables we encounter. // See above for details. - match *b.kind() { + match *b.data() { ty::RawPtr(mt_b) => { return self.coerce_unsafe_ptr(a, b, mt_b.mutbl); } @@ -207,7 +207,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { _ => {} } - match *a.kind() { + match *a.data() { ty::FnDef(..) => { // Function items are coercible to any closure // type; function pointers are not (that would @@ -252,7 +252,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.data() { ty::Ref(r_a, ty, mutbl) => { let mt_a = ty::TypeAndMut { ty, mutbl }; coerce_mutbls(mt_a.mutbl, mutbl_b)?; @@ -415,7 +415,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { // Now apply the autoref. We have to extract the region out of // the final ref type we got. - let r_borrow = match ty.kind() { + let r_borrow = match ty.data() { ty::Ref(r_borrow, _, _) => r_borrow, _ => span_bug!(span, "expected a ref type, got {:?}", ty), }; @@ -490,7 +490,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { // that, at which point we will need extra checks on the target here. // Handle reborrows before selecting `Source: CoerceUnsized`. - let reborrow = match (source.kind(), target.kind()) { + let reborrow = match (source.data(), target.data()) { (&ty::Ref(_, ty_a, mutbl_a), &ty::Ref(_, _, mutbl_b)) => { coerce_mutbls(mutbl_a, mutbl_b)?; @@ -588,7 +588,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { { if unsize_did == trait_pred.def_id() { let unsize_ty = trait_pred.trait_ref.substs[1].expect_ty(); - if let ty::Tuple(..) = unsize_ty.kind() { + if let ty::Tuple(..) = unsize_ty.data() { debug!("coerce_unsized: found unsized tuple coercion"); has_unsized_tuple_coercion = true; } @@ -608,7 +608,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { let self_ty = trait_pred.skip_binder().self_ty(); let unsize_ty = trait_pred.skip_binder().trait_ref.substs[1].expect_ty(); debug!("coerce_unsized: ambiguous unsize case for {:?}", trait_pred); - match (&self_ty.kind(), &unsize_ty.kind()) { + match (&self_ty.data(), &unsize_ty.data()) { (ty::Infer(ty::TyVar(v)), ty::Dynamic(..)) if self.type_var_is_sized(*v) => { @@ -672,7 +672,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { F: FnOnce(Ty<'tcx>) -> Vec>, G: FnOnce(Ty<'tcx>) -> Vec>, { - if let ty::FnPtr(fn_ty_b) = b.kind() { + if let ty::FnPtr(fn_ty_b) = b.data() { if let (hir::Unsafety::Normal, hir::Unsafety::Unsafe) = (fn_ty_a.unsafety(), fn_ty_b.unsafety()) { @@ -712,7 +712,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { let b = self.shallow_resolve(b); debug!("coerce_from_fn_item(a={:?}, b={:?})", a, b); - match b.kind() { + match b.data() { ty::FnPtr(b_sig) => { let a_sig = a.fn_sig(self.tcx); // Intrinsics are not coercible to function pointers @@ -721,7 +721,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { } // Safe `#[target_feature]` functions are not assignable to safe fn pointers (RFC 2396). - if let ty::FnDef(def_id, _) = *a.kind() { + if let ty::FnDef(def_id, _) = *a.data() { if b_sig.unsafety() == hir::Unsafety::Normal && !self.tcx.codegen_fn_attrs(def_id).target_features.is_empty() { @@ -771,7 +771,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { let b = self.shallow_resolve(b); - match b.kind() { + match b.data() { ty::FnPtr(fn_ty) if substs_a.as_closure().upvar_tys().next().is_none() => { // We coerce the closure, which has fn type // `extern "rust-call" fn((arg0,arg1,...)) -> _` @@ -802,7 +802,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.data() { ty::Ref(_, ty, mutbl) => (true, ty::TypeAndMut { ty, mutbl }), ty::RawPtr(mt) => (false, mt), _ => return self.unify_and(a, b, identity), @@ -912,10 +912,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { false } }; - if is_capturing_closure(&prev_ty.kind()) || is_capturing_closure(&new_ty.kind()) { + if is_capturing_closure(&prev_ty.data()) || is_capturing_closure(&new_ty.data()) { (None, None) } else { - match (&prev_ty.kind(), &new_ty.kind()) { + match (&prev_ty.data(), &new_ty.data()) { (&ty::FnDef(..), &ty::FnDef(..)) => { // Don't reify if the function types have a LUB, i.e., they // are the same function and their parameters have a LUB. @@ -969,12 +969,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Reify both sides and return the reified fn pointer type. let fn_ptr = self.tcx.mk_fn_ptr(sig); - let prev_adjustment = match prev_ty.kind() { + let prev_adjustment = match prev_ty.data() { ty::Closure(..) => Adjust::Pointer(PointerCast::ClosureFnPointer(a_sig.unsafety())), ty::FnDef(..) => Adjust::Pointer(PointerCast::ReifyFnPointer), _ => unreachable!(), }; - let next_adjustment = match new_ty.kind() { + let next_adjustment = match new_ty.data() { ty::Closure(..) => Adjust::Pointer(PointerCast::ClosureFnPointer(b_sig.unsafety())), ty::FnDef(..) => Adjust::Pointer(PointerCast::ReifyFnPointer), _ => unreachable!(), @@ -1024,7 +1024,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let noop = match self.typeck_results.borrow().expr_adjustments(expr) { &[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).data() { ty::Ref(_, _, mt_orig) => { let mutbl_adj: hir::Mutability = mutbl_adj.into(); // Reborrow that we can safely ignore, because @@ -1502,7 +1502,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { if let hir::TyKind::OpaqueDef(..) = ty.kind { let ty = AstConv::ast_ty_to_ty(fcx, ty); // Get the `impl Trait`'s `DefId`. - if let ty::Opaque(def_id, _) = ty.kind() { + if let ty::Opaque(def_id, _) = ty.data() { let hir_id = fcx.tcx.hir().local_def_id_to_hir_id(def_id.expect_local()); // Get the `impl Trait`'s `Item` so that we can get its trait bounds and // get the `Trait`'s `DefId`. @@ -1563,7 +1563,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { if let Some((fn_decl, _)) = fcx.get_fn_decl(blk_id) { if let hir::FnRetTy::Return(ty) = fn_decl.output { let ty = AstConv::ast_ty_to_ty(fcx, ty); - if let ty::Dynamic(..) = ty.kind() { + if let ty::Dynamic(..) = ty.data() { return true; } } diff --git a/compiler/rustc_typeck/src/check/compare_method.rs b/compiler/rustc_typeck/src/check/compare_method.rs index 4acc7451a2131..d99f201778824 100644 --- a/compiler/rustc_typeck/src/check/compare_method.rs +++ b/compiler/rustc_typeck/src/check/compare_method.rs @@ -1205,7 +1205,7 @@ pub fn check_type_bounds<'tcx>( // ParamEnv for normalization specifically. let normalize_param_env = { let mut predicates = param_env.caller_bounds().iter().collect::>(); - match impl_ty_value.kind() { + match impl_ty_value.data() { ty::Projection(proj) if proj.item_def_id == trait_ty.def_id && proj.substs == rebased_substs => { diff --git a/compiler/rustc_typeck/src/check/demand.rs b/compiler/rustc_typeck/src/check/demand.rs index 3e66885448b9a..d4f30253f4b3c 100644 --- a/compiler/rustc_typeck/src/check/demand.rs +++ b/compiler/rustc_typeck/src/check/demand.rs @@ -185,7 +185,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expected: Ty<'tcx>, expr_ty: Ty<'tcx>, ) { - if let ty::Adt(expected_adt, substs) = expected.kind() { + if let ty::Adt(expected_adt, substs) = expected.data() { if !expected_adt.is_enum() { return; } @@ -409,8 +409,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // `ExprKind::DropTemps` is semantically irrelevant for these suggestions. 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()) { + match (&expr.kind, expected.data(), checked_ty.data()) { + (_, &ty::Ref(_, exp, _), &ty::Ref(_, check, _)) => match (exp.data(), check.data()) { (&ty::Str, &ty::Array(arr, _) | &ty::Slice(arr)) if arr == self.tcx.types.u8 => { if let hir::ExprKind::Lit(_) = expr.kind { if let Ok(src) = sm.span_to_snippet(sp) { @@ -770,7 +770,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let suffix_suggestion = with_opt_paren(&format_args!( "{}{}", if matches!( - (&expected_ty.kind(), &checked_ty.kind()), + (&expected_ty.data(), &checked_ty.data()), (ty::Int(_) | ty::Uint(_), ty::Float(_)) ) { // Remove fractional part from literal, for example `42.0f32` into `42` @@ -786,7 +786,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; let is_negative_int = |expr: &hir::Expr<'_>| matches!(expr.kind, hir::ExprKind::Unary(hir::UnOp::UnNeg, ..)); - let is_uint = |ty: Ty<'_>| matches!(ty.kind(), ty::Uint(..)); + let is_uint = |ty: Ty<'_>| matches!(ty.data(), ty::Uint(..)); let in_const_context = self.tcx.hir().is_inside_const_context(expr.hir_id); @@ -853,7 +853,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.span_suggestion(expr.span, msg, suggestion, Applicability::MachineApplicable); }; - match (&expected_ty.kind(), &checked_ty.kind()) { + match (&expected_ty.data(), &checked_ty.data()) { (&ty::Int(ref exp), &ty::Int(ref found)) => { let (f2e_is_fallible, e2f_is_fallible) = match (exp.bit_width(), found.bit_width()) { diff --git a/compiler/rustc_typeck/src/check/dropck.rs b/compiler/rustc_typeck/src/check/dropck.rs index ae94a6df5fd47..3716d6df9e93e 100644 --- a/compiler/rustc_typeck/src/check/dropck.rs +++ b/compiler/rustc_typeck/src/check/dropck.rs @@ -34,7 +34,7 @@ use rustc_trait_selection::traits::{ObligationCause, TraitEngine, TraitEngineExt pub fn check_drop_impl(tcx: TyCtxt<'_>, drop_impl_did: DefId) -> Result<(), ErrorReported> { let dtor_self_type = tcx.type_of(drop_impl_did); let dtor_predicates = tcx.predicates_of(drop_impl_did); - match dtor_self_type.kind() { + match dtor_self_type.data() { ty::Adt(adt_def, self_to_impl_substs) => { ensure_drop_params_and_item_params_correspond( tcx, diff --git a/compiler/rustc_typeck/src/check/expectation.rs b/compiler/rustc_typeck/src/check/expectation.rs index fd6fe1406c840..7bf6ee002a1da 100644 --- a/compiler/rustc_typeck/src/check/expectation.rs +++ b/compiler/rustc_typeck/src/check/expectation.rs @@ -71,7 +71,7 @@ impl<'a, 'tcx> Expectation<'tcx> { /// See the test case `test/ui/coerce-expect-unsized.rs` and #20169 /// for examples of where this comes up,. pub(super) fn rvalue_hint(fcx: &FnCtxt<'a, 'tcx>, ty: Ty<'tcx>) -> Expectation<'tcx> { - match fcx.tcx.struct_tail_without_normalization(ty).kind() { + match fcx.tcx.struct_tail_without_normalization(ty).data() { ty::Slice(_) | ty::Str | ty::Dynamic(..) => ExpectRvalueLikeUnsized(ty), _ => ExpectHasType(ty), } diff --git a/compiler/rustc_typeck/src/check/expr.rs b/compiler/rustc_typeck/src/check/expr.rs index 179e383be2e2b..6cf04099b1459 100644 --- a/compiler/rustc_typeck/src/check/expr.rs +++ b/compiler/rustc_typeck/src/check/expr.rs @@ -301,7 +301,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } fn check_expr_box(&self, expr: &'tcx hir::Expr<'tcx>, expected: Expectation<'tcx>) -> Ty<'tcx> { - let expected_inner = expected.to_option(self).map_or(NoExpectation, |ty| match ty.kind() { + let expected_inner = expected.to_option(self).map_or(NoExpectation, |ty| match ty.data() { ty::Adt(def, _) if def.is_box() => Expectation::rvalue_hint(self, ty.boxed_ty()), _ => NoExpectation, }); @@ -351,7 +351,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { hir::UnOp::UnNot => { let result = self.check_user_unop(expr, oprnd_t, unop); // 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.data() == ty::Bool) { oprnd_t = result; } } @@ -376,7 +376,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expr: &'tcx hir::Expr<'tcx>, ) -> Ty<'tcx> { let hint = expected.only_has_type(self).map_or(NoExpectation, |ty| { - match ty.kind() { + match ty.data() { ty::Ref(_, ty, _) | ty::RawPtr(ty::TypeAndMut { ty, .. }) => { if oprnd.is_syntactic_place_expr() { // Places may legitimately have unsized types. @@ -473,7 +473,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { _ => self.instantiate_value_path(segs, opt_ty, res, expr.span, expr.hir_id).0, }; - if let ty::FnDef(..) = ty.kind() { + if let ty::FnDef(..) = ty.data() { let fn_sig = ty.fn_sig(tcx); if !tcx.features().unsized_locals { // We want to remove some Sized bounds from std functions, @@ -946,7 +946,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { error, Some(args), ) { - if let ty::Adt(..) = rcvr_t.kind() { + if let ty::Adt(..) = rcvr_t.data() { // Try alternative arbitrary self types that could fulfill this call. // FIXME: probe for all types that *could* be arbitrary self-types, not // just this list. @@ -997,7 +997,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.data() { ty::Array(ty, _) | ty::Slice(ty) => Some(ty), _ => None, }) @@ -1035,7 +1035,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let count = self.to_const(count); let uty = match expected { - ExpectHasType(uty) => match *uty.kind() { + ExpectHasType(uty) => match *uty.data() { ty::Array(ty, _) | ty::Slice(ty) => Some(ty), _ => None, }, @@ -1072,7 +1072,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) -> Ty<'tcx> { let flds = expected.only_has_type(self).and_then(|ty| { let ty = self.resolve_vars_with_obligations(ty); - match ty.kind() { + match ty.data() { ty::Tuple(ref flds) => Some(&flds[..]), _ => None, } @@ -1135,7 +1135,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // when certain fields are assumed to exist that in fact do not. if !error_happened { self.check_expr_has_type_or_error(base_expr, adt_ty, |_| {}); - match adt_ty.kind() { + match adt_ty.data() { ty::Adt(adt, substs) if adt.is_struct() => { let fru_field_types = adt .non_enum_variant() @@ -1186,7 +1186,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // re-link the regions that EIfEO can erase. self.demand_eqtype(span, adt_ty_hint, adt_ty); - let (substs, adt_kind, kind_name) = match &adt_ty.kind() { + let (substs, adt_kind, kind_name) = match &adt_ty.data() { &ty::Adt(adt, substs) => (substs, adt.adt_kind(), adt.variant_descr()), _ => span_bug!(span, "non-ADT passed to check_expr_struct_fields"), }; @@ -1361,7 +1361,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } let mut err = self.type_error_struct_with_diag( field.ident.span, - |actual| match ty.kind() { + |actual| match ty.data() { ty::Adt(adt, ..) if adt.is_enum() => struct_span_err!( self.tcx.sess, field.ident.span, @@ -1411,7 +1411,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Applicability::MaybeIncorrect, ); } else { - match ty.kind() { + match ty.data() { ty::Adt(adt, ..) => { if adt.is_enum() { err.span_label( @@ -1498,7 +1498,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut private_candidate = None; let mut autoderef = self.autoderef(expr.span, expr_t); while let Some((base_t, _)) = autoderef.next() { - match base_t.kind() { + match base_t.data() { ty::Adt(base_def, substs) if !base_def.is_enum() => { debug!("struct named {:?}", base_t); let (ident, def_scope) = @@ -1601,9 +1601,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { debug!( "suggest_await_on_field_access: normalized_ty={:?}, ty_kind={:?}", self.resolve_vars_if_possible(&normalized_ty), - normalized_ty.kind(), + normalized_ty.data(), ); - if let ty::Adt(def, _) = normalized_ty.kind() { + if let ty::Adt(def, _) = normalized_ty.data() { // no field access on enum type if !def.is_enum() { if def.non_enum_variant().fields.iter().any(|field| field.ident == field_ident) @@ -1633,7 +1633,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); let mut err = self.no_such_field_err(field.span, field, expr_t); - match *expr_t.peel_refs().kind() { + match *expr_t.peel_refs().data() { ty::Array(_, len) => { self.maybe_suggest_array_indexing(&mut err, expr, base, field, len); } @@ -1853,7 +1853,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { base_t ); // Try to give some advice about indexing tuples. - if let ty::Tuple(..) = base_t.kind() { + if let ty::Tuple(..) = base_t.data() { let mut needs_note = true; // If the index is an integer, we can show the actual // fixed expression: @@ -1932,7 +1932,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // function. if is_input { let ty = self.structurally_resolved_type(expr.span, &ty); - match *ty.kind() { + match *ty.data() { ty::FnDef(..) => { let fnptr_ty = self.tcx.mk_fn_ptr(ty.fn_sig(self.tcx)); self.demand_coerce(expr, ty, fnptr_ty, None, AllowTwoPhase::No); @@ -1980,7 +1980,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } pub(super) fn ty_kind_suggestion(ty: Ty<'_>) -> Option<&'static str> { - Some(match ty.kind() { + Some(match ty.data() { ty::Bool => "true", ty::Char => "'a'", ty::Int(_) | ty::Uint(_) => "42", diff --git a/compiler/rustc_typeck/src/check/fn_ctxt.rs b/compiler/rustc_typeck/src/check/fn_ctxt.rs index 79d6c7dbfdae2..2dc79eafa8ceb 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt.rs @@ -943,7 +943,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { "self_type_matches_expected_vid(trait_ref={:?}, self_ty={:?}, expected_vid={:?})", trait_ref, self_ty, expected_vid ); - match *self_ty.kind() { + match *self_ty.data() { ty::Infer(ty::TyVar(found_vid)) => { // FIXME: consider using `sub_root_var` here so we // can see through subtyping. @@ -1124,7 +1124,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let formal_tys = if tuple_arguments == TupleArguments { let tuple_type = self.structurally_resolved_type(sp, fn_inputs[0]); - match tuple_type.kind() { + match tuple_type.data() { ty::Tuple(arg_types) if arg_types.len() != args.len() => { param_count_error(arg_types.len(), args.len(), "E0057", false, false); expected_arg_tys = vec![]; @@ -1132,7 +1132,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } ty::Tuple(arg_types) => { expected_arg_tys = match expected_arg_tys.get(0) { - Some(&ty) => match ty.kind() { + Some(&ty) => match ty.data() { ty::Tuple(ref tys) => tys.iter().map(|k| k.expect_ty()).collect(), _ => vec![], }, @@ -1277,7 +1277,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // There are a few types which get autopromoted when passed via varargs // in C but we just error out instead and require explicit casts. let arg_ty = self.structurally_resolved_type(arg.span, arg_ty); - match arg_ty.kind() { + match arg_ty.data() { ty::Float(ast::FloatTy::F32) => { variadic_error(tcx.sess, arg.span, arg_ty, "c_double"); } @@ -1429,7 +1429,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ast::LitKind::Int(_, ast::LitIntType::Signed(t)) => tcx.mk_mach_int(t), ast::LitKind::Int(_, ast::LitIntType::Unsigned(t)) => tcx.mk_mach_uint(t), ast::LitKind::Int(_, ast::LitIntType::Unsuffixed) => { - let opt_ty = expected.to_option(self).and_then(|ty| match ty.kind() { + let opt_ty = expected.to_option(self).and_then(|ty| match ty.data() { ty::Int(_) | ty::Uint(_) => Some(ty), ty::Char => Some(tcx.types.u8), ty::RawPtr(..) => Some(tcx.types.usize), @@ -1440,7 +1440,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } ast::LitKind::Float(_, ast::LitFloatType::Suffixed(t)) => tcx.mk_mach_float(t), ast::LitKind::Float(_, ast::LitFloatType::Unsuffixed) => { - let opt_ty = expected.to_option(self).and_then(|ty| match ty.kind() { + let opt_ty = expected.to_option(self).and_then(|ty| match ty.data() { ty::Float(_) => Some(ty), _ => None, }); @@ -1518,12 +1518,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.set_tainted_by_errors(); return None; } - Res::Def(DefKind::Variant, _) => match ty.kind() { + Res::Def(DefKind::Variant, _) => match ty.data() { ty::Adt(adt, substs) => Some((adt.variant_of_res(def), adt.did, substs)), _ => bug!("unexpected type: {:?}", ty), }, Res::Def(DefKind::Struct | DefKind::Union | DefKind::TyAlias | DefKind::AssocTy, _) - | Res::SelfTy(..) => match ty.kind() { + | Res::SelfTy(..) => match ty.data() { ty::Adt(adt, substs) if !adt.is_enum() => { Some((adt.non_enum_variant(), adt.did, substs)) } @@ -2063,7 +2063,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { found: Ty<'tcx>, ) -> bool { let hir = self.tcx.hir(); - let (def_id, sig) = match *found.kind() { + let (def_id, sig) = match *found.data() { ty::FnDef(def_id, _) => (def_id, found.fn_sig(self.tcx)), ty::Closure(def_id, substs) => (def_id, substs.as_closure().sig()), _ => return false, @@ -2196,7 +2196,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Some((sp, msg, suggestion, applicability)) = self.check_ref(expr, found, expected) { err.span_suggestion(sp, msg, suggestion, applicability); } else if let (ty::FnDef(def_id, ..), true) = - (&found.kind(), self.suggest_fn_call(err, expr, expected, found)) + (&found.data(), self.suggest_fn_call(err, expr, expected, found)) { if let Some(sp) = self.tcx.hir().span_if_local(*def_id) { let sp = self.sess().source_map().guess_head_span(sp); @@ -2343,7 +2343,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return false; } let pin_did = self.tcx.lang_items().pin_type(); - match expected.kind() { + match expected.data() { ty::Adt(def, _) if Some(def.did) != pin_did => return false, // This guards the `unwrap` and `mk_box` below. _ if pin_did.is_none() || self.tcx.lang_items().owned_box().is_none() => return false, @@ -2355,7 +2355,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.can_coerce(new_found, expected), self.sess().source_map().span_to_snippet(expr.span), ) { - match found.kind() { + match found.data() { ty::Adt(def, _) if def.is_box() => { err.help("use `Box::pin`"); } @@ -2463,7 +2463,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let ty = AstConv::ast_ty_to_ty(self, ty); debug!("suggest_missing_return_type: return type {:?}", ty); debug!("suggest_missing_return_type: expected type {:?}", ty); - if ty.kind() == expected.kind() { + if ty.data() == expected.data() { err.span_label(sp, format!("expected `{}` because of return type", expected)); return true; } @@ -2571,7 +2571,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expected: Ty<'tcx>, found: Ty<'tcx>, ) { - let (sig, did, substs) = match (&expected.kind(), &found.kind()) { + let (sig, did, substs) = match (&expected.data(), &found.data()) { (ty::FnDef(did1, substs1), ty::FnDef(did2, substs2)) => { let sig1 = self.tcx.fn_sig(*did1).subst(self.tcx, substs1); let sig2 = self.tcx.fn_sig(*did2).subst(self.tcx, substs2); @@ -2642,7 +2642,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { _ => return None, }; let last_expr_ty = self.node_ty(last_expr.hir_id); - if matches!(last_expr_ty.kind(), ty::Error(_)) + if matches!(last_expr_ty.data(), ty::Error(_)) || self.can_sub(self.param_env, last_expr_ty, expected_ty).is_err() { return None; @@ -2771,7 +2771,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let (res, self_ctor_substs) = if let Res::SelfCtor(impl_def_id) = res { let ty = self.normalize_ty(span, tcx.at(span).type_of(impl_def_id)); - match *ty.kind() { + match *ty.data() { ty::Adt(adt_def, substs) if adt_def.has_ctor() => { let variant = adt_def.non_enum_variant(); let ctor_def_id = variant.ctor_def_id.unwrap(); diff --git a/compiler/rustc_typeck/src/check/method/confirm.rs b/compiler/rustc_typeck/src/check/method/confirm.rs index fd2700b85e279..10f07fc1b94b1 100644 --- a/compiler/rustc_typeck/src/check/method/confirm.rs +++ b/compiler/rustc_typeck/src/check/method/confirm.rs @@ -270,7 +270,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { self.fcx .autoderef(self.span, self_ty) .include_raw_pointers() - .find_map(|(ty, _)| match ty.kind() { + .find_map(|(ty, _)| match ty.data() { ty::Dynamic(ref data, ..) => Some(closure( self, ty, @@ -465,7 +465,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { } _ => None, }) - .find_map(|(trait_pred, span)| match trait_pred.self_ty().kind() { + .find_map(|(trait_pred, span)| match trait_pred.self_ty().data() { ty::Dynamic(..) => Some(span), _ => None, }) diff --git a/compiler/rustc_typeck/src/check/method/mod.rs b/compiler/rustc_typeck/src/check/method/mod.rs index 84bc3979e1229..fc63c19c65d3a 100644 --- a/compiler/rustc_typeck/src/check/method/mod.rs +++ b/compiler/rustc_typeck/src/check/method/mod.rs @@ -207,7 +207,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() { + if let ty::Ref(region, t_type, mutability) = self_ty.data() { let trait_type = self .tcx .mk_ref(region, ty::TypeAndMut { ty: t_type, mutbl: mutability.invert() }); @@ -424,7 +424,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let tcx = self.tcx; // Check if we have an enum variant. - if let ty::Adt(adt_def, _) = self_ty.kind() { + if let ty::Adt(adt_def, _) = self_ty.data() { if adt_def.is_enum() { let variant_def = adt_def .variants diff --git a/compiler/rustc_typeck/src/check/method/probe.rs b/compiler/rustc_typeck/src/check/method/probe.rs index c1ba29284da16..288742448fb0d 100644 --- a/compiler/rustc_typeck/src/check/method/probe.rs +++ b/compiler/rustc_typeck/src/check/method/probe.rs @@ -394,7 +394,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.structurally_resolved_type(span, ty.value); - assert!(matches!(ty.kind(), ty::Error(_))); + assert!(matches!(ty.data(), ty::Error(_))); return Err(MethodError::NoMatch(NoMatchData::new( Vec::new(), Vec::new(), @@ -463,7 +463,7 @@ fn method_autoderef_steps<'tcx>( from_unsafe_deref: reached_raw_pointer, unsize: false, }; - if let ty::RawPtr(_) = ty.kind() { + if let ty::RawPtr(_) = ty.data() { // all the subsequent steps will be from_unsafe_deref reached_raw_pointer = true; } @@ -472,7 +472,7 @@ fn method_autoderef_steps<'tcx>( .collect(); let final_ty = autoderef.final_ty(true); - let opt_bad_ty = match final_ty.kind() { + let opt_bad_ty = match final_ty.data() { ty::Infer(ty::TyVar(_)) | ty::Error(_) => Some(MethodAutoderefBadTy { reached_raw_pointer, ty: infcx @@ -581,7 +581,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { debug!("assemble_probe: self_ty={:?}", self_ty); let lang_items = self.tcx.lang_items(); - match *self_ty.value.value.kind() { + match *self_ty.value.value.data() { ty::Dynamic(ref data, ..) => { if let Some(p) = data.principal() { // Subtle: we can't use `instantiate_query_response` here: using it will @@ -753,7 +753,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { fn assemble_inherent_candidates_from_object(&mut self, self_ty: Ty<'tcx>) { debug!("assemble_inherent_candidates_from_object(self_ty={:?})", self_ty); - let principal = match self_ty.kind() { + let principal = match self_ty.data() { ty::Dynamic(ref data, ..) => Some(data), _ => None, } @@ -800,7 +800,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { self.param_env.caller_bounds().iter().map(ty::Predicate::skip_binders).filter_map( |predicate| match predicate { ty::PredicateAtom::Trait(trait_predicate, _) => { - match trait_predicate.trait_ref.self_ty().kind() { + match trait_predicate.trait_ref.self_ty().data() { ty::Param(ref p) if *p == param_ty => { Some(ty::Binder::bind(trait_predicate.trait_ref)) } @@ -1120,7 +1120,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.data() { pick.autoderefs += 1; pick.autoref = Some(mutbl); } diff --git a/compiler/rustc_typeck/src/check/method/suggest.rs b/compiler/rustc_typeck/src/check/method/suggest.rs index e33a4e98c593a..1a32f7cd54a67 100644 --- a/compiler/rustc_typeck/src/check/method/suggest.rs +++ b/compiler/rustc_typeck/src/check/method/suggest.rs @@ -31,7 +31,7 @@ use super::{CandidateSource, MethodError, NoMatchData}; impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn is_fn_ty(&self, ty: Ty<'tcx>, span: Span) -> bool { let tcx = self.tcx; - match ty.kind() { + match ty.data() { // Not all of these (e.g., unsafe fns) implement `FnOnce`, // so we look for these beforehand. ty::Closure(..) | ty::FnDef(..) | ty::FnPtr(_) => true, @@ -413,7 +413,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); } } - if let ty::RawPtr(_) = &actual.kind() { + if let ty::RawPtr(_) = &actual.data() { err.note( "try using `<*const T>::as_ref()` to get a reference to the \ type behind the pointer: https://doc.rust-lang.org/std/\ @@ -450,7 +450,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // give a helping note that it has to be called as `(x.f)(...)`. if let SelfSource::MethodCall(expr) = source { let field_receiver = - self.autoderef(span, rcvr_ty).find_map(|(ty, _)| match ty.kind() { + self.autoderef(span, rcvr_ty).find_map(|(ty, _)| match ty.data() { ty::Adt(def, substs) if !def.is_enum() => { let variant = &def.non_enum_variant(); self.tcx.find_field_index(item_name, variant).map(|index| { @@ -545,7 +545,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // original type that has the associated function for accurate suggestions. // (#61411) let ty = tcx.at(span).type_of(*impl_did); - match (&ty.peel_refs().kind(), &actual.peel_refs().kind()) { + match (&ty.peel_refs().data(), &actual.peel_refs().data()) { (ty::Adt(def, _), ty::Adt(def_actual, _)) if def == def_actual => { // Use `actual` as it will have more `substs` filled in. self.ty_to_value_string(actual.peel_refs()) @@ -583,9 +583,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |self_ty: Ty<'tcx>, parent_pred: &ty::Predicate<'tcx>, obligation: &str| { // We don't care about regions here, so it's fine to skip the binder here. if let (ty::Param(_), ty::PredicateAtom::Trait(p, _)) = - (self_ty.kind(), parent_pred.skip_binders()) + (self_ty.data(), parent_pred.skip_binders()) { - if let ty::Adt(def, _) = p.trait_ref.self_ty().kind() { + if let ty::Adt(def, _) = p.trait_ref.self_ty().data() { let node = def.did.as_local().map(|def_id| { self.tcx .hir() @@ -615,7 +615,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { "doesn't satisfy `{}`", if obligation.len() > 50 { quiet } else { obligation } ); - match &self_ty.kind() { + match &self_ty.data() { // Point at the type that couldn't satisfy the bound. ty::Adt(def, _) => bound_spans.push((def_span(def.did), msg)), // Point at the trait object that couldn't satisfy the bound. @@ -837,7 +837,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); self.suggest_use_candidates(&mut err, help, candidates); } - if let ty::Ref(region, t_type, mutability) = rcvr_ty.kind() { + if let ty::Ref(region, t_type, mutability) = rcvr_ty.data() { if needs_mut { let trait_type = self.tcx.mk_ref( region, @@ -856,7 +856,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Print out the type for use in value namespace. fn ty_to_value_string(&self, ty: Ty<'tcx>) -> String { - match ty.kind() { + match ty.data() { ty::Adt(def, substs) => format!("{}", ty::Instance::new(def.did, substs)), _ => self.ty_to_string(ty), } @@ -870,7 +870,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { call: &hir::Expr<'_>, span: Span, ) { - if let ty::Opaque(def_id, _) = *ty.kind() { + if let ty::Opaque(def_id, _) = *ty.data() { let future_trait = self.tcx.require_lang_item(LangItem::Future, None); // Future::Output let item_def_id = self @@ -897,7 +897,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { debug!( "suggest_await_before_method: normalized_ty={:?}, ty_kind={:?}", self.resolve_vars_if_possible(&normalized_ty), - normalized_ty.kind(), + normalized_ty.data(), ); let method_exists = self.method_exists(item_name, normalized_ty, call.hir_id, true); debug!("suggest_await_before_method: is_method_exist={}", method_exists); @@ -1089,9 +1089,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { candidates.sort_by(|a, b| a.cmp(b).reverse()); candidates.dedup(); - let param_type = match rcvr_ty.kind() { + let param_type = match rcvr_ty.data() { ty::Param(param) => Some(param), - ty::Ref(_, ty, _) => match ty.kind() { + ty::Ref(_, ty, _) => match ty.data() { ty::Param(param) => Some(param), _ => None, }, @@ -1243,7 +1243,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// autoderefs of `rcvr_ty`. fn type_derefs_to_local(&self, span: Span, rcvr_ty: Ty<'tcx>, source: SelfSource<'_>) -> bool { fn is_local(ty: Ty<'_>) -> bool { - match ty.kind() { + match ty.data() { ty::Adt(def, _) => def.did.is_local(), ty::Foreign(did) => did.is_local(), diff --git a/compiler/rustc_typeck/src/check/mod.rs b/compiler/rustc_typeck/src/check/mod.rs index 97172d391ba65..c2f4de38fa5cd 100644 --- a/compiler/rustc_typeck/src/check/mod.rs +++ b/compiler/rustc_typeck/src/check/mod.rs @@ -375,7 +375,7 @@ where } fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { - match *ty.kind() { + match *ty.data() { ty::Opaque(def_id, substs) => { debug!("fixup_opaque_types: found type {:?}", ty); // Here, we replace any inference variables that occur within @@ -391,7 +391,7 @@ where let old_param = substs[param.index as usize]; match old_param.unpack() { GenericArgKind::Type(old_ty) => { - if let ty::Infer(_) = old_ty.kind() { + if let ty::Infer(_) = old_ty.data() { // Replace inference type with a generic parameter self.tcx.mk_param_from_def(param) } else { @@ -873,7 +873,7 @@ fn bounds_from_generic_predicates<'tcx>( "<{}>", types .keys() - .filter_map(|t| match t.kind() { + .filter_map(|t| match t.data() { ty::Param(_) => Some(t.to_string()), // Avoid suggesting the following: // fn foo::Bar>(_: T) where T: Trait, ::Bar: Other {} @@ -918,7 +918,7 @@ fn fn_sig_suggestion<'tcx>( .iter() .enumerate() .map(|(i, ty)| { - Some(match ty.kind() { + Some(match ty.data() { ty::Param(_) if assoc.fn_has_self_parameter && i == 0 => "self".to_string(), ty::Ref(reg, ref_ty, mutability) if i == 0 => { let reg = match &format!("{}", reg)[..] { @@ -926,7 +926,7 @@ fn fn_sig_suggestion<'tcx>( reg => format!("{} ", reg), }; if assoc.fn_has_self_parameter { - match ref_ty.kind() { + match ref_ty.data() { ty::Param(param) if param.name == kw::SelfUpper => { format!("&{}{}self", reg, mutability.prefix_str()) } diff --git a/compiler/rustc_typeck/src/check/op.rs b/compiler/rustc_typeck/src/check/op.rs index 2f3fb49717b9c..76988a0aae23f 100644 --- a/compiler/rustc_typeck/src/check/op.rs +++ b/compiler/rustc_typeck/src/check/op.rs @@ -10,7 +10,7 @@ use rustc_middle::ty::adjustment::{ Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability, }; use rustc_middle::ty::fold::TypeFolder; -use rustc_middle::ty::TyKind::{Adt, Array, Char, FnDef, Never, Ref, Str, Tuple, Uint}; +use rustc_middle::ty::TyData::{Adt, Array, Char, FnDef, Never, Ref, Str, Tuple, Uint}; use rustc_middle::ty::{ self, suggest_constraining_type_param, Ty, TyCtxt, TypeFoldable, TypeVisitor, }; @@ -208,7 +208,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Ok(method) => { 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() { + if let ty::Ref(region, _, mutbl) = method.sig.inputs()[0].data() { let mutbl = match mutbl { hir::Mutability::Not => AutoBorrowMutability::Not, hir::Mutability::Mut => AutoBorrowMutability::Mut { @@ -225,7 +225,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } if by_ref_binop { - if let ty::Ref(region, _, mutbl) = method.sig.inputs()[1].kind() { + if let ty::Ref(region, _, mutbl) = method.sig.inputs()[1].data() { let mutbl = match mutbl { hir::Mutability::Not => AutoBorrowMutability::Not, hir::Mutability::Mut => AutoBorrowMutability::Mut { @@ -397,7 +397,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } }; let mut suggested_deref = false; - if let Ref(_, rty, _) = lhs_ty.kind() { + if let Ref(_, rty, _) = lhs_ty.data() { if { self.infcx.type_is_copy_modulo_regions(self.param_env, rty, lhs_expr.span) && self @@ -438,7 +438,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // concatenation (e.g., "Hello " + "World!"). This means // we don't want the note in the else clause to be emitted } else if let [ty] = &visitor.0[..] { - if let ty::Param(p) = *ty.kind() { + if let ty::Param(p) = *ty.data() { // Check if the method would be found if the type param wasn't // involved. If so, it means that adding a trait bound to the param is // enough. Otherwise we do not give the suggestion. @@ -470,7 +470,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { )); } } else { - bug!("type param visitor stored a non type param: {:?}", ty.kind()); + bug!("type param visitor stored a non type param: {:?}", ty.data()); } } else if !suggested_deref && !involves_fn { suggest_impl_missing(&mut err, lhs_ty, &missing_trait); @@ -496,7 +496,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { is_assign: IsAssign, ) -> bool /* did we suggest to call a function because of missing parenthesis? */ { err.span_label(span, ty.to_string()); - if let FnDef(def_id, _) = *ty.kind() { + if let FnDef(def_id, _) = *ty.data() { let source_map = self.tcx.sess.source_map(); if !self.tcx.has_typeck_results(def_id) { return false; @@ -504,7 +504,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // We're emitting a suggestion, so we can just ignore regions let fn_sig = self.tcx.fn_sig(def_id).skip_binder(); - let other_ty = if let FnDef(def_id, _) = *other_ty.kind() { + let other_ty = if let FnDef(def_id, _) = *other_ty.data() { if !self.tcx.has_typeck_results(def_id) { return false; } @@ -570,10 +570,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { None => false, }; - match (lhs_ty.kind(), rhs_ty.kind()) { + match (lhs_ty.data(), rhs_ty.data()) { (&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) || + if (*l_ty.data() == Str || is_std_string(l_ty)) && ( + *r_ty.data() == Str || is_std_string(r_ty) || &format!("{:?}", rhs_ty) == "&&str" ) => { @@ -607,7 +607,7 @@ 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) => + if (*l_ty.data() == Str || is_std_string(l_ty)) && is_std_string(rhs_ty) => { err.span_label( op.span, @@ -672,7 +672,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ex.span, format!("cannot apply unary operator `{}`", op.as_str()), ); - match actual.kind() { + match actual.data() { Uint(_) if op == hir::UnOp::UnNeg => { err.note("unsigned values cannot be negated"); @@ -700,7 +700,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } Str | Never | Char | Tuple(_) | Array(_, _) => {} - Ref(_, ref lty, _) if *lty.kind() == Str => {} + Ref(_, ref lty, _) if *lty.data() == Str => {} _ => { let missing_trait = match op { hir::UnOp::UnNeg => "std::ops::Neg", @@ -869,7 +869,7 @@ enum Op { /// Dereferences a single level of immutable referencing. fn deref_ty_if_possible(ty: Ty<'tcx>) -> Ty<'tcx> { - match ty.kind() { + match ty.data() { ty::Ref(_, ty, hir::Mutability::Not) => ty, _ => ty, } @@ -928,7 +928,7 @@ fn is_builtin_binop<'tcx>(lhs: Ty<'tcx>, rhs: Ty<'tcx>, op: hir::BinOp) -> bool /// If applicable, note that an implementation of `trait` for `ty` may fix the error. fn suggest_impl_missing(err: &mut DiagnosticBuilder<'_>, ty: Ty<'_>, missing_trait: &str) { - if let Adt(def, _) = ty.peel_refs().kind() { + if let Adt(def, _) = ty.peel_refs().data() { if def.did.is_local() { err.note(&format!( "an implementation of `{}` might be missing for `{}`", @@ -982,7 +982,7 @@ struct TypeParamVisitor<'tcx>(Vec>); impl<'tcx> TypeVisitor<'tcx> for TypeParamVisitor<'tcx> { fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool { - if let ty::Param(_) = ty.kind() { + if let ty::Param(_) = ty.data() { self.0.push(ty); } ty.super_visit_with(self) @@ -997,7 +997,7 @@ impl TypeFolder<'tcx> for TypeParamEraser<'_, 'tcx> { } fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { - match ty.kind() { + match ty.data() { ty::Param(_) => self.0.next_ty_var(TypeVariableOrigin { kind: TypeVariableOriginKind::MiscVariable, span: self.1, diff --git a/compiler/rustc_typeck/src/check/pat.rs b/compiler/rustc_typeck/src/check/pat.rs index 53bc2069b76ce..84e575c29b0c5 100644 --- a/compiler/rustc_typeck/src/check/pat.rs +++ b/compiler/rustc_typeck/src/check/pat.rs @@ -282,7 +282,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // String and byte-string literals result in types `&str` and `&[u8]` respectively. // All other literals result in non-reference types. // As a result, we allow `if let 0 = &&0 {}` but not `if let "foo" = &&"foo {}`. - PatKind::Lit(lt) => match self.check_expr(lt).kind() { + PatKind::Lit(lt) => match self.check_expr(lt).data() { ty::Ref(..) => AdjustMode::Pass, _ => AdjustMode::Peel, }, @@ -342,7 +342,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.data() { debug!("inspecting {:?}", expected); debug!("current discriminant is Ref, inserting implicit deref"); @@ -390,8 +390,8 @@ 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_resolved_type(span, expected); - if let ty::Ref(_, inner_ty, _) = expected.kind() { - if matches!(inner_ty.kind(), ty::Slice(_)) { + if let ty::Ref(_, inner_ty, _) = expected.data() { + if matches!(inner_ty.data(), ty::Slice(_)) { let tcx = self.tcx; pat_ty = tcx.mk_imm_ref(tcx.lifetimes.re_static, tcx.mk_slice(tcx.types.u8)); } @@ -642,7 +642,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn check_dereferenceable(&self, span: Span, expected: Ty<'tcx>, inner: &Pat<'_>) -> bool { if let PatKind::Binding(..) = inner.kind { if let Some(mt) = self.shallow_resolve(expected).builtin_deref(true) { - if let ty::Dynamic(..) = mt.ty.kind() { + if let ty::Dynamic(..) = mt.ty.data() { // This is "x = SomeTrait" being reduced from // "let &x = &SomeTrait" or "let box x = Box", an error. let type_str = self.ty_to_string(expected); @@ -807,7 +807,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); } _ => { - let (type_def_id, item_def_id) = match pat_ty.kind() { + let (type_def_id, item_def_id) = match pat_ty.data() { Adt(def, _) => match res { Res::Def(DefKind::Const, def_id) => (Some(def.did), Some(def_id)), _ => (None, None), @@ -939,7 +939,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if subpats.len() == variant.fields.len() || subpats.len() < variant.fields.len() && ddpos.is_some() { - let substs = match pat_ty.kind() { + let substs = match pat_ty.data() { ty::Adt(_, substs) => substs, _ => bug!("unexpected pattern type {:?}", pat_ty), }; @@ -992,13 +992,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // More generally, the expected type wants a tuple variant with one field of an // N-arity-tuple, e.g., `V_i((p_0, .., p_N))`. Meanwhile, the user supplied a pattern // with the subpatterns directly in the tuple variant pattern, e.g., `V_i(p_0, .., p_N)`. - let missing_parenthesis = match (&expected.kind(), fields, had_err) { + let missing_parenthesis = match (&expected.data(), fields, had_err) { // #67037: only do this if we could successfully type-check the expected type against // the tuple struct pattern. Otherwise the substs could get out of range on e.g., // `let P() = U;` where `P != U` with `struct P(T);`. (ty::Adt(_, substs), [field], false) => { let field_ty = self.field_ty(pat_span, field, substs); - match field_ty.kind() { + match field_ty.data() { ty::Tuple(_) => field_ty.tuple_fields().count() == subpats.len(), _ => false, } @@ -1049,7 +1049,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut expected_len = elements.len(); if ddpos.is_some() { // Require known type only when `..` is present. - if let ty::Tuple(ref tys) = self.structurally_resolved_type(span, expected).kind() { + if let ty::Tuple(ref tys) = self.structurally_resolved_type(span, expected).data() { expected_len = tys.len(); } } @@ -1093,7 +1093,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) -> bool { let tcx = self.tcx; - let (substs, adt) = match adt_ty.kind() { + let (substs, adt) = match adt_ty.data() { ty::Adt(adt, substs) => (substs, adt), _ => span_bug!(pat.span, "struct pattern is not an ADT"), }; @@ -1557,7 +1557,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.data() { ty::Ref(_, r_ty, r_mutbl) if r_mutbl == mutbl => (expected, r_ty), _ => { let inner_ty = self.next_ty_var(TypeVariableOrigin { @@ -1613,7 +1613,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ti: TopInfo<'tcx>, ) -> Ty<'tcx> { let expected = self.structurally_resolved_type(span, expected); - let (element_ty, opt_slice_ty, inferred) = match *expected.kind() { + let (element_ty, opt_slice_ty, inferred) = match *expected.data() { // 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; @@ -1749,8 +1749,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { "expected an array or slice, found `{}`", expected_ty ); - if let ty::Ref(_, ty, _) = expected_ty.kind() { - if let ty::Array(..) | ty::Slice(..) = ty.kind() { + if let ty::Ref(_, ty, _) = expected_ty.data() { + if let ty::Array(..) | ty::Slice(..) = ty.data() { err.help("the semantics of slice patterns changed recently; see issue #62254"); } } diff --git a/compiler/rustc_typeck/src/check/place_op.rs b/compiler/rustc_typeck/src/check/place_op.rs index 502cb562385e0..e34f5bdaaf24c 100644 --- a/compiler/rustc_typeck/src/check/place_op.rs +++ b/compiler/rustc_typeck/src/check/place_op.rs @@ -25,7 +25,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let ok = self.try_overloaded_deref(expr.span, oprnd_ty)?; let method = self.register_infer_ok_obligations(ok); - if let ty::Ref(region, _, hir::Mutability::Not) = method.sig.inputs()[0].kind() { + if let ty::Ref(region, _, hir::Mutability::Not) = method.sig.inputs()[0].data() { self.apply_adjustments( oprnd_expr, vec![Adjustment { @@ -86,7 +86,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut self_ty = adjusted_ty; if unsize { // We only unsize arrays here. - if let ty::Array(element_ty, _) = adjusted_ty.kind() { + if let ty::Array(element_ty, _) = adjusted_ty.data() { self_ty = self.tcx.mk_slice(element_ty); } else { continue; @@ -108,7 +108,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let method = self.register_infer_ok_obligations(ok); let mut adjustments = self.adjust_steps(autoderef); - if let ty::Ref(region, _, hir::Mutability::Not) = method.sig.inputs()[0].kind() { + if let ty::Ref(region, _, hir::Mutability::Not) = method.sig.inputs()[0].data() { adjustments.push(Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(region, AutoBorrowMutability::Not)), target: self.tcx.mk_ref( @@ -241,7 +241,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { PlaceOp::Deref, ) { 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().data() { *deref = OverloadedDeref { region, mutbl, span: deref.span }; } // If this is a union field, also throw an error for `DerefMut` of `ManuallyDrop` (see RFC 2514). @@ -328,7 +328,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { debug!("convert_place_op_to_mutable: method={:?}", method); self.write_method_call(expr.hir_id, method); - let region = if let ty::Ref(r, _, hir::Mutability::Mut) = method.sig.inputs()[0].kind() { + let region = if let ty::Ref(r, _, hir::Mutability::Mut) = method.sig.inputs()[0].data() { r } else { span_bug!(expr.span, "input to mutable place op is not a mut ref?"); diff --git a/compiler/rustc_typeck/src/check/regionck.rs b/compiler/rustc_typeck/src/check/regionck.rs index ba0f22513a146..cdb623500d26a 100644 --- a/compiler/rustc_typeck/src/check/regionck.rs +++ b/compiler/rustc_typeck/src/check/regionck.rs @@ -624,7 +624,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> { ); let rptr_ty = self.resolve_node_type(id); - if let ty::Ref(r, _, _) = rptr_ty.kind() { + if let ty::Ref(r, _, _) = rptr_ty.data() { debug!("rptr_ty={}", rptr_ty); self.link_region(span, r, ty::BorrowKind::from_mutbl(mutbl), cmt_borrowed); } @@ -649,7 +649,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> { "link_region(borrow_region={:?}, borrow_kind={:?}, pointer_ty={:?})", borrow_region, borrow_kind, borrow_place ); - match *pointer_ty.kind() { + match *pointer_ty.data() { ty::RawPtr(_) => return, ty::Ref(ref_region, _, ref_mutability) => { if self.link_reborrowed_region(span, borrow_region, ref_region, ref_mutability) @@ -794,7 +794,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> { // A closure capture can't be borrowed for longer than the // reference to the closure. - if let ty::Closure(_, substs) = ty.kind() { + if let ty::Closure(_, substs) = ty.data() { match self.infcx.closure_kind(substs) { Some(ty::ClosureKind::Fn | ty::ClosureKind::FnMut) => { // Region of environment pointer diff --git a/compiler/rustc_typeck/src/check/upvar.rs b/compiler/rustc_typeck/src/check/upvar.rs index 2c3be0da5ddd0..83e5b93b33f59 100644 --- a/compiler/rustc_typeck/src/check/upvar.rs +++ b/compiler/rustc_typeck/src/check/upvar.rs @@ -88,7 +88,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, substs) = match *ty.kind() { + let (closure_def_id, substs) = match *ty.data() { ty::Closure(def_id, substs) => (def_id, UpvarSubsts::Closure(substs)), ty::Generator(def_id, substs, _) => (def_id, UpvarSubsts::Generator(substs)), ty::Error(_) => { @@ -349,7 +349,7 @@ impl<'a, 'tcx> InferBorrowKind<'a, 'tcx> { if let PlaceBase::Upvar(upvar_id) = place_with_id.place.base { let mut borrow_kind = ty::MutBorrow; for pointer_ty in place_with_id.place.deref_tys() { - match pointer_ty.kind() { + match pointer_ty.data() { // Raw pointers don't inherit mutability. ty::RawPtr(_) => return, // assignment to deref of an `&mut` diff --git a/compiler/rustc_typeck/src/check/wfcheck.rs b/compiler/rustc_typeck/src/check/wfcheck.rs index b4e950ab6e9e5..e89264f0ddcaf 100644 --- a/compiler/rustc_typeck/src/check/wfcheck.rs +++ b/compiler/rustc_typeck/src/check/wfcheck.rs @@ -291,7 +291,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) { let err_ty_str; let mut is_ptr = true; let err = if tcx.features().min_const_generics { - match ty.kind() { + match ty.data() { ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Error(_) => None, ty::FnPtr(_) => Some("function pointers"), ty::RawPtr(_) => Some("raw pointers"), @@ -302,7 +302,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) { } } } else { - match ty.peel_refs().kind() { + match ty.peel_refs().data() { ty::FnPtr(_) => Some("function pointers"), ty::RawPtr(_) => Some("raw pointers"), _ => None, @@ -338,7 +338,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) { // We use the same error code in both branches, because this is really the same // issue: we just special-case the message for type parameters to make it // clearer. - if let ty::Param(_) = ty.peel_refs().kind() { + if let ty::Param(_) = ty.peel_refs().data() { // Const parameters may not have type parameters as their types, // because we cannot be sure that the type parameter derives `PartialEq` // and `Eq` (just implementing them is not enough for `structural_match`). @@ -641,7 +641,7 @@ fn check_item_type(tcx: TyCtxt<'_>, item_id: hir::HirId, ty_span: Span, allow_fo let mut forbid_unsized = true; if allow_foreign_ty { let tail = fcx.tcx.struct_tail_erasing_lifetimes(item_ty, fcx.param_env); - if let ty::Foreign(_) = tail.kind() { + if let ty::Foreign(_) = tail.data() { forbid_unsized = false; } } @@ -799,7 +799,7 @@ fn check_where_clauses<'tcx, 'fcx>( } impl<'tcx> ty::fold::TypeVisitor<'tcx> for CountParams { fn visit_ty(&mut self, t: Ty<'tcx>) -> bool { - if let ty::Param(param) = t.kind() { + if let ty::Param(param) = t.data() { self.params.insert(param.index); } t.super_visit_with(self) @@ -933,7 +933,7 @@ fn check_opaque_types<'fcx, 'tcx>( ty.fold_with(&mut ty::fold::BottomUpFolder { tcx: fcx.tcx, ty_op: |ty| { - if let ty::Opaque(def_id, substs) = *ty.kind() { + if let ty::Opaque(def_id, substs) = *ty.data() { trace!("check_opaque_types: opaque_ty, {:?}, {:?}", def_id, substs); let generics = tcx.generics_of(def_id); @@ -976,7 +976,7 @@ fn check_opaque_types<'fcx, 'tcx>( let mut seen_params: FxHashMap<_, Vec<_>> = FxHashMap::default(); for (i, arg) in substs.iter().enumerate() { let arg_is_param = match arg.unpack() { - GenericArgKind::Type(ty) => matches!(ty.kind(), ty::Param(_)), + GenericArgKind::Type(ty) => matches!(ty.data(), ty::Param(_)), GenericArgKind::Lifetime(region) => { if let ty::ReStatic = region { diff --git a/compiler/rustc_typeck/src/check/writeback.rs b/compiler/rustc_typeck/src/check/writeback.rs index 5363702a5be6d..84e22e5fe407c 100644 --- a/compiler/rustc_typeck/src/check/writeback.rs +++ b/compiler/rustc_typeck/src/check/writeback.rs @@ -191,7 +191,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { let mut typeck_results = self.fcx.typeck_results.borrow_mut(); // All valid indexing looks like this; might encounter non-valid indexes at this point. - let base_ty = typeck_results.expr_ty_adjusted_opt(&base).map(|t| t.kind()); + let base_ty = typeck_results.expr_ty_adjusted_opt(&base).map(|t| t.data()); if base_ty.is_none() { // When encountering `return [0][0]` outside of a `fn` body we can encounter a base // that isn't in the type table. We assume more relevant errors have already been @@ -457,7 +457,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { let mut skip_add = false; - if let ty::Opaque(defin_ty_def_id, _substs) = *definition_ty.kind() { + if let ty::Opaque(defin_ty_def_id, _substs) = *definition_ty.data() { if let hir::OpaqueTyOrigin::Misc = opaque_defn.origin { if def_id == defin_ty_def_id { debug!( diff --git a/compiler/rustc_typeck/src/coherence/builtin.rs b/compiler/rustc_typeck/src/coherence/builtin.rs index 89270fb6c77a5..e0d43f1de457f 100644 --- a/compiler/rustc_typeck/src/coherence/builtin.rs +++ b/compiler/rustc_typeck/src/coherence/builtin.rs @@ -49,7 +49,7 @@ impl<'tcx> Checker<'tcx> { fn visit_implementation_of_drop(tcx: TyCtxt<'_>, impl_did: LocalDefId) { // Destructors only work on nominal types. - if let ty::Adt(..) | ty::Error(_) = tcx.type_of(impl_did).kind() { + if let ty::Adt(..) | ty::Error(_) = tcx.type_of(impl_did).data() { return; } @@ -146,8 +146,8 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef tcx.infer_ctxt().enter(|infcx| { let cause = ObligationCause::misc(span, impl_hir_id); - use ty::TyKind::*; - match (source.kind(), target.kind()) { + use ty::TyData::*; + match (source.data(), target.data()) { (&Ref(r_a, _, mutbl_a), Ref(r_b, _, mutbl_b)) if infcx.at(&cause, param_env).eq(r_a, r_b).is_ok() && mutbl_a == *mutbl_b => {} (&RawPtr(tm_a), &RawPtr(tm_b)) if tm_a.mutbl == tm_b.mutbl => (), @@ -331,7 +331,7 @@ pub fn coerce_unsized_info(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUnsizedI } (mt_a.ty, mt_b.ty, unsize_trait, None) }; - let (source, target, trait_def_id, kind) = match (source.kind(), target.kind()) { + let (source, target, trait_def_id, kind) = match (source.data(), target.data()) { (&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 }; diff --git a/compiler/rustc_typeck/src/coherence/inherent_impls.rs b/compiler/rustc_typeck/src/coherence/inherent_impls.rs index 373acb95c9e37..116e2c889b1af 100644 --- a/compiler/rustc_typeck/src/coherence/inherent_impls.rs +++ b/compiler/rustc_typeck/src/coherence/inherent_impls.rs @@ -52,7 +52,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> { let def_id = self.tcx.hir().local_def_id(item.hir_id); let self_ty = self.tcx.type_of(def_id); let lang_items = self.tcx.lang_items(); - match *self_ty.kind() { + match *self_ty.data() { ty::Adt(def, _) => { self.check_def_id(item, def.did); } @@ -123,7 +123,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> { ); } ty::RawPtr(ty::TypeAndMut { ty: inner, mutbl: hir::Mutability::Not }) - if matches!(inner.kind(), ty::Slice(_)) => + if matches!(inner.data(), ty::Slice(_)) => { self.check_primitive_impl( def_id, @@ -135,7 +135,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> { ); } ty::RawPtr(ty::TypeAndMut { ty: inner, mutbl: hir::Mutability::Mut }) - if matches!(inner.kind(), ty::Slice(_)) => + if matches!(inner.data(), ty::Slice(_)) => { self.check_primitive_impl( def_id, @@ -318,7 +318,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> { err.span_label(ty.span, "impl requires a nominal type") .note("either implement a trait on it or create a newtype to wrap it instead"); - if let ty::Ref(_, subty, _) = self_ty.kind() { + if let ty::Ref(_, subty, _) = self_ty.data() { err.note(&format!( "you could also try moving the reference to \ uses of `{}` (such as `self`) within the implementation", diff --git a/compiler/rustc_typeck/src/coherence/mod.rs b/compiler/rustc_typeck/src/coherence/mod.rs index 4294450333ca3..561da804f247e 100644 --- a/compiler/rustc_typeck/src/coherence/mod.rs +++ b/compiler/rustc_typeck/src/coherence/mod.rs @@ -209,7 +209,7 @@ fn check_object_overlap<'tcx>( } // check for overlap with the automatic `impl Trait for dyn Trait` - if let ty::Dynamic(ref data, ..) = trait_ref.self_ty().kind() { + if let ty::Dynamic(ref data, ..) = trait_ref.self_ty().data() { // This is something like impl Trait1 for Trait2. Illegal // if Trait1 is a supertrait of Trait2 or Trait2 is not object safe. diff --git a/compiler/rustc_typeck/src/coherence/orphan.rs b/compiler/rustc_typeck/src/coherence/orphan.rs index 917fc5631c4f5..077e795da7571 100644 --- a/compiler/rustc_typeck/src/coherence/orphan.rs +++ b/compiler/rustc_typeck/src/coherence/orphan.rs @@ -52,7 +52,7 @@ impl ItemLikeVisitor<'v> for OrphanChecker<'tcx> { // Remove the lifetimes unnecessary for this error. ty = infcx.freshen(ty); }); - ty = match ty.kind() { + ty = match ty.data() { // Remove the type arguments from the output, as they are not relevant. // You can think of this as the reverse of `resolve_vars_if_possible`. // That way if we had `Vec`, we will properly attribute the @@ -62,7 +62,7 @@ impl ItemLikeVisitor<'v> for OrphanChecker<'tcx> { _ => ty, }; let this = "this".to_string(); - let (ty, postfix) = match &ty.kind() { + let (ty, postfix) = match &ty.data() { ty::Slice(_) => (this, " because slices are always foreign"), ty::Array(..) => (this, " because arrays are always foreign"), ty::Tuple(..) => (this, " because tuples are always foreign"), @@ -185,7 +185,7 @@ impl ItemLikeVisitor<'v> for OrphanChecker<'tcx> { ); if self.tcx.trait_is_auto(trait_def_id) && !trait_def_id.is_local() { let self_ty = trait_ref.self_ty(); - let opt_self_def_id = match *self_ty.kind() { + let opt_self_def_id = match *self_ty.data() { ty::Adt(self_def, _) => Some(self_def.did), ty::Foreign(did) => Some(did), _ => None, @@ -231,7 +231,7 @@ impl ItemLikeVisitor<'v> for OrphanChecker<'tcx> { } } - if let ty::Opaque(def_id, _) = *trait_ref.self_ty().kind() { + if let ty::Opaque(def_id, _) = *trait_ref.self_ty().data() { self.tcx .sess .struct_span_err(sp, "cannot implement trait on type alias impl trait") diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index b64a1ce7c3082..014b72de40ac3 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -1911,7 +1911,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP // That way, `where Ty:` is not a complete noop (see #53696) and `Ty` // is still checked for WF. if bound_pred.bounds.is_empty() { - if let ty::Param(_) = ty.kind() { + if let ty::Param(_) = ty.data() { // This is a `where T:`, which can be in the HIR from the // transformation that moves `?Sized` to `T`'s declaration. // We can skip the predicate because type parameters are @@ -2142,7 +2142,7 @@ fn explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicat // substs are the same as the trait's. // * It must be an associated type for this trait (*not* a // supertrait). - if let ty::Projection(projection) = ty.kind() { + if let ty::Projection(projection) = ty.data() { if projection.substs == trait_identity_substs && tcx.associated_item(projection.item_def_id).container.id() == def_id { diff --git a/compiler/rustc_typeck/src/collect/type_of.rs b/compiler/rustc_typeck/src/collect/type_of.rs index 4b3250a1d443a..6af68a5bdc97a 100644 --- a/compiler/rustc_typeck/src/collect/type_of.rs +++ b/compiler/rustc_typeck/src/collect/type_of.rs @@ -383,7 +383,7 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> { let mut used_params: FxHashSet<_> = FxHashSet::default(); for (i, arg) in substs.iter().enumerate() { let arg_is_param = match arg.unpack() { - GenericArgKind::Type(ty) => matches!(ty.kind(), ty::Param(_)), + GenericArgKind::Type(ty) => matches!(ty.data(), ty::Param(_)), GenericArgKind::Lifetime(lt) => { matches!(lt, ty::ReEarlyBound(_) | ty::ReFree(_)) } @@ -608,7 +608,7 @@ fn infer_placeholder_type( } None => { let mut diag = bad_placeholder_type(tcx, vec![span]); - if !matches!(ty.kind(), ty::Error(_)) { + if !matches!(ty.data(), ty::Error(_)) { diag.span_suggestion( span, "replace `_` with the correct type", diff --git a/compiler/rustc_typeck/src/constrained_generic_params.rs b/compiler/rustc_typeck/src/constrained_generic_params.rs index 09b5a9b0a65fc..74cb952444781 100644 --- a/compiler/rustc_typeck/src/constrained_generic_params.rs +++ b/compiler/rustc_typeck/src/constrained_generic_params.rs @@ -57,7 +57,7 @@ struct ParameterCollector { impl<'tcx> TypeVisitor<'tcx> for ParameterCollector { fn visit_ty(&mut self, t: Ty<'tcx>) -> bool { - match *t.kind() { + match *t.data() { ty::Projection(..) | ty::Opaque(..) if !self.include_nonconstraining => { // projections are not injective return false; diff --git a/compiler/rustc_typeck/src/expr_use_visitor.rs b/compiler/rustc_typeck/src/expr_use_visitor.rs index e16f26c330401..8a66ef9711a64 100644 --- a/compiler/rustc_typeck/src/expr_use_visitor.rs +++ b/compiler/rustc_typeck/src/expr_use_visitor.rs @@ -387,7 +387,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { // Select just those fields of the `with` // expression that will actually be used - match with_place.place.ty().kind() { + match with_place.place.ty().data() { ty::Adt(adt, substs) if adt.is_struct() => { // Consume those fields of the with expression that are needed. for (f_index, with_field) in adt.non_enum_variant().fields.iter().enumerate() { diff --git a/compiler/rustc_typeck/src/lib.rs b/compiler/rustc_typeck/src/lib.rs index 7efda54fbe035..203c3904dedf0 100644 --- a/compiler/rustc_typeck/src/lib.rs +++ b/compiler/rustc_typeck/src/lib.rs @@ -159,7 +159,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: LocalDefId) { let main_id = tcx.hir().local_def_id_to_hir_id(main_def_id); let main_span = tcx.def_span(main_def_id); let main_t = tcx.type_of(main_def_id); - match main_t.kind() { + match main_t.data() { ty::FnDef(..) => { if let Some(Node::Item(it)) = tcx.hir().find(main_id) { if let hir::ItemKind::Fn(ref sig, ref generics, _) = it.kind { @@ -255,7 +255,7 @@ fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: LocalDefId) { let start_id = tcx.hir().local_def_id_to_hir_id(start_def_id); let start_span = tcx.def_span(start_def_id); let start_t = tcx.type_of(start_def_id); - match start_t.kind() { + match start_t.data() { ty::FnDef(..) => { if let Some(Node::Item(it)) = tcx.hir().find(start_id) { if let hir::ItemKind::Fn(ref sig, ref generics, _) = it.kind { diff --git a/compiler/rustc_typeck/src/mem_categorization.rs b/compiler/rustc_typeck/src/mem_categorization.rs index 04ead74936f88..a57e9b4bcd8dd 100644 --- a/compiler/rustc_typeck/src/mem_categorization.rs +++ b/compiler/rustc_typeck/src/mem_categorization.rs @@ -482,7 +482,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { let place_ty = self.expr_ty(expr)?; let base_ty = self.expr_ty_adjusted(base)?; - let (region, mutbl) = match *base_ty.kind() { + let (region, mutbl) = match *base_ty.data() { ty::Ref(region, _, mutbl) => (region, mutbl), _ => span_bug!(expr.span, "cat_overloaded_place: base is not a reference"), }; @@ -542,7 +542,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { ) -> McResult { let res = self.typeck_results.qpath_res(qpath, pat_hir_id); let ty = self.typeck_results.node_type(pat_hir_id); - let adt_def = match ty.kind() { + let adt_def = match ty.data() { ty::Adt(adt_def, _) => adt_def, _ => { self.tcx() @@ -577,7 +577,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { span: Span, ) -> McResult { let ty = self.typeck_results.node_type(pat_hir_id); - match ty.kind() { + match ty.data() { ty::Adt(adt_def, _) => Ok(adt_def.variants[variant_index].fields.len()), _ => { self.tcx() @@ -592,7 +592,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { /// Here `pat_hir_id` is the HirId of the pattern itself. fn total_fields_in_tuple(&self, pat_hir_id: hir::HirId, span: Span) -> McResult { let ty = self.typeck_results.node_type(pat_hir_id); - match ty.kind() { + match ty.data() { ty::Tuple(substs) => Ok(substs.len()), _ => { self.tcx().sess.delay_span_bug(span, "tuple pattern not applied to a tuple"); diff --git a/compiler/rustc_typeck/src/outlives/implicit_infer.rs b/compiler/rustc_typeck/src/outlives/implicit_infer.rs index e7a9e078a737f..03c9c97f3f3d8 100644 --- a/compiler/rustc_typeck/src/outlives/implicit_infer.rs +++ b/compiler/rustc_typeck/src/outlives/implicit_infer.rs @@ -128,7 +128,7 @@ fn insert_required_predicates_to_be_wf<'tcx>( GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => continue, }; - match *ty.kind() { + match *ty.data() { // The field is of type &'a T which means that we will have // a predicate requirement of T: 'a (T outlives 'a). // diff --git a/compiler/rustc_typeck/src/variance/constraints.rs b/compiler/rustc_typeck/src/variance/constraints.rs index b2b062e40951e..386dd202044f5 100644 --- a/compiler/rustc_typeck/src/variance/constraints.rs +++ b/compiler/rustc_typeck/src/variance/constraints.rs @@ -140,7 +140,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { let id = tcx.hir().local_def_id_to_hir_id(def_id); let inferred_start = self.terms_cx.inferred_starts[&id]; let current_item = &CurrentItem { inferred_start }; - match tcx.type_of(def_id).kind() { + match tcx.type_of(def_id).data() { ty::Adt(def, _) => { // Not entirely obvious: constraints on structs/enums do not // affect the variance of their type parameters. See discussion @@ -257,7 +257,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { ) { debug!("add_constraints_from_ty(ty={:?}, variance={:?})", ty, variance); - match *ty.kind() { + match *ty.data() { ty::Bool | ty::Char | ty::Int(_) diff --git a/compiler/rustc_typeck/src/variance/solve.rs b/compiler/rustc_typeck/src/variance/solve.rs index 2d3369cba7a1e..14bd87682ad63 100644 --- a/compiler/rustc_typeck/src/variance/solve.rs +++ b/compiler/rustc_typeck/src/variance/solve.rs @@ -107,7 +107,7 @@ impl<'a, 'tcx> SolveContext<'a, 'tcx> { self.enforce_const_invariance(generics, variances); // Functions are permitted to have unused generic parameters: make those invariant. - if let ty::FnDef(..) = tcx.type_of(def_id).kind() { + if let ty::FnDef(..) = tcx.type_of(def_id).data() { for variance in variances.iter_mut() { if *variance == ty::Bivariant { *variance = ty::Invariant; diff --git a/src/librustdoc/clean/blanket_impl.rs b/src/librustdoc/clean/blanket_impl.rs index de5a9a615557c..ecee99cd5d768 100644 --- a/src/librustdoc/clean/blanket_impl.rs +++ b/src/librustdoc/clean/blanket_impl.rs @@ -38,7 +38,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> { ); let trait_ref = self.cx.tcx.impl_trait_ref(impl_def_id).unwrap(); let may_apply = self.cx.tcx.infer_ctxt().enter(|infcx| { - match trait_ref.self_ty().kind() { + match trait_ref.self_ty().data() { ty::Param(_) => {} _ => return false, } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 501891da573a6..44b0889d9c1fe 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -765,17 +765,17 @@ impl<'a, 'tcx> Clean for (&'a ty::Generics, ty::GenericPredicates<'tcx let param_idx = (|| { match p.skip_binders() { ty::PredicateAtom::Trait(pred, _constness) => { - if let ty::Param(param) = pred.self_ty().kind() { + if let ty::Param(param) = pred.self_ty().data() { return Some(param.index); } } ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(ty, _reg)) => { - if let ty::Param(param) = ty.kind() { + if let ty::Param(param) = ty.data() { return Some(param.index); } } ty::PredicateAtom::Projection(p) => { - if let ty::Param(param) = p.projection_ty.self_ty().kind() { + if let ty::Param(param) = p.projection_ty.self_ty().data() { projection = Some(ty::Binder::bind(p)); return Some(param.index); } @@ -1209,7 +1209,7 @@ impl Clean for ty::AssocItem { let self_arg_ty = sig.input(0).skip_binder(); if self_arg_ty == self_ty { decl.inputs.values[0].type_ = Generic(String::from("Self")); - } else if let ty::Ref(_, ty, _) = *self_arg_ty.kind() { + } else if let ty::Ref(_, ty, _) = *self_arg_ty.data() { if ty == self_ty { match decl.inputs.values[0].type_ { BorrowedRef { ref mut type_, .. } => { @@ -1511,7 +1511,7 @@ impl Clean for hir::Ty<'_> { TyKind::Path(hir::QPath::TypeRelative(ref qself, ref segment)) => { let mut res = Res::Err; let ty = hir_ty_to_ty(cx.tcx, self); - if let ty::Projection(proj) = ty.kind() { + if let ty::Projection(proj) = ty.data() { res = Res::Def(DefKind::Trait, proj.trait_ref(cx.tcx).def_id); } let trait_path = hir::Path { span: self.span, res, segments: &[] }; @@ -1554,7 +1554,7 @@ impl Clean for hir::Ty<'_> { impl<'tcx> Clean for Ty<'tcx> { fn clean(&self, cx: &DocContext<'_>) -> Type { debug!("cleaning type: {:?}", self); - match *self.kind() { + match *self.data() { ty::Never => Never, ty::Bool => Primitive(PrimitiveType::Bool), ty::Char => Primitive(PrimitiveType::Char), diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 913342e271513..900bbcd9fbc69 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -130,7 +130,7 @@ pub fn external_generic_args( None } GenericArgKind::Type(ty) => { - ty_kind = Some(ty.kind()); + ty_kind = Some(ty.data()); Some(GenericArg::Type(ty.clean(cx))) } GenericArgKind::Const(ct) => Some(GenericArg::Const(ct.clean(cx))), @@ -472,7 +472,7 @@ pub fn print_const(cx: &DocContext<'_>, n: &'tcx ty::Const<'_>) -> String { pub fn print_evaluated_const(cx: &DocContext<'_>, def_id: DefId) -> Option { cx.tcx.const_eval_poly(def_id).ok().and_then(|val| { let ty = cx.tcx.type_of(def_id); - match (val, ty.kind()) { + match (val, ty.data()) { (_, &ty::Ref(..)) => None, (ConstValue::Scalar(_), &ty::Adt(_, _)) => None, (ConstValue::Scalar(_), _) => { @@ -497,7 +497,7 @@ fn format_integer_with_underscore_sep(num: &str) -> String { fn print_const_with_custom_print_scalar(cx: &DocContext<'_>, ct: &'tcx ty::Const<'tcx>) -> String { // Use a slightly different format for integer types which always shows the actual value. // For all other types, fallback to the original `pretty_print_const`. - match (ct.val, ct.ty.kind()) { + match (ct.val, ct.ty.data()) { (ty::ConstKind::Value(ConstValue::Scalar(Scalar::Raw { data, .. })), ty::Uint(ui)) => { format!("{}{}", format_integer_with_underscore_sep(&data.to_string()), ui.name_str()) } diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 8be9482acffde..ea1d318a0d3ee 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -204,7 +204,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { // it's a bug for the error to make it to the user return Err(ResolutionFailure::Dummy.into()); } - match cx.tcx.type_of(did).kind() { + match cx.tcx.type_of(did).data() { ty::Adt(def, _) if def.is_enum() => { if def.all_fields().any(|item| item.ident.name == variant_field_name) { Ok(( @@ -480,7 +480,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { }) } else if ns == Namespace::ValueNS { debug!("looking for variants or fields named {} for {:?}", item_name, did); - match cx.tcx.type_of(did).kind() { + match cx.tcx.type_of(did).data() { ty::Adt(def, _) => { let field = if def.is_enum() { def.all_fields().find(|item| item.ident.name == item_name) @@ -698,12 +698,12 @@ fn traits_implemented_by(cx: &DocContext<'_>, type_: DefId, module: DefId) -> Fx trace!( "comparing type {} with kind {:?} against type {:?}", impl_type, - impl_type.kind(), + impl_type.data(), type_ ); // Fast path: if this is a primitive simple `==` will work let saw_impl = impl_type == ty - || match impl_type.kind() { + || match impl_type.data() { // Check if these are the same def_id ty::Adt(def, _) => { debug!("adt def_id: {:?}", def.did); diff --git a/src/test/ui-fulldeps/internal-lints/ty_tydata_usage.rs b/src/test/ui-fulldeps/internal-lints/ty_tydata_usage.rs new file mode 100644 index 0000000000000..fc25a3e24e211 --- /dev/null +++ b/src/test/ui-fulldeps/internal-lints/ty_tydata_usage.rs @@ -0,0 +1,48 @@ +// compile-flags: -Z unstable-options + +#![feature(rustc_private)] + +extern crate rustc_middle; + +use rustc_middle::ty::{self, Ty, TyData}; + +#[deny(rustc::usage_of_ty_tydata)] +fn main() { + let data = TyData::Bool; //~ ERROR usage of `ty::TyData::` + + match data { + TyData::Bool => (), //~ ERROR usage of `ty::TyData::` + TyData::Char => (), //~ ERROR usage of `ty::TyData::` + TyData::Int(..) => (), //~ ERROR usage of `ty::TyData::` + TyData::Uint(..) => (), //~ ERROR usage of `ty::TyData::` + TyData::Float(..) => (), //~ ERROR usage of `ty::TyData::` + TyData::Adt(..) => (), //~ ERROR usage of `ty::TyData::` + TyData::Foreign(..) => (), //~ ERROR usage of `ty::TyData::` + TyData::Str => (), //~ ERROR usage of `ty::TyData::` + TyData::Array(..) => (), //~ ERROR usage of `ty::TyData::` + TyData::Slice(..) => (), //~ ERROR usage of `ty::TyData::` + TyData::RawPtr(..) => (), //~ ERROR usage of `ty::TyData::` + TyData::Ref(..) => (), //~ ERROR usage of `ty::TyData::` + TyData::FnDef(..) => (), //~ ERROR usage of `ty::TyData::` + TyData::FnPtr(..) => (), //~ ERROR usage of `ty::TyData::` + TyData::Dynamic(..) => (), //~ ERROR usage of `ty::TyData::` + TyData::Closure(..) => (), //~ ERROR usage of `ty::TyData::` + TyData::Generator(..) => (), //~ ERROR usage of `ty::TyData::` + TyData::GeneratorWitness(..) => (), //~ ERROR usage of `ty::TyData::` + TyData::Never => (), //~ ERROR usage of `ty::TyData::` + TyData::Tuple(..) => (), //~ ERROR usage of `ty::TyData::` + TyData::Projection(..) => (), //~ ERROR usage of `ty::TyData::` + TyData::Opaque(..) => (), //~ ERROR usage of `ty::TyData::` + TyData::Param(..) => (), //~ ERROR usage of `ty::TyData::` + TyData::Bound(..) => (), //~ ERROR usage of `ty::TyData::` + TyData::Placeholder(..) => (), //~ ERROR usage of `ty::TyData::` + TyData::Infer(..) => (), //~ ERROR usage of `ty::TyData::` + TyData::Error(_) => (), //~ ERROR usage of `ty::TyData::` + } + + if let ty::Int(int_ty) = data {} + + if let TyData::Int(int_ty) = data {} //~ ERROR usage of `ty::TyData::` + + fn ty_data(ty_bad: TyData<'_>, ty_good: Ty<'_>) {} //~ ERROR usage of `ty::TyData` +} diff --git a/src/test/ui-fulldeps/internal-lints/ty_tydata_usage.stderr b/src/test/ui-fulldeps/internal-lints/ty_tydata_usage.stderr new file mode 100644 index 0000000000000..dc09ed1467b74 --- /dev/null +++ b/src/test/ui-fulldeps/internal-lints/ty_tydata_usage.stderr @@ -0,0 +1,190 @@ +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:11:16 + | +LL | let data = TyData::Bool; + | ^^^^^^ help: try using ty:: directly: `ty` + | +note: the lint level is defined here + --> $DIR/ty_tydata_usage.rs:9:8 + | +LL | #[deny(rustc::usage_of_ty_tydata)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:14:9 + | +LL | TyData::Bool => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:15:9 + | +LL | TyData::Char => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:16:9 + | +LL | TyData::Int(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:17:9 + | +LL | TyData::Uint(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:18:9 + | +LL | TyData::Float(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:19:9 + | +LL | TyData::Adt(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:20:9 + | +LL | TyData::Foreign(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:21:9 + | +LL | TyData::Str => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:22:9 + | +LL | TyData::Array(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:23:9 + | +LL | TyData::Slice(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:24:9 + | +LL | TyData::RawPtr(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:25:9 + | +LL | TyData::Ref(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:26:9 + | +LL | TyData::FnDef(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:27:9 + | +LL | TyData::FnPtr(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:28:9 + | +LL | TyData::Dynamic(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:29:9 + | +LL | TyData::Closure(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:30:9 + | +LL | TyData::Generator(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:31:9 + | +LL | TyData::GeneratorWitness(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:32:9 + | +LL | TyData::Never => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:33:9 + | +LL | TyData::Tuple(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:34:9 + | +LL | TyData::Projection(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:35:9 + | +LL | TyData::Opaque(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:36:9 + | +LL | TyData::Param(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:37:9 + | +LL | TyData::Bound(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:38:9 + | +LL | TyData::Placeholder(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:39:9 + | +LL | TyData::Infer(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:40:9 + | +LL | TyData::Error(_) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData::` + --> $DIR/ty_tydata_usage.rs:45:12 + | +LL | if let TyData::Int(int_ty) = data {} + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyData` + --> $DIR/ty_tydata_usage.rs:47:24 + | +LL | fn ty_data(ty_bad: TyData<'_>, ty_good: Ty<'_>) {} + | ^^^^^^^^^^ + | + = help: try using `Ty` instead + +error: aborting due to 30 previous errors + diff --git a/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs b/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs deleted file mode 100644 index 973294e985f7a..0000000000000 --- a/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs +++ /dev/null @@ -1,48 +0,0 @@ -// compile-flags: -Z unstable-options - -#![feature(rustc_private)] - -extern crate rustc_middle; - -use rustc_middle::ty::{self, Ty, TyKind}; - -#[deny(rustc::usage_of_ty_tykind)] -fn main() { - let kind = TyKind::Bool; //~ ERROR usage of `ty::TyKind::` - - match kind { - TyKind::Bool => (), //~ ERROR usage of `ty::TyKind::` - TyKind::Char => (), //~ ERROR usage of `ty::TyKind::` - TyKind::Int(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::Uint(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::Float(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::Adt(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::Foreign(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::Str => (), //~ ERROR usage of `ty::TyKind::` - TyKind::Array(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::Slice(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::RawPtr(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::Ref(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::FnDef(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::FnPtr(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::Dynamic(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::Closure(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::Generator(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::GeneratorWitness(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::Never => (), //~ ERROR usage of `ty::TyKind::` - TyKind::Tuple(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::Projection(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::Opaque(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::Param(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::Bound(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::Placeholder(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::Infer(..) => (), //~ ERROR usage of `ty::TyKind::` - TyKind::Error(_) => (), //~ ERROR usage of `ty::TyKind::` - } - - if let ty::Int(int_ty) = kind {} - - if let TyKind::Int(int_ty) = kind {} //~ ERROR usage of `ty::TyKind::` - - fn ty_kind(ty_bad: TyKind<'_>, ty_good: Ty<'_>) {} //~ ERROR usage of `ty::TyKind` -} diff --git a/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr b/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr deleted file mode 100644 index d6e4c85c190d5..0000000000000 --- a/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr +++ /dev/null @@ -1,190 +0,0 @@ -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:11:16 - | -LL | let kind = TyKind::Bool; - | ^^^^^^ help: try using ty:: directly: `ty` - | -note: the lint level is defined here - --> $DIR/ty_tykind_usage.rs:9:8 - | -LL | #[deny(rustc::usage_of_ty_tykind)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:14:9 - | -LL | TyKind::Bool => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:15:9 - | -LL | TyKind::Char => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:16:9 - | -LL | TyKind::Int(..) => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:17:9 - | -LL | TyKind::Uint(..) => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:18:9 - | -LL | TyKind::Float(..) => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:19:9 - | -LL | TyKind::Adt(..) => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:20:9 - | -LL | TyKind::Foreign(..) => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:21:9 - | -LL | TyKind::Str => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:22:9 - | -LL | TyKind::Array(..) => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:23:9 - | -LL | TyKind::Slice(..) => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:24:9 - | -LL | TyKind::RawPtr(..) => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:25:9 - | -LL | TyKind::Ref(..) => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:26:9 - | -LL | TyKind::FnDef(..) => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:27:9 - | -LL | TyKind::FnPtr(..) => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:28:9 - | -LL | TyKind::Dynamic(..) => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:29:9 - | -LL | TyKind::Closure(..) => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:30:9 - | -LL | TyKind::Generator(..) => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:31:9 - | -LL | TyKind::GeneratorWitness(..) => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:32:9 - | -LL | TyKind::Never => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:33:9 - | -LL | TyKind::Tuple(..) => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:34:9 - | -LL | TyKind::Projection(..) => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:35:9 - | -LL | TyKind::Opaque(..) => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:36:9 - | -LL | TyKind::Param(..) => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:37:9 - | -LL | TyKind::Bound(..) => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:38:9 - | -LL | TyKind::Placeholder(..) => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:39:9 - | -LL | TyKind::Infer(..) => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:40:9 - | -LL | TyKind::Error(_) => (), - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind::` - --> $DIR/ty_tykind_usage.rs:45:12 - | -LL | if let TyKind::Int(int_ty) = kind {} - | ^^^^^^ help: try using ty:: directly: `ty` - -error: usage of `ty::TyKind` - --> $DIR/ty_tykind_usage.rs:47:24 - | -LL | fn ty_kind(ty_bad: TyKind<'_>, ty_good: Ty<'_>) {} - | ^^^^^^^^^^ - | - = help: try using `Ty` instead - -error: aborting due to 30 previous errors - diff --git a/src/tools/clippy/clippy_dev/src/lib.rs b/src/tools/clippy/clippy_dev/src/lib.rs index 43cb2954b74b3..ff5db16ea9f03 100644 --- a/src/tools/clippy/clippy_dev/src/lib.rs +++ b/src/tools/clippy/clippy_dev/src/lib.rs @@ -319,7 +319,7 @@ pub fn clippy_project_root() -> PathBuf { for path in current_dir.ancestors() { let result = std::fs::read_to_string(path.join("Cargo.toml")); if let Err(err) = &result { - if err.kind() == std::io::ErrorKind::NotFound { + if err.data() == std::io::ErrorKind::NotFound { continue; } } diff --git a/src/tools/clippy/clippy_lints/src/atomic_ordering.rs b/src/tools/clippy/clippy_lints/src/atomic_ordering.rs index 703d8a6f62bb1..c0b3146dcf343 100644 --- a/src/tools/clippy/clippy_lints/src/atomic_ordering.rs +++ b/src/tools/clippy/clippy_lints/src/atomic_ordering.rs @@ -67,7 +67,7 @@ const ATOMIC_TYPES: [&str; 12] = [ ]; fn type_is_atomic(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { - if let ty::Adt(&ty::AdtDef { did, .. }, _) = cx.typeck_results().expr_ty(expr).kind() { + if let ty::Adt(&ty::AdtDef { did, .. }, _) = cx.typeck_results().expr_ty(expr).data() { ATOMIC_TYPES .iter() .any(|ty| match_def_path(cx, did, &["core", "sync", "atomic", ty])) diff --git a/src/tools/clippy/clippy_lints/src/await_holding_lock.rs b/src/tools/clippy/clippy_lints/src/await_holding_lock.rs index 367534499fd02..d2f6620a99ad2 100644 --- a/src/tools/clippy/clippy_lints/src/await_holding_lock.rs +++ b/src/tools/clippy/clippy_lints/src/await_holding_lock.rs @@ -67,7 +67,7 @@ impl LateLintPass<'_> for AwaitHoldingLock { fn check_interior_types(cx: &LateContext<'_>, ty_causes: &[GeneratorInteriorTypeCause<'_>], span: Span) { for ty_cause in ty_causes { - if let rustc_middle::ty::Adt(adt, _) = ty_cause.ty.kind() { + if let rustc_middle::ty::Adt(adt, _) = ty_cause.ty.data() { if is_mutex_guard(cx, adt.did) { span_lint_and_note( cx, diff --git a/src/tools/clippy/clippy_lints/src/bytecount.rs b/src/tools/clippy/clippy_lints/src/bytecount.rs index d7d02ebf985c8..218d693da21c4 100644 --- a/src/tools/clippy/clippy_lints/src/bytecount.rs +++ b/src/tools/clippy/clippy_lints/src/bytecount.rs @@ -62,7 +62,7 @@ impl<'tcx> LateLintPass<'tcx> for ByteCount { _ => { return; } } }; - if ty::Uint(UintTy::U8) != *cx.typeck_results().expr_ty(needle).peel_refs().kind() { + if ty::Uint(UintTy::U8) != *cx.typeck_results().expr_ty(needle).peel_refs().data() { return; } let haystack = if let ExprKind::MethodCall(ref path, _, ref args, _) = diff --git a/src/tools/clippy/clippy_lints/src/consts.rs b/src/tools/clippy/clippy_lints/src/consts.rs index 062c9bd2d9e6c..20ced18e5da7b 100644 --- a/src/tools/clippy/clippy_lints/src/consts.rs +++ b/src/tools/clippy/clippy_lints/src/consts.rs @@ -123,7 +123,7 @@ impl Constant { (&Self::Str(ref ls), &Self::Str(ref rs)) => Some(ls.cmp(rs)), (&Self::Char(ref l), &Self::Char(ref r)) => Some(l.cmp(r)), (&Self::Int(l), &Self::Int(r)) => { - if let ty::Int(int_ty) = *cmp_type.kind() { + if let ty::Int(int_ty) = *cmp_type.data() { Some(sext(tcx, l, int_ty).cmp(&sext(tcx, r, int_ty))) } else { Some(l.cmp(&r)) @@ -162,7 +162,7 @@ pub fn lit_to_constant(lit: &LitKind, ty: Option>) -> Constant { FloatTy::F32 => Constant::F32(is.as_str().parse().unwrap()), FloatTy::F64 => Constant::F64(is.as_str().parse().unwrap()), }, - LitKind::Float(ref is, LitFloatType::Unsuffixed) => match ty.expect("type of float is known").kind() { + LitKind::Float(ref is, LitFloatType::Unsuffixed) => match ty.expect("type of float is known").data() { ty::Float(FloatTy::F32) => Constant::F32(is.as_str().parse().unwrap()), ty::Float(FloatTy::F64) => Constant::F64(is.as_str().parse().unwrap()), _ => bug!(), @@ -230,7 +230,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> { ExprKind::Array(ref vec) => self.multi(vec).map(Constant::Vec), ExprKind::Tup(ref tup) => self.multi(tup).map(Constant::Tuple), ExprKind::Repeat(ref value, _) => { - let n = match self.typeck_results.expr_ty(e).kind() { + let n = match self.typeck_results.expr_ty(e).data() { ty::Array(_, n) => n.try_eval_usize(self.lcx.tcx, self.lcx.param_env)?, _ => span_bug!(e.span, "typeck error"), }; @@ -281,7 +281,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> { Bool(b) => Some(Bool(!b)), Int(value) => { let value = !value; - match *ty.kind() { + match *ty.data() { 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, @@ -295,7 +295,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> { use self::Constant::{Int, F32, F64}; match *o { Int(value) => { - let ity = match *ty.kind() { + let ity = match *ty.data() { ty::Int(ity) => ity, _ => return None, }; @@ -402,7 +402,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)?.data() { ty::Int(ity) => { let l = sext(self.lcx.tcx, l, ity); let r = sext(self.lcx.tcx, r, ity); @@ -495,7 +495,7 @@ pub fn miri_to_const(result: &ty::Const<'_>) -> Option { use rustc_middle::mir::interpret::{ConstValue, Scalar}; match result.val { ty::ConstKind::Value(ConstValue::Scalar(Scalar::Raw { data: d, .. })) => { - match result.ty.kind() { + match result.ty.data() { ty::Bool => Some(Constant::Bool(d == 1)), ty::Uint(_) | ty::Int(_) => Some(Constant::Int(d)), ty::Float(FloatTy::F32) => Some(Constant::F32(f32::from_bits( @@ -505,7 +505,7 @@ pub fn miri_to_const(result: &ty::Const<'_>) -> Option { d.try_into().expect("invalid f64 bit representation"), ))), ty::RawPtr(type_and_mut) => { - if let ty::Uint(_) = type_and_mut.ty.kind() { + if let ty::Uint(_) = type_and_mut.ty.data() { return Some(Constant::RawPtr(d)); } None @@ -514,8 +514,8 @@ pub fn miri_to_const(result: &ty::Const<'_>) -> Option { _ => None, } }, - ty::ConstKind::Value(ConstValue::Slice { data, start, end }) => match result.ty.kind() { - ty::Ref(_, tam, _) => match tam.kind() { + ty::ConstKind::Value(ConstValue::Slice { data, start, end }) => match result.ty.data() { + ty::Ref(_, tam, _) => match tam.data() { ty::Str => String::from_utf8( data.inspect_with_uninit_and_ptr_outside_interpreter(start..end) .to_owned(), @@ -526,8 +526,8 @@ pub fn miri_to_const(result: &ty::Const<'_>) -> Option { }, _ => None, }, - ty::ConstKind::Value(ConstValue::ByRef { alloc, offset: _ }) => match result.ty.kind() { - ty::Array(sub_type, len) => match sub_type.kind() { + ty::ConstKind::Value(ConstValue::ByRef { alloc, offset: _ }) => match result.ty.data() { + ty::Array(sub_type, len) => match sub_type.data() { ty::Float(FloatTy::F32) => match miri_to_const(len) { Some(Constant::Int(len)) => alloc .inspect_with_uninit_and_ptr_outside_interpreter(0..(4 * len as usize)) diff --git a/src/tools/clippy/clippy_lints/src/default_trait_access.rs b/src/tools/clippy/clippy_lints/src/default_trait_access.rs index 3048436d9a7b5..37c3cba7dd421 100644 --- a/src/tools/clippy/clippy_lints/src/default_trait_access.rs +++ b/src/tools/clippy/clippy_lints/src/default_trait_access.rs @@ -42,7 +42,7 @@ impl<'tcx> LateLintPass<'tcx> for DefaultTraitAccess { if let QPath::Resolved(None, _path) = qpath; then { let expr_ty = cx.typeck_results().expr_ty(expr); - if let ty::Adt(def, ..) = expr_ty.kind() { + if let ty::Adt(def, ..) = expr_ty.data() { // TODO: Work out a way to put "whatever the imported way of referencing // this type in this file" rather than a fully-qualified type. let replacement = format!("{}::default()", cx.tcx.def_path_str(def.did)); diff --git a/src/tools/clippy/clippy_lints/src/derive.rs b/src/tools/clippy/clippy_lints/src/derive.rs index bf8e030cc294b..c28dcdac190eb 100644 --- a/src/tools/clippy/clippy_lints/src/derive.rs +++ b/src/tools/clippy/clippy_lints/src/derive.rs @@ -299,20 +299,20 @@ fn check_copy_clone<'tcx>(cx: &LateContext<'tcx>, item: &Item<'_>, trait_ref: &T return; } - match *ty.kind() { + match *ty.data() { ty::Adt(def, _) if def.is_union() => return, // Some types are not Clone by default but could be cloned “by hand” if necessary ty::Adt(def, substs) => { for variant in &def.variants { for field in &variant.fields { - if let ty::FnDef(..) = field.ty(cx.tcx, substs).kind() { + if let ty::FnDef(..) = field.ty(cx.tcx, substs).data() { return; } } for subst in substs { if let ty::subst::GenericArgKind::Type(subst) = subst.unpack() { - if let ty::Param(_) = subst.kind() { + if let ty::Param(_) = subst.data() { return; } } @@ -353,7 +353,7 @@ fn check_unsafe_derive_deserialize<'tcx>( if_chain! { if match_path(&trait_ref.path, &paths::SERDE_DESERIALIZE); - if let ty::Adt(def, _) = ty.kind(); + if let ty::Adt(def, _) = ty.data(); if let Some(local_def_id) = def.did.as_local(); let adt_hir_id = cx.tcx.hir().local_def_id_to_hir_id(local_def_id); if !is_allowed(cx, UNSAFE_DERIVE_DESERIALIZE, adt_hir_id); diff --git a/src/tools/clippy/clippy_lints/src/doc.rs b/src/tools/clippy/clippy_lints/src/doc.rs index 62bb70af06e93..adb3b1edd5851 100644 --- a/src/tools/clippy/clippy_lints/src/doc.rs +++ b/src/tools/clippy/clippy_lints/src/doc.rs @@ -239,9 +239,9 @@ fn lint_for_missing_headers<'tcx>( let mir = cx.tcx.optimized_mir(def_id.to_def_id()); let ret_ty = mir.return_ty(); if implements_trait(cx, ret_ty, future, &[]); - if let ty::Opaque(_, subs) = ret_ty.kind(); + if let ty::Opaque(_, subs) = ret_ty.data(); if let Some(gen) = subs.types().next(); - if let ty::Generator(_, subs, _) = gen.kind(); + if let ty::Generator(_, subs, _) = gen.data(); if is_type_diagnostic_item(cx, subs.as_generator().return_ty(), sym!(result_type)); then { span_lint( diff --git a/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs b/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs index cf528d189b4b1..d33eedb699e99 100644 --- a/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs +++ b/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs @@ -121,7 +121,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef { let arg = &args[0]; let arg_ty = cx.typeck_results().expr_ty(arg); - if let ty::Ref(..) = arg_ty.kind() { + if let ty::Ref(..) = arg_ty.data() { if match_def_path(cx, def_id, &paths::DROP) { lint = DROP_REF; msg = DROP_REF_SUMMARY.to_string(); diff --git a/src/tools/clippy/clippy_lints/src/enum_clike.rs b/src/tools/clippy/clippy_lints/src/enum_clike.rs index fb80f48a9ccf3..6e13963a339a9 100644 --- a/src/tools/clippy/clippy_lints/src/enum_clike.rs +++ b/src/tools/clippy/clippy_lints/src/enum_clike.rs @@ -53,12 +53,12 @@ impl<'tcx> LateLintPass<'tcx> for UnportableVariant { .ok() .map(|val| rustc_middle::ty::Const::from_value(cx.tcx, val, ty)); if let Some(Constant::Int(val)) = constant.and_then(miri_to_const) { - if let ty::Adt(adt, _) = ty.kind() { + if let ty::Adt(adt, _) = ty.data() { if adt.is_enum() { ty = adt.repr.discr_type().to_ty(cx.tcx); } } - match ty.kind() { + match ty.data() { ty::Int(IntTy::Isize) => { let val = ((val as i128) << 64) >> 64; if i32::try_from(val).is_ok() { diff --git a/src/tools/clippy/clippy_lints/src/eta_reduction.rs b/src/tools/clippy/clippy_lints/src/eta_reduction.rs index 53df3abbf5437..f8138eb7bf3e4 100644 --- a/src/tools/clippy/clippy_lints/src/eta_reduction.rs +++ b/src/tools/clippy/clippy_lints/src/eta_reduction.rs @@ -99,7 +99,7 @@ fn check_closure(cx: &LateContext<'_>, expr: &Expr<'_>) { let fn_ty = cx.typeck_results().expr_ty(caller); - if matches!(fn_ty.kind(), ty::FnDef(_, _) | ty::FnPtr(_) | ty::Closure(_, _)); + if matches!(fn_ty.data(), ty::FnDef(_, _) | ty::FnPtr(_) | ty::Closure(_, _)); if !type_is_unsafe_function(cx, fn_ty); @@ -173,14 +173,14 @@ fn get_ufcs_type_name(cx: &LateContext<'_>, method_def_id: def_id::DefId, self_a } fn match_borrow_depth(lhs: Ty<'_>, rhs: Ty<'_>) -> bool { - match (&lhs.kind(), &rhs.kind()) { + match (&lhs.data(), &rhs.data()) { (ty::Ref(_, t1, mut1), ty::Ref(_, t2, mut2)) => mut1 == mut2 && match_borrow_depth(&t1, &t2), (l, r) => !matches!((l, r), (ty::Ref(_, _, _), _) | (_, ty::Ref(_, _, _))), } } fn match_types(lhs: Ty<'_>, rhs: Ty<'_>) -> bool { - match (&lhs.kind(), &rhs.kind()) { + match (&lhs.data(), &rhs.data()) { (ty::Bool, ty::Bool) | (ty::Char, ty::Char) | (ty::Int(_), ty::Int(_)) @@ -194,7 +194,7 @@ fn match_types(lhs: Ty<'_>, rhs: Ty<'_>) -> bool { } fn get_type_name(cx: &LateContext<'_>, ty: Ty<'_>) -> String { - match ty.kind() { + match ty.data() { ty::Adt(t, _) => cx.tcx.def_path_str(t.did), ty::Ref(_, r, _) => get_type_name(cx, &r), _ => ty.to_string(), diff --git a/src/tools/clippy/clippy_lints/src/eval_order_dependence.rs b/src/tools/clippy/clippy_lints/src/eval_order_dependence.rs index 4240147f498db..215a382d0ce5a 100644 --- a/src/tools/clippy/clippy_lints/src/eval_order_dependence.rs +++ b/src/tools/clippy/clippy_lints/src/eval_order_dependence.rs @@ -138,10 +138,10 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> { ExprKind::Continue(_) | ExprKind::Break(_, _) | ExprKind::Ret(_) => self.report_diverging_sub_expr(e), ExprKind::Call(ref func, _) => { let typ = self.cx.typeck_results().expr_ty(func); - match typ.kind() { + match typ.data() { ty::FnDef(..) | ty::FnPtr(_) => { let sig = typ.fn_sig(self.cx.tcx); - if let ty::Never = self.cx.tcx.erase_late_bound_regions(&sig).output().kind() { + if let ty::Never = self.cx.tcx.erase_late_bound_regions(&sig).output().data() { self.report_diverging_sub_expr(e); } }, diff --git a/src/tools/clippy/clippy_lints/src/float_equality_without_abs.rs b/src/tools/clippy/clippy_lints/src/float_equality_without_abs.rs index 69818b4d3c642..d17c1b162d0a3 100644 --- a/src/tools/clippy/clippy_lints/src/float_equality_without_abs.rs +++ b/src/tools/clippy/clippy_lints/src/float_equality_without_abs.rs @@ -81,8 +81,8 @@ impl<'tcx> LateLintPass<'tcx> for FloatEqualityWithoutAbs { // values of the substractions on the left hand side are of the type float let t_val_l = cx.typeck_results().expr_ty(val_l); let t_val_r = cx.typeck_results().expr_ty(val_r); - if let ty::Float(_) = t_val_l.kind(); - if let ty::Float(_) = t_val_r.kind(); + if let ty::Float(_) = t_val_l.data(); + if let ty::Float(_) = t_val_r.data(); then { let sug_l = sugg::Sugg::hir(cx, &val_l, ".."); diff --git a/src/tools/clippy/clippy_lints/src/float_literal.rs b/src/tools/clippy/clippy_lints/src/float_literal.rs index 1fe4461533b36..2da59c8506aa5 100644 --- a/src/tools/clippy/clippy_lints/src/float_literal.rs +++ b/src/tools/clippy/clippy_lints/src/float_literal.rs @@ -62,7 +62,7 @@ impl<'tcx> LateLintPass<'tcx> for FloatLiteral { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) { if_chain! { let ty = cx.typeck_results().expr_ty(expr); - if let ty::Float(fty) = *ty.kind(); + if let ty::Float(fty) = *ty.data(); if let hir::ExprKind::Lit(ref lit) = expr.kind; if let LitKind::Float(sym, lit_float_ty) = lit.node; then { diff --git a/src/tools/clippy/clippy_lints/src/floating_point_arithmetic.rs b/src/tools/clippy/clippy_lints/src/floating_point_arithmetic.rs index 18fea8b34bfd4..f50681bfbc5a9 100644 --- a/src/tools/clippy/clippy_lints/src/floating_point_arithmetic.rs +++ b/src/tools/clippy/clippy_lints/src/floating_point_arithmetic.rs @@ -136,7 +136,7 @@ fn prepare_receiver_sugg<'a>(cx: &LateContext<'_>, mut expr: &'a Expr<'a>) -> Su if_chain! { // if the expression is a float literal and it is unsuffixed then // add a suffix so the suggestion is valid and unambiguous - if let ty::Float(float_ty) = cx.typeck_results().expr_ty(expr).kind(); + if let ty::Float(float_ty) = cx.typeck_results().expr_ty(expr).data(); if let ExprKind::Lit(lit) = &expr.kind; if let ast::LitKind::Float(sym, ast::LitFloatType::Unsuffixed) = lit.node; then { diff --git a/src/tools/clippy/clippy_lints/src/format.rs b/src/tools/clippy/clippy_lints/src/format.rs index d6541010bca23..baf11199ca6a0 100644 --- a/src/tools/clippy/clippy_lints/src/format.rs +++ b/src/tools/clippy/clippy_lints/src/format.rs @@ -91,7 +91,7 @@ fn on_argumentv1_new<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, arms: & if pats.len() == 1; then { let ty = cx.typeck_results().pat_ty(&pats[0]).peel_refs(); - if *ty.kind() != rustc_middle::ty::Str && !is_type_diagnostic_item(cx, ty, sym!(string_type)) { + if *ty.data() != rustc_middle::ty::Str && !is_type_diagnostic_item(cx, ty, sym!(string_type)) { return None; } if let ExprKind::Lit(ref lit) = format_args.kind { diff --git a/src/tools/clippy/clippy_lints/src/functions.rs b/src/tools/clippy/clippy_lints/src/functions.rs index 50b39cf4ea7c0..600e0340509eb 100644 --- a/src/tools/clippy/clippy_lints/src/functions.rs +++ b/src/tools/clippy/clippy_lints/src/functions.rs @@ -510,7 +510,7 @@ fn is_mutable_pat(cx: &LateContext<'_>, pat: &hir::Pat<'_>, tys: &mut FxHashSet< static KNOWN_WRAPPER_TYS: &[&[&str]] = &[&["alloc", "rc", "Rc"], &["std", "sync", "Arc"]]; fn is_mutable_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, span: Span, tys: &mut FxHashSet) -> bool { - match *ty.kind() { + match *ty.data() { // primitive types are never mutable ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Str => false, ty::Adt(ref adt, ref substs) => { 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 d2a322e1223c6..b06887e29828f 100644 --- a/src/tools/clippy/clippy_lints/src/future_not_send.rs +++ b/src/tools/clippy/clippy_lints/src/future_not_send.rs @@ -62,7 +62,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend { return; } let ret_ty = utils::return_ty(cx, hir_id); - if let Opaque(id, subst) = *ret_ty.kind() { + if let Opaque(id, subst) = *ret_ty.data() { let preds = cx.tcx.explicit_item_bounds(id); let mut is_future = false; for &(p, _span) in preds { diff --git a/src/tools/clippy/clippy_lints/src/identity_op.rs b/src/tools/clippy/clippy_lints/src/identity_op.rs index 8501d34770201..55f9996eccc89 100644 --- a/src/tools/clippy/clippy_lints/src/identity_op.rs +++ b/src/tools/clippy/clippy_lints/src/identity_op.rs @@ -75,7 +75,7 @@ fn is_allowed(cx: &LateContext<'_>, cmp: BinOp, left: &Expr<'_>, right: &Expr<'_ #[allow(clippy::cast_possible_wrap)] fn check(cx: &LateContext<'_>, e: &Expr<'_>, m: i8, span: Span, arg: Span) { if let Some(Constant::Int(v)) = constant_simple(cx, cx.typeck_results(), e) { - let check = match *cx.typeck_results().expr_ty(e).kind() { + let check = match *cx.typeck_results().expr_ty(e).data() { ty::Int(ity) => unsext(cx.tcx, -1_i128, ity), ty::Uint(uty) => clip(cx.tcx, !0, uty), _ => return, diff --git a/src/tools/clippy/clippy_lints/src/indexing_slicing.rs b/src/tools/clippy/clippy_lints/src/indexing_slicing.rs index 741195f3b10d5..16e2939d46c29 100644 --- a/src/tools/clippy/clippy_lints/src/indexing_slicing.rs +++ b/src/tools/clippy/clippy_lints/src/indexing_slicing.rs @@ -91,7 +91,7 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing { let ty = cx.typeck_results().expr_ty(array).peel_refs(); if let Some(range) = higher::range(index) { // Ranged indexes, i.e., &x[n..m], &x[n..], &x[..n] and &x[..] - if let ty::Array(_, s) = ty.kind() { + if let ty::Array(_, s) = ty.data() { let size: u128 = if let Some(size) = s.try_eval_usize(cx.tcx, cx.param_env) { size.into() } else { @@ -141,7 +141,7 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing { span_lint_and_help(cx, INDEXING_SLICING, expr.span, "slicing may panic.", None, help_msg); } else { // Catchall non-range index, i.e., [n] or [n << m] - if let ty::Array(..) = ty.kind() { + if let ty::Array(..) = ty.data() { // Index is a constant uint. if let Some(..) = constant(cx, cx.typeck_results(), index) { // Let rustc's `const_err` lint handle constant `usize` indexing on arrays. 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 025ff86da39d8..ac5bafcb72b09 100644 --- a/src/tools/clippy/clippy_lints/src/large_const_arrays.rs +++ b/src/tools/clippy/clippy_lints/src/large_const_arrays.rs @@ -51,7 +51,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeConstArrays { if !item.span.from_expansion(); if let ItemKind::Const(hir_ty, _) = &item.kind; let ty = hir_ty_to_ty(cx.tcx, hir_ty); - if let ty::Array(element_type, cst) = ty.kind(); + if let ty::Array(element_type, cst) = ty.data(); if let ConstKind::Value(val) = cst.val; if let ConstValue::Scalar(element_count) = val; if let Ok(element_count) = element_count.to_machine_usize(&cx.tcx); 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 9fd3780e14e04..8734180a3b8ad 100644 --- a/src/tools/clippy/clippy_lints/src/large_stack_arrays.rs +++ b/src/tools/clippy/clippy_lints/src/large_stack_arrays.rs @@ -42,7 +42,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeStackArrays { fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) { if_chain! { if let ExprKind::Repeat(_, _) = expr.kind; - if let ty::Array(element_type, cst) = cx.typeck_results().expr_ty(expr).kind(); + if let ty::Array(element_type, cst) = cx.typeck_results().expr_ty(expr).data(); if let ConstKind::Value(val) = cst.val; if let ConstValue::Scalar(element_count) = val; if let Ok(element_count) = element_count.to_machine_usize(&cx.tcx); diff --git a/src/tools/clippy/clippy_lints/src/len_zero.rs b/src/tools/clippy/clippy_lints/src/len_zero.rs index c9c4891bb08ac..4df6c29f109ea 100644 --- a/src/tools/clippy/clippy_lints/src/len_zero.rs +++ b/src/tools/clippy/clippy_lints/src/len_zero.rs @@ -286,7 +286,7 @@ fn has_is_empty(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { } let ty = &cx.typeck_results().expr_ty(expr).peel_refs(); - match ty.kind() { + match ty.data() { ty::Dynamic(ref tt, ..) => tt.principal().map_or(false, |principal| { cx.tcx .associated_items(principal.def_id()) diff --git a/src/tools/clippy/clippy_lints/src/loops.rs b/src/tools/clippy/clippy_lints/src/loops.rs index 61b63597b1633..0ae19a5ef0c4c 100644 --- a/src/tools/clippy/clippy_lints/src/loops.rs +++ b/src/tools/clippy/clippy_lints/src/loops.rs @@ -826,7 +826,7 @@ struct FixedOffsetVar<'hir> { } fn is_slice_like<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'_>) -> bool { - let is_slice = match ty.kind() { + let is_slice = match ty.data() { ty::Ref(_, subty, _) => is_slice_like(cx, subty), ty::Slice(..) | ty::Array(..) => true, _ => false, @@ -1407,7 +1407,7 @@ fn is_end_eq_array_len<'tcx>( if_chain! { if let ExprKind::Lit(ref lit) = end.kind; if let ast::LitKind::Int(end_int, _) = lit.node; - if let ty::Array(_, arr_len_const) = indexed_ty.kind(); + if let ty::Array(_, arr_len_const) = indexed_ty.data(); if let Some(arr_len) = arr_len_const.try_eval_usize(cx.tcx, cx.param_env); then { return match limits { @@ -1644,7 +1644,7 @@ fn check_for_loop_over_map_kv<'tcx>( if let PatKind::Tuple(ref 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).data() { ty::Ref(_, ty, mutbl) => match (&pat[0].kind, &pat[1].kind) { (key, _) if pat_is_wild(key, body) => (pat[1].span, "value", ty, mutbl), (_, value) if pat_is_wild(value, body) => (pat[0].span, "key", ty, Mutability::Not), @@ -1972,7 +1972,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.data() { if mutbl == Mutability::Mut { self.prefer_mutable = true; } @@ -1984,7 +1984,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> { let def_id = self.cx.typeck_results().type_dependent_def_id(expr.hir_id).unwrap(); for (ty, expr) in self.cx.tcx.fn_sig(def_id).inputs().skip_binder().iter().zip(args) { self.prefer_mutable = false; - if let ty::Ref(_, _, mutbl) = *ty.kind() { + if let ty::Ref(_, _, mutbl) = *ty.data() { if mutbl == Mutability::Mut { self.prefer_mutable = true; } @@ -2082,7 +2082,7 @@ fn is_ref_iterable_type(cx: &LateContext<'_>, e: &Expr<'_>) -> bool { fn is_iterable_array<'tcx>(ty: Ty<'tcx>, cx: &LateContext<'tcx>) -> bool { // IntoIterator is currently only implemented for array sizes <= 32 in rustc - match ty.kind() { + match ty.data() { ty::Array(_, n) => n .try_eval_usize(cx.tcx, cx.param_env) .map_or(false, |val| (0..=32).contains(&val)), diff --git a/src/tools/clippy/clippy_lints/src/manual_strip.rs b/src/tools/clippy/clippy_lints/src/manual_strip.rs index 4afb0ab3badb0..eac4f75681b02 100644 --- a/src/tools/clippy/clippy_lints/src/manual_strip.rs +++ b/src/tools/clippy/clippy_lints/src/manual_strip.rs @@ -155,7 +155,7 @@ fn eq_pattern_length<'tcx>(cx: &LateContext<'tcx>, pattern: &Expr<'_>, expr: &'t // Tests if `expr` is a `&str`. fn is_ref_str(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { - match cx.typeck_results().expr_ty_adjusted(&expr).kind() { + match cx.typeck_results().expr_ty_adjusted(&expr).data() { ty::Ref(_, ty, _) => ty.is_str(), _ => false, } diff --git a/src/tools/clippy/clippy_lints/src/map_clone.rs b/src/tools/clippy/clippy_lints/src/map_clone.rs index 6d1c2ffbfbdd2..1fd4b8c2e49b1 100644 --- a/src/tools/clippy/clippy_lints/src/map_clone.rs +++ b/src/tools/clippy/clippy_lints/src/map_clone.rs @@ -70,7 +70,7 @@ impl<'tcx> LateLintPass<'tcx> for MapClone { match closure_expr.kind { hir::ExprKind::Unary(hir::UnOp::UnDeref, ref inner) => { if ident_eq(name, inner) { - if let ty::Ref(.., Mutability::Not) = cx.typeck_results().expr_ty(inner).kind() { + if let ty::Ref(.., Mutability::Not) = cx.typeck_results().expr_ty(inner).data() { lint(cx, e.span, args[0].span, true); } } @@ -80,7 +80,7 @@ impl<'tcx> LateLintPass<'tcx> for MapClone { && match_trait_method(cx, closure_expr, &paths::CLONE_TRAIT) { let obj_ty = cx.typeck_results().expr_ty(&obj[0]); - if let ty::Ref(_, ty, _) = obj_ty.kind() { + if let ty::Ref(_, ty, _) = obj_ty.data() { let copy = is_copy(cx, ty); lint(cx, e.span, args[0].span, copy); } 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 076ef235b8bd8..55c2f9a0efcc7 100644 --- a/src/tools/clippy/clippy_lints/src/map_unit_fn.rs +++ b/src/tools/clippy/clippy_lints/src/map_unit_fn.rs @@ -93,7 +93,7 @@ declare_clippy_lint! { declare_lint_pass!(MapUnit => [OPTION_MAP_UNIT_FN, RESULT_MAP_UNIT_FN]); fn is_unit_type(ty: Ty<'_>) -> bool { - match ty.kind() { + match ty.data() { ty::Tuple(slice) => slice.is_empty(), ty::Never => true, _ => false, @@ -103,7 +103,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.data() { if let Some(fn_type) = cx.tcx.fn_sig(id).no_bound_vars() { return is_unit_type(fn_type.output()); } diff --git a/src/tools/clippy/clippy_lints/src/matches.rs b/src/tools/clippy/clippy_lints/src/matches.rs index b1a4e06d4c32f..ea5f27ff85ca2 100644 --- a/src/tools/clippy/clippy_lints/src/matches.rs +++ b/src/tools/clippy/clippy_lints/src/matches.rs @@ -573,7 +573,7 @@ impl<'tcx> LateLintPass<'tcx> for Matches { if let QPath::Resolved(_, ref path) = qpath; if let Some(def_id) = path.res.opt_def_id(); let ty = cx.tcx.type_of(def_id); - if let ty::Adt(def, _) = ty.kind(); + if let ty::Adt(def, _) = ty.data(); if def.is_struct() || def.is_union(); if fields.len() == def.non_enum_variant().fields.len(); @@ -621,7 +621,7 @@ fn check_single_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], exp }; let ty = cx.typeck_results().expr_ty(ex); - if *ty.kind() != ty::Bool || is_allowed(cx, MATCH_BOOL, ex.hir_id) { + if *ty.data() != ty::Bool || is_allowed(cx, MATCH_BOOL, ex.hir_id) { check_single_match_single_pattern(cx, ex, arms, expr, els); check_single_match_opt_like(cx, ex, arms, expr, ty, els); } @@ -712,7 +712,7 @@ fn check_single_match_opt_like( fn check_match_bool(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr: &Expr<'_>) { // Type of expression is `bool`. - if *cx.typeck_results().expr_ty(ex).kind() == ty::Bool { + if *cx.typeck_results().expr_ty(ex).data() == ty::Bool { span_lint_and_then( cx, MATCH_BOOL, @@ -860,7 +860,7 @@ fn check_wild_enum_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>]) // already covered. let mut missing_variants = vec![]; - if let ty::Adt(def, _) = ty.kind() { + if let ty::Adt(def, _) = ty.data() { for variant in &def.variants { missing_variants.push(variant); } @@ -914,7 +914,7 @@ fn check_wild_enum_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>]) let mut message = "wildcard match will miss any future added variants"; - if let ty::Adt(def, _) = ty.kind() { + if let ty::Adt(def, _) = ty.data() { if def.is_variant_list_non_exhaustive() { message = "match on non-exhaustive enum doesn't explicitly match all known variants"; suggestion.push(String::from("_")); @@ -1014,11 +1014,11 @@ fn check_match_as_ref(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], exp let input_ty = cx.typeck_results().expr_ty(ex); let cast = if_chain! { - if let ty::Adt(_, substs) = input_ty.kind(); + if let ty::Adt(_, substs) = input_ty.data(); let input_ty = substs.type_at(0); - if let ty::Adt(_, substs) = output_ty.kind(); + if let ty::Adt(_, substs) = output_ty.data(); let output_ty = substs.type_at(0); - if let ty::Ref(_, output_ty, _) = *output_ty.kind(); + if let ty::Ref(_, output_ty, _) = *output_ty.data(); if input_ty != output_ty; then { ".map(|x| x as _)" diff --git a/src/tools/clippy/clippy_lints/src/methods/inefficient_to_string.rs b/src/tools/clippy/clippy_lints/src/methods/inefficient_to_string.rs index 5dae7efad9763..171af5bfa1749 100644 --- a/src/tools/clippy/clippy_lints/src/methods/inefficient_to_string.rs +++ b/src/tools/clippy/clippy_lints/src/methods/inefficient_to_string.rs @@ -46,7 +46,7 @@ pub fn lint<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>, arg: &hir::Expr< /// Returns whether `ty` specializes `ToString`. /// Currently, these are `str`, `String`, and `Cow<'_, str>`. fn specializes_tostring(cx: &LateContext<'_>, ty: Ty<'_>) -> bool { - if let ty::Str = ty.kind() { + if let ty::Str = ty.data() { return true; } @@ -54,7 +54,7 @@ fn specializes_tostring(cx: &LateContext<'_>, ty: Ty<'_>) -> bool { return true; } - if let ty::Adt(adt, substs) = ty.kind() { + if let ty::Adt(adt, substs) = ty.data() { match_def_path(cx, adt.did, &paths::COW) && substs.type_at(1).is_str() } else { false diff --git a/src/tools/clippy/clippy_lints/src/methods/mod.rs b/src/tools/clippy/clippy_lints/src/methods/mod.rs index c0824bacbc735..1106411cab29d 100644 --- a/src/tools/clippy/clippy_lints/src/methods/mod.rs +++ b/src/tools/clippy/clippy_lints/src/methods/mod.rs @@ -1538,8 +1538,8 @@ impl<'tcx> LateLintPass<'tcx> for Methods { } } - match self_ty.kind() { - ty::Ref(_, ty, _) if *ty.kind() == ty::Str => { + match self_ty.data() { + ty::Ref(_, ty, _) if *ty.data() == ty::Str => { for &(method, pos) in &PATTERN_METHODS { if method_call.ident.name.as_str() == method && args.len() > pos { lint_single_char_pattern(cx, expr, &args[pos]); @@ -1665,7 +1665,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods { } // if return type is impl trait, check the associated types - if let ty::Opaque(def_id, _) = *ret_ty.kind() { + if let ty::Opaque(def_id, _) = *ret_ty.data() { // one of the associated types must be Self for &(predicate, _span) in cx.tcx.explicit_item_bounds(def_id) { if let ty::PredicateAtom::Projection(projection_predicate) = predicate.skip_binders() { @@ -1776,7 +1776,7 @@ fn lint_or_fun_call<'tcx>( if path.ident.as_str() == "len" { let ty = cx.typeck_results().expr_ty(&args[0]).peel_refs(); - match ty.kind() { + match ty.data() { ty::Slice(_) | ty::Array(_, _) => return, _ => (), } @@ -1882,7 +1882,7 @@ fn lint_expect_fun_call( && { let arg_type = cx.typeck_results().expr_ty(&call_args[0]); let base_type = arg_type.peel_refs(); - *base_type.kind() == ty::Str || is_type_diagnostic_item(cx, base_type, sym!(string_type)) + *base_type.data() == ty::Str || is_type_diagnostic_item(cx, base_type, sym!(string_type)) } { &call_args[0] @@ -1903,8 +1903,8 @@ fn lint_expect_fun_call( if is_type_diagnostic_item(cx, arg_ty, sym!(string_type)) { return false; } - if let ty::Ref(_, ty, ..) = arg_ty.kind() { - if *ty.kind() == ty::Str && can_be_static_str(cx, arg) { + if let ty::Ref(_, ty, ..) = arg_ty.data() { + if *ty.data() == ty::Str && can_be_static_str(cx, arg) { return false; } }; @@ -1920,7 +1920,7 @@ fn lint_expect_fun_call( if let hir::ExprKind::Path(ref p) = fun.kind { match cx.qpath_res(p, fun.hir_id) { hir::def::Res::Def(hir::def::DefKind::Fn | hir::def::DefKind::AssocFn, def_id) => matches!( - cx.tcx.fn_sig(def_id).output().skip_binder().kind(), + cx.tcx.fn_sig(def_id).output().skip_binder().data(), ty::Ref(ty::ReStatic, ..) ), _ => false, @@ -1934,7 +1934,7 @@ fn lint_expect_fun_call( .type_dependent_def_id(arg.hir_id) .map_or(false, |method_id| { matches!( - cx.tcx.fn_sig(method_id).output().skip_binder().kind(), + cx.tcx.fn_sig(method_id).output().skip_binder().data(), ty::Ref(ty::ReStatic, ..) ) }) @@ -2053,8 +2053,8 @@ fn lint_expect_fun_call( /// Checks for the `CLONE_ON_COPY` lint. fn lint_clone_on_copy(cx: &LateContext<'_>, expr: &hir::Expr<'_>, arg: &hir::Expr<'_>, arg_ty: Ty<'_>) { let ty = cx.typeck_results().expr_ty(expr); - if let ty::Ref(_, inner, _) = arg_ty.kind() { - if let ty::Ref(_, innermost, _) = inner.kind() { + if let ty::Ref(_, inner, _) = arg_ty.data() { + if let ty::Ref(_, innermost, _) = inner.data() { span_lint_and_then( cx, CLONE_DOUBLE_REF, @@ -2065,7 +2065,7 @@ fn lint_clone_on_copy(cx: &LateContext<'_>, expr: &hir::Expr<'_>, arg: &hir::Exp if let Some(snip) = sugg::Sugg::hir_opt(cx, arg) { let mut ty = innermost; let mut n = 0; - while let ty::Ref(_, inner, _) = ty.kind() { + while let ty::Ref(_, inner, _) = ty.data() { ty = inner; n += 1; } @@ -2144,7 +2144,7 @@ fn lint_clone_on_copy(cx: &LateContext<'_>, expr: &hir::Expr<'_>, arg: &hir::Exp fn lint_clone_on_ref_ptr(cx: &LateContext<'_>, expr: &hir::Expr<'_>, arg: &hir::Expr<'_>) { let obj_ty = cx.typeck_results().expr_ty(arg).peel_refs(); - if let ty::Adt(_, subst) = obj_ty.kind() { + if let ty::Adt(_, subst) = obj_ty.data() { let caller_type = if is_type_diagnostic_item(cx, obj_ty, sym::Rc) { "Rc" } else if is_type_diagnostic_item(cx, obj_ty, sym::Arc) { @@ -2174,7 +2174,7 @@ fn lint_string_extend(cx: &LateContext<'_>, expr: &hir::Expr<'_>, args: &[hir::E if let Some(arglists) = method_chain_args(arg, &["chars"]) { let target = &arglists[0][0]; let self_ty = cx.typeck_results().expr_ty(target).peel_refs(); - let ref_str = if *self_ty.kind() == ty::Str { + let ref_str = if *self_ty.data() == ty::Str { "" } else if is_type_diagnostic_item(cx, self_ty, sym!(string_type)) { "&" @@ -2210,7 +2210,7 @@ fn lint_extend(cx: &LateContext<'_>, expr: &hir::Expr<'_>, args: &[hir::Expr<'_> fn lint_cstring_as_ptr(cx: &LateContext<'_>, expr: &hir::Expr<'_>, source: &hir::Expr<'_>, unwrap: &hir::Expr<'_>) { if_chain! { let source_type = cx.typeck_results().expr_ty(source); - if let ty::Adt(def, substs) = source_type.kind(); + if let ty::Adt(def, substs) = source_type.data(); if cx.tcx.is_diagnostic_item(sym!(result_type), def.did); if match_type(cx, substs.type_at(0), &paths::CSTRING); then { @@ -2384,7 +2384,7 @@ fn lint_iter_next<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, iter_ } } else if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(caller_expr), sym!(vec_type)) || matches!( - &cx.typeck_results().expr_ty(caller_expr).peel_refs().kind(), + &cx.typeck_results().expr_ty(caller_expr).peel_refs().data(), ty::Array(_, _) ) { @@ -2551,7 +2551,7 @@ fn derefs_to_slice<'tcx>( ty: Ty<'tcx>, ) -> Option<&'tcx hir::Expr<'tcx>> { fn may_slice<'a>(cx: &LateContext<'a>, ty: Ty<'a>) -> bool { - match ty.kind() { + match ty.data() { ty::Slice(_) => true, ty::Adt(def, _) if def.is_box() => may_slice(cx, ty.boxed_ty()), ty::Adt(..) => is_type_diagnostic_item(cx, ty, sym!(vec_type)), @@ -2570,7 +2570,7 @@ fn derefs_to_slice<'tcx>( None } } else { - match ty.kind() { + match ty.data() { ty::Slice(_) => Some(expr), ty::Adt(def, _) if def.is_box() && may_slice(cx, ty.boxed_ty()) => Some(expr), ty::Ref(_, inner, _) => { @@ -2664,9 +2664,9 @@ fn lint_map_flatten<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, map // lint if caller of `.map().flatten()` is an Iterator if match_trait_method(cx, expr, &paths::ITERATOR) { let map_closure_ty = cx.typeck_results().expr_ty(&map_args[1]); - let is_map_to_option = match map_closure_ty.kind() { + let is_map_to_option = match map_closure_ty.data() { ty::Closure(_, _) | ty::FnDef(_, _) | ty::FnPtr(_) => { - let map_closure_sig = match map_closure_ty.kind() { + let map_closure_sig = match map_closure_ty.data() { ty::Closure(_, substs) => substs.as_closure().sig(), _ => map_closure_ty.fn_sig(cx.tcx), }; @@ -3136,7 +3136,7 @@ fn lint_chars_cmp( 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.data() != ty::Str { return false; } @@ -3324,7 +3324,7 @@ fn lint_asref(cx: &LateContext<'_>, expr: &hir::Expr<'_>, call_name: &str, as_re fn ty_has_iter_method(cx: &LateContext<'_>, self_ref_ty: Ty<'_>) -> Option<(&'static str, &'static str)> { has_iter_method(cx, self_ref_ty).map(|ty_name| { - let mutbl = match self_ref_ty.kind() { + let mutbl = match self_ref_ty.data() { ty::Ref(_, _, mutbl) => mutbl, _ => unreachable!(), }; @@ -3376,7 +3376,7 @@ fn lint_maybe_uninit(cx: &LateContext<'_>, expr: &hir::Expr<'_>, outer: &hir::Ex } fn is_maybe_uninit_ty_valid(cx: &LateContext<'_>, ty: Ty<'_>) -> bool { - match ty.kind() { + match ty.data() { ty::Array(ref component, _) => is_maybe_uninit_ty_valid(cx, component), ty::Tuple(ref types) => types.types().all(|ty| is_maybe_uninit_ty_valid(cx, ty)), ty::Adt(ref adt, _) => match_def_path(cx, adt.did, &paths::MEM_MAYBEUNINIT), @@ -3503,7 +3503,7 @@ fn lint_option_as_ref_deref<'tcx>( /// Given a `Result` type, return its error type (`E`). fn get_error_type<'a>(cx: &LateContext<'_>, ty: Ty<'a>) -> Option> { - match ty.kind() { + match ty.data() { ty::Adt(_, substs) if is_type_diagnostic_item(cx, ty, sym!(result_type)) => substs.types().nth(1), _ => None, } @@ -3657,7 +3657,7 @@ impl SelfKind { } else if ty.is_box() { ty.boxed_ty() == parent_ty } else if is_type_diagnostic_item(cx, ty, sym::Rc) || is_type_diagnostic_item(cx, ty, sym::Arc) { - if let ty::Adt(_, substs) = ty.kind() { + if let ty::Adt(_, substs) = ty.data() { substs.types().next().map_or(false, |t| t == parent_ty) } else { false @@ -3668,7 +3668,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.data() { return m == mutability && t == parent_ty; } @@ -3785,7 +3785,7 @@ fn contains_return(expr: &hir::Expr<'_>) -> bool { fn check_pointer_offset(cx: &LateContext<'_>, expr: &hir::Expr<'_>, args: &[hir::Expr<'_>]) { if_chain! { if args.len() == 2; - if let ty::RawPtr(ty::TypeAndMut { ref ty, .. }) = cx.typeck_results().expr_ty(&args[0]).kind(); + if let ty::RawPtr(ty::TypeAndMut { ref ty, .. }) = cx.typeck_results().expr_ty(&args[0]).data(); if let Ok(layout) = cx.tcx.layout_of(cx.param_env.and(ty)); if layout.is_zst(); then { diff --git a/src/tools/clippy/clippy_lints/src/misc.rs b/src/tools/clippy/clippy_lints/src/misc.rs index 909e79f661a6d..c39e1a32a6195 100644 --- a/src/tools/clippy/clippy_lints/src/misc.rs +++ b/src/tools/clippy/clippy_lints/src/misc.rs @@ -561,17 +561,17 @@ fn is_signum(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { } fn is_float(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { - let value = &cx.typeck_results().expr_ty(expr).peel_refs().kind(); + let value = &cx.typeck_results().expr_ty(expr).peel_refs().data(); if let ty::Array(arr_ty, _) = value { - return matches!(arr_ty.kind(), ty::Float(_)); + return matches!(arr_ty.data(), ty::Float(_)); }; matches!(value, ty::Float(_)) } fn is_array(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { - matches!(&cx.typeck_results().expr_ty(expr).peel_refs().kind(), ty::Array(_, _)) + matches!(&cx.typeck_results().expr_ty(expr).peel_refs().data(), ty::Array(_, _)) } fn check_to_owned(cx: &LateContext<'_>, expr: &Expr<'_>, other: &Expr<'_>, left: bool) { diff --git a/src/tools/clippy/clippy_lints/src/modulo_arithmetic.rs b/src/tools/clippy/clippy_lints/src/modulo_arithmetic.rs index da3ae1d652f6c..5184c82bebf95 100644 --- a/src/tools/clippy/clippy_lints/src/modulo_arithmetic.rs +++ b/src/tools/clippy/clippy_lints/src/modulo_arithmetic.rs @@ -38,7 +38,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).data() { ty::Int(ity) => { let value = sext(cx.tcx, v, ity); return Some(OperandInfo { diff --git a/src/tools/clippy/clippy_lints/src/mut_key.rs b/src/tools/clippy/clippy_lints/src/mut_key.rs index 8a2dbdc50eaea..be2fd1c527b59 100644 --- a/src/tools/clippy/clippy_lints/src/mut_key.rs +++ b/src/tools/clippy/clippy_lints/src/mut_key.rs @@ -99,7 +99,7 @@ fn check_sig<'tcx>(cx: &LateContext<'tcx>, item_hir_id: hir::HirId, decl: &hir:: // generics (because the compiler cannot ensure immutability for unknown types). fn check_ty<'tcx>(cx: &LateContext<'tcx>, span: Span, ty: Ty<'tcx>) { let ty = ty.peel_refs(); - if let Adt(def, substs) = ty.kind() { + if let Adt(def, substs) = ty.data() { if [&paths::HASHMAP, &paths::BTREEMAP, &paths::HASHSET, &paths::BTREESET] .iter() .any(|path| match_def_path(cx, def.did, &**path)) @@ -111,7 +111,7 @@ fn check_ty<'tcx>(cx: &LateContext<'tcx>, span: Span, ty: Ty<'tcx>) { } fn is_mutable_type<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, span: Span) -> bool { - match *ty.kind() { + match *ty.data() { RawPtr(TypeAndMut { ty: inner_ty, mutbl }) | Ref(_, inner_ty, mutbl) => { mutbl == hir::Mutability::Mut || is_mutable_type(cx, inner_ty, span) }, diff --git a/src/tools/clippy/clippy_lints/src/mut_mut.rs b/src/tools/clippy/clippy_lints/src/mut_mut.rs index 2f3cdb894f01c..67e65d9405863 100644 --- a/src/tools/clippy/clippy_lints/src/mut_mut.rs +++ b/src/tools/clippy/clippy_lints/src/mut_mut.rs @@ -69,7 +69,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for MutVisitor<'a, 'tcx> { expr.span, "generally you want to avoid `&mut &mut _` if possible", ); - } else if let ty::Ref(_, _, hir::Mutability::Mut) = self.cx.typeck_results().expr_ty(e).kind() { + } else if let ty::Ref(_, _, hir::Mutability::Mut) = self.cx.typeck_results().expr_ty(e).data() { span_lint( self.cx, MUT_MUT, diff --git a/src/tools/clippy/clippy_lints/src/mut_reference.rs b/src/tools/clippy/clippy_lints/src/mut_reference.rs index 3f0b765df1561..b43adebb9317d 100644 --- a/src/tools/clippy/clippy_lints/src/mut_reference.rs +++ b/src/tools/clippy/clippy_lints/src/mut_reference.rs @@ -61,11 +61,11 @@ fn check_arguments<'tcx>( name: &str, fn_kind: &str, ) { - match type_definition.kind() { + match type_definition.data() { ty::FnDef(..) | ty::FnPtr(_) => { let parameters = type_definition.fn_sig(cx.tcx).skip_binder().inputs(); for (argument, parameter) in arguments.iter().zip(parameters.iter()) { - match parameter.kind() { + match parameter.data() { ty::Ref(_, _, Mutability::Not) | ty::RawPtr(ty::TypeAndMut { mutbl: Mutability::Not, .. diff --git a/src/tools/clippy/clippy_lints/src/mutable_debug_assertion.rs b/src/tools/clippy/clippy_lints/src/mutable_debug_assertion.rs index cc635c2a202f6..2a8775996c91d 100644 --- a/src/tools/clippy/clippy_lints/src/mutable_debug_assertion.rs +++ b/src/tools/clippy/clippy_lints/src/mutable_debug_assertion.rs @@ -138,7 +138,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MutArgVisitor<'a, 'tcx> { if let Some(adj) = self.cx.typeck_results().adjustments().get(expr.hir_id) { if adj .iter() - .any(|a| matches!(a.target.kind(), ty::Ref(_, _, Mutability::Mut))) + .any(|a| matches!(a.target.data(), ty::Ref(_, _, Mutability::Mut))) { self.found = true; return; diff --git a/src/tools/clippy/clippy_lints/src/mutex_atomic.rs b/src/tools/clippy/clippy_lints/src/mutex_atomic.rs index ea986874291e0..53f909ebdd667 100644 --- a/src/tools/clippy/clippy_lints/src/mutex_atomic.rs +++ b/src/tools/clippy/clippy_lints/src/mutex_atomic.rs @@ -67,7 +67,7 @@ declare_lint_pass!(Mutex => [MUTEX_ATOMIC, MUTEX_INTEGER]); impl<'tcx> LateLintPass<'tcx> for Mutex { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { let ty = cx.typeck_results().expr_ty(expr); - if let ty::Adt(_, subst) = ty.kind() { + if let ty::Adt(_, subst) = ty.data() { if is_type_diagnostic_item(cx, ty, sym!(mutex_type)) { let mutex_param = subst.type_at(0); if let Some(atomic_name) = get_atomic_name(mutex_param) { @@ -76,7 +76,7 @@ impl<'tcx> LateLintPass<'tcx> for Mutex { behavior and not the internal type, consider using `Mutex<()>`", atomic_name ); - match *mutex_param.kind() { + match *mutex_param.data() { ty::Uint(t) if t != ast::UintTy::Usize => span_lint(cx, MUTEX_INTEGER, expr.span, &msg), ty::Int(t) if t != ast::IntTy::Isize => span_lint(cx, MUTEX_INTEGER, expr.span, &msg), _ => span_lint(cx, MUTEX_ATOMIC, expr.span, &msg), @@ -88,7 +88,7 @@ impl<'tcx> LateLintPass<'tcx> for Mutex { } fn get_atomic_name(ty: Ty<'_>) -> Option<&'static str> { - match ty.kind() { + match ty.data() { ty::Bool => Some("AtomicBool"), ty::Uint(_) => Some("AtomicUsize"), ty::Int(_) => Some("AtomicIsize"), diff --git a/src/tools/clippy/clippy_lints/src/needless_borrow.rs b/src/tools/clippy/clippy_lints/src/needless_borrow.rs index b71d5496a37a3..7110b1d6fe133 100644 --- a/src/tools/clippy/clippy_lints/src/needless_borrow.rs +++ b/src/tools/clippy/clippy_lints/src/needless_borrow.rs @@ -46,7 +46,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessBorrow { return; } if let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, ref inner) = e.kind { - if let ty::Ref(..) = cx.typeck_results().expr_ty(inner).kind() { + if let ty::Ref(..) = cx.typeck_results().expr_ty(inner).data() { for adj3 in cx.typeck_results().expr_adjustments(e).windows(3) { if let [Adjustment { kind: Adjust::Deref(_), .. @@ -85,9 +85,9 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessBorrow { } if_chain! { if let PatKind::Binding(BindingAnnotation::Ref, .., name, _) = pat.kind; - if let ty::Ref(_, tam, mutbl) = *cx.typeck_results().pat_ty(pat).kind(); + if let ty::Ref(_, tam, mutbl) = *cx.typeck_results().pat_ty(pat).data(); if mutbl == Mutability::Not; - if let ty::Ref(_, _, mutbl) = *tam.kind(); + if let ty::Ref(_, _, mutbl) = *tam.data(); // only lint immutable refs, because borrowed `&mut T` cannot be moved out if mutbl == Mutability::Not; then { diff --git a/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs b/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs index 7e933c674dd78..fcfd193d0832c 100644 --- a/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs +++ b/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs @@ -194,7 +194,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue { // Dereference suggestion let sugg = |diag: &mut DiagnosticBuilder<'_>| { - if let ty::Adt(def, ..) = ty.kind() { + if let ty::Adt(def, ..) = ty.data() { if let Some(span) = cx.tcx.hir().span_if_local(def.did) { if can_type_implement_copy(cx.tcx, cx.param_env, ty).is_ok() { diag.span_help(span, "consider marking this type as `Copy`"); diff --git a/src/tools/clippy/clippy_lints/src/needless_update.rs b/src/tools/clippy/clippy_lints/src/needless_update.rs index 98e9078094a22..536c3b74a00e8 100644 --- a/src/tools/clippy/clippy_lints/src/needless_update.rs +++ b/src/tools/clippy/clippy_lints/src/needless_update.rs @@ -48,7 +48,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessUpdate { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { if let ExprKind::Struct(_, ref fields, Some(ref base)) = expr.kind { let ty = cx.typeck_results().expr_ty(expr); - if let ty::Adt(def, _) = ty.kind() { + if let ty::Adt(def, _) = ty.data() { if fields.len() == def.non_enum_variant().fields.len() { span_lint( cx, 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 5539331d0460b..1362e7e114e84 100644 --- a/src/tools/clippy/clippy_lints/src/pattern_type_mismatch.rs +++ b/src/tools/clippy/clippy_lints/src/pattern_type_mismatch.rs @@ -6,7 +6,7 @@ use rustc_hir::{ use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty::subst::SubstsRef; -use rustc_middle::ty::{AdtDef, FieldDef, Ty, TyKind, VariantDef}; +use rustc_middle::ty::{AdtDef, FieldDef, Ty, TyData, VariantDef}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; @@ -179,7 +179,7 @@ enum Level { Lower, } -#[allow(rustc::usage_of_ty_tykind)] +#[allow(rustc::usage_of_ty_tydata)] fn find_first_mismatch<'tcx>( cx: &LateContext<'tcx>, pat: &Pat<'_>, @@ -187,19 +187,19 @@ fn find_first_mismatch<'tcx>( level: Level, ) -> Option<(Span, Mutability, Level)> { if let PatKind::Ref(ref sub_pat, _) = pat.kind { - if let TyKind::Ref(_, sub_ty, _) = ty.kind() { + if let TyData::Ref(_, sub_ty, _) = ty.data() { return find_first_mismatch(cx, sub_pat, sub_ty, Level::Lower); } } - if let TyKind::Ref(_, _, mutability) = *ty.kind() { + if let TyData::Ref(_, _, mutability) = *ty.data() { if is_non_ref_pattern(&pat.kind) { return Some((pat.span, mutability, level)); } } if let PatKind::Struct(ref qpath, ref field_pats, _) = pat.kind { - if let TyKind::Adt(ref adt_def, ref substs_ref) = ty.kind() { + if let TyData::Adt(ref adt_def, ref substs_ref) = ty.data() { if let Some(variant) = get_variant(adt_def, qpath) { let field_defs = &variant.fields; return find_first_mismatch_in_struct(cx, field_pats, field_defs, substs_ref); @@ -208,7 +208,7 @@ fn find_first_mismatch<'tcx>( } if let PatKind::TupleStruct(ref qpath, ref pats, _) = pat.kind { - if let TyKind::Adt(ref adt_def, ref substs_ref) = ty.kind() { + if let TyData::Adt(ref adt_def, ref substs_ref) = ty.data() { if let Some(variant) = get_variant(adt_def, qpath) { let field_defs = &variant.fields; let ty_iter = field_defs.iter().map(|field_def| field_def.ty(cx.tcx, substs_ref)); @@ -218,7 +218,7 @@ fn find_first_mismatch<'tcx>( } if let PatKind::Tuple(ref pats, _) = pat.kind { - if let TyKind::Tuple(..) = ty.kind() { + if let TyData::Tuple(..) = ty.data() { return find_first_mismatch_in_tuple(cx, pats, ty.tuple_fields()); } } diff --git a/src/tools/clippy/clippy_lints/src/ptr.rs b/src/tools/clippy/clippy_lints/src/ptr.rs index 6b1c848a9467b..b6995b35ca71a 100644 --- a/src/tools/clippy/clippy_lints/src/ptr.rs +++ b/src/tools/clippy/clippy_lints/src/ptr.rs @@ -180,7 +180,7 @@ fn check_fn(cx: &LateContext<'_>, decl: &FnDecl<'_>, fn_id: HirId, opt_body_id: } } - if let ty::Ref(_, ty, Mutability::Not) = ty.kind() { + if let ty::Ref(_, ty, Mutability::Not) = ty.data() { if is_type_diagnostic_item(cx, ty, sym!(vec_type)) { let mut ty_snippet = None; if_chain! { diff --git a/src/tools/clippy/clippy_lints/src/ranges.rs b/src/tools/clippy/clippy_lints/src/ranges.rs index cc492917b9daf..4cc524391cdc1 100644 --- a/src/tools/clippy/clippy_lints/src/ranges.rs +++ b/src/tools/clippy/clippy_lints/src/ranges.rs @@ -281,7 +281,7 @@ fn check_reversed_empty_range(cx: &LateContext<'_>, expr: &Expr<'_>) { if_chain! { if let Some(higher::Range { start: Some(start), end: Some(end), limits }) = higher::range(expr); let ty = cx.typeck_results().expr_ty(start); - if let ty::Int(_) | ty::Uint(_) = ty.kind(); + if let ty::Int(_) | ty::Uint(_) = ty.data(); if let Some((start_idx, _)) = constant(cx, cx.typeck_results(), start); if let Some((end_idx, _)) = constant(cx, cx.typeck_results(), end); if let Some(ordering) = Constant::partial_cmp(cx.tcx, ty, &start_idx, &end_idx); diff --git a/src/tools/clippy/clippy_lints/src/redundant_clone.rs b/src/tools/clippy/clippy_lints/src/redundant_clone.rs index b4502c668dcbe..4cb8332669908 100644 --- a/src/tools/clippy/clippy_lints/src/redundant_clone.rs +++ b/src/tools/clippy/clippy_lints/src/redundant_clone.rs @@ -124,7 +124,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClone { continue; } - if let ty::Adt(ref def, _) = arg_ty.kind() { + if let ty::Adt(ref def, _) = arg_ty.data() { if match_def_path(cx, def.did, &paths::MEM_MANUALLY_DROP) { continue; } @@ -286,7 +286,7 @@ fn is_call_with_ref_arg<'tcx>( if let mir::TerminatorKind::Call { func, args, destination, .. } = kind; if args.len() == 1; if let mir::Operand::Move(mir::Place { local, .. }) = &args[0]; - if let ty::FnDef(def_id, _) = *func.ty(&*mir, cx.tcx).kind(); + if let ty::FnDef(def_id, _) = *func.ty(&*mir, cx.tcx).data(); if let (inner_ty, 1) = walk_ptrs_ty_depth(args[0].ty(&*mir, cx.tcx)); if !is_copy(cx, inner_ty); then { diff --git a/src/tools/clippy/clippy_lints/src/shadow.rs b/src/tools/clippy/clippy_lints/src/shadow.rs index 225fe58906f73..a483cf7f01fa3 100644 --- a/src/tools/clippy/clippy_lints/src/shadow.rs +++ b/src/tools/clippy/clippy_lints/src/shadow.rs @@ -166,7 +166,7 @@ fn check_local<'tcx>(cx: &LateContext<'tcx>, local: &'tcx Local<'_>, bindings: & fn is_binding(cx: &LateContext<'_>, pat_id: HirId) -> bool { let var_ty = cx.typeck_results().node_type_opt(pat_id); - var_ty.map_or(false, |var_ty| !matches!(var_ty.kind(), ty::Adt(..))) + var_ty.map_or(false, |var_ty| !matches!(var_ty.data(), ty::Adt(..))) } fn check_pat<'tcx>( diff --git a/src/tools/clippy/clippy_lints/src/swap.rs b/src/tools/clippy/clippy_lints/src/swap.rs index 54b38d9f4ced2..a10350591b097 100644 --- a/src/tools/clippy/clippy_lints/src/swap.rs +++ b/src/tools/clippy/clippy_lints/src/swap.rs @@ -195,8 +195,8 @@ fn check_for_slice<'a>(cx: &LateContext<'_>, lhs1: &'a Expr<'_>, lhs2: &'a Expr< if eq_expr_value(cx, lhs1, lhs2) { let ty = cx.typeck_results().expr_ty(lhs1).peel_refs(); - if matches!(ty.kind(), ty::Slice(_)) - || matches!(ty.kind(), ty::Array(_, _)) + if matches!(ty.data(), ty::Slice(_)) + || matches!(ty.data(), ty::Array(_, _)) || is_type_diagnostic_item(cx, ty, sym!(vec_type)) || is_type_diagnostic_item(cx, ty, sym!(vecdeque_type)) { 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 eeda39bfa2087..7301e11fe5123 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 { if let [char_arg, radix_arg] = &**to_digit_args; if to_digits_path.ident.name.as_str() == "to_digit"; let char_arg_ty = cx.typeck_results().expr_ty_adjusted(char_arg); - if *char_arg_ty.kind() == ty::Char; + if *char_arg_ty.data() == ty::Char; then { Some((true, char_arg, radix_arg)) } else { diff --git a/src/tools/clippy/clippy_lints/src/transmute.rs b/src/tools/clippy/clippy_lints/src/transmute.rs index c75adb62f2575..162d9abe0e310 100644 --- a/src/tools/clippy/clippy_lints/src/transmute.rs +++ b/src/tools/clippy/clippy_lints/src/transmute.rs @@ -339,7 +339,7 @@ impl<'tcx> LateLintPass<'tcx> for Transmute { let from_ty = cx.typeck_results().expr_ty(&args[0]); let to_ty = cx.typeck_results().expr_ty(e); - match (&from_ty.kind(), &to_ty.kind()) { + match (&from_ty.data(), &to_ty.data()) { _ if from_ty == to_ty => span_lint( cx, USELESS_TRANSMUTE, @@ -447,7 +447,7 @@ impl<'tcx> LateLintPass<'tcx> for Transmute { &format!("transmute from a `{}` to a `char`", from_ty), |diag| { let arg = sugg::Sugg::hir(cx, &args[0], ".."); - let arg = if let ty::Int(_) = from_ty.kind() { + let arg = if let ty::Int(_) = from_ty.data() { arg.as_ty(ast::UintTy::U32.name_str()) } else { arg @@ -463,8 +463,8 @@ impl<'tcx> LateLintPass<'tcx> for Transmute { }, (ty::Ref(_, ty_from, from_mutbl), ty::Ref(_, ty_to, to_mutbl)) => { if_chain! { - if let (&ty::Slice(slice_ty), &ty::Str) = (&ty_from.kind(), &ty_to.kind()); - if let ty::Uint(ast::UintTy::U8) = slice_ty.kind(); + if let (&ty::Slice(slice_ty), &ty::Str) = (&ty_from.data(), &ty_to.data()); + if let ty::Uint(ast::UintTy::U8) = slice_ty.data(); if from_mutbl == to_mutbl; then { let postfix = if *from_mutbl == Mutability::Mut { @@ -557,7 +557,7 @@ impl<'tcx> LateLintPass<'tcx> for Transmute { &format!("transmute from a `{}` to a `{}`", from_ty, to_ty), |diag| { let arg = sugg::Sugg::hir(cx, &args[0], ".."); - let arg = if let ty::Int(int_ty) = from_ty.kind() { + let arg = if let ty::Int(int_ty) = from_ty.data() { arg.as_ty(format!( "u{}", int_ty.bit_width().map_or_else(|| "size".to_string(), |v| v.to_string()) @@ -603,7 +603,7 @@ impl<'tcx> LateLintPass<'tcx> for Transmute { arg = sugg::Sugg::NonParen(format!("{}.to_bits()", arg.maybe_par()).into()); // cast the result of `to_bits` if `to_ty` is signed - arg = if let ty::Int(int_ty) = to_ty.kind() { + arg = if let ty::Int(int_ty) = to_ty.data() { arg.as_ty(int_ty.name_str().to_string()) } else { arg diff --git a/src/tools/clippy/clippy_lints/src/trivially_copy_pass_by_ref.rs b/src/tools/clippy/clippy_lints/src/trivially_copy_pass_by_ref.rs index 1f06d2dbe9144..7a67bcfe19fdb 100644 --- a/src/tools/clippy/clippy_lints/src/trivially_copy_pass_by_ref.rs +++ b/src/tools/clippy/clippy_lints/src/trivially_copy_pass_by_ref.rs @@ -83,7 +83,7 @@ impl<'tcx> TriviallyCopyPassByRef { // Use lifetimes to determine if we're returning a reference to the // argument. In that case we can't switch to pass-by-value as the // argument will not live long enough. - let output_lts = match *fn_sig.output().kind() { + let output_lts = match *fn_sig.output().data() { ty::Ref(output_lt, _, _) => vec![output_lt], ty::Adt(_, substs) => substs.regions().collect(), _ => vec![], @@ -97,7 +97,7 @@ impl<'tcx> TriviallyCopyPassByRef { } if_chain! { - if let ty::Ref(input_lt, ty, Mutability::Not) = ty.kind(); + if let ty::Ref(input_lt, ty, Mutability::Not) = ty.data(); if !output_lts.contains(&input_lt); if is_copy(cx, ty); if let Some(size) = cx.layout_of(ty).ok().map(|l| l.size.bytes()); diff --git a/src/tools/clippy/clippy_lints/src/try_err.rs b/src/tools/clippy/clippy_lints/src/try_err.rs index 3e747ec4ad9e2..6a235d86a60d9 100644 --- a/src/tools/clippy/clippy_lints/src/try_err.rs +++ b/src/tools/clippy/clippy_lints/src/try_err.rs @@ -132,7 +132,7 @@ fn find_return_type<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx ExprKind<'_>) -> O /// Extracts the error type from Result. fn result_error_type<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option> { if_chain! { - if let ty::Adt(_, subst) = ty.kind(); + if let ty::Adt(_, subst) = ty.data(); if is_type_diagnostic_item(cx, ty, sym!(result_type)); let err_ty = subst.type_at(1); then { @@ -146,11 +146,11 @@ fn result_error_type<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option>. fn poll_result_error_type<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option> { if_chain! { - if let ty::Adt(def, subst) = ty.kind(); + if let ty::Adt(def, subst) = ty.data(); if match_def_path(cx, def.did, &paths::POLL); let ready_ty = subst.type_at(0); - if let ty::Adt(ready_def, ready_subst) = ready_ty.kind(); + if let ty::Adt(ready_def, ready_subst) = ready_ty.data(); if cx.tcx.is_diagnostic_item(sym!(result_type), ready_def.did); let err_ty = ready_subst.type_at(1); @@ -165,15 +165,15 @@ fn poll_result_error_type<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option< /// Extracts the error type from Poll>>. fn poll_option_result_error_type<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option> { if_chain! { - if let ty::Adt(def, subst) = ty.kind(); + if let ty::Adt(def, subst) = ty.data(); if match_def_path(cx, def.did, &paths::POLL); let ready_ty = subst.type_at(0); - if let ty::Adt(ready_def, ready_subst) = ready_ty.kind(); + if let ty::Adt(ready_def, ready_subst) = ready_ty.data(); if cx.tcx.is_diagnostic_item(sym!(option_type), ready_def.did); let some_ty = ready_subst.type_at(0); - if let ty::Adt(some_def, some_subst) = some_ty.kind(); + if let ty::Adt(some_def, some_subst) = some_ty.data(); if cx.tcx.is_diagnostic_item(sym!(result_type), some_def.did); let err_ty = some_subst.type_at(1); diff --git a/src/tools/clippy/clippy_lints/src/types.rs b/src/tools/clippy/clippy_lints/src/types.rs index 5e83b6c81ec8f..2f215a076e72a 100644 --- a/src/tools/clippy/clippy_lints/src/types.rs +++ b/src/tools/clippy/clippy_lints/src/types.rs @@ -1091,7 +1091,7 @@ fn is_questionmark_desugar_marked_call(expr: &Expr<'_>) -> bool { } fn is_unit(ty: Ty<'_>) -> bool { - matches!(ty.kind(), ty::Tuple(slice) if slice.is_empty()) + matches!(ty.data(), ty::Tuple(slice) if slice.is_empty()) } fn is_unit_literal(expr: &Expr<'_>) -> bool { @@ -1318,7 +1318,7 @@ declare_clippy_lint! { /// Returns the size in bits of an integral type. /// Will return 0 if the type is not an int or uint variant fn int_ty_to_nbits(typ: Ty<'_>, tcx: TyCtxt<'_>) -> u64 { - match typ.kind() { + match typ.data() { ty::Int(i) => match i { IntTy::Isize => tcx.data_layout.pointer_size.bits(), IntTy::I8 => 8, @@ -1340,7 +1340,7 @@ fn int_ty_to_nbits(typ: Ty<'_>, tcx: TyCtxt<'_>) -> u64 { } fn is_isize_or_usize(typ: Ty<'_>) -> bool { - matches!(typ.kind(), ty::Int(IntTy::Isize) | ty::Uint(UintTy::Usize)) + matches!(typ.data(), ty::Int(IntTy::Isize) | ty::Uint(UintTy::Usize)) } fn span_precision_loss_lint(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, cast_to_f64: bool) { @@ -1432,7 +1432,7 @@ fn check_loss_of_sign(cx: &LateContext<'_>, expr: &Expr<'_>, op: &Expr<'_>, cast if_chain! { if let Some((const_val, _)) = const_val; if let Constant::Int(n) = const_val; - if let ty::Int(ity) = *cast_from.kind(); + if let ty::Int(ity) = *cast_from.data(); if sext(cx.tcx, n, ity) >= 0; then { return @@ -1565,7 +1565,7 @@ declare_lint_pass!(Casts => [ // Check if the given type is either `core::ffi::c_void` or // one of the platform specific `libc::::c_void` of libc. fn is_c_void(cx: &LateContext<'_>, ty: Ty<'_>) -> bool { - if let ty::Adt(adt, _) = ty.kind() { + if let ty::Adt(adt, _) = ty.data() { let names = cx.get_def_path(adt.did); if names.is_empty() { @@ -1581,7 +1581,7 @@ fn is_c_void(cx: &LateContext<'_>, ty: Ty<'_>) -> bool { /// Returns the mantissa bits wide of a fp type. /// Will return 0 if the type is not a fp fn fp_ty_mantissa_nbits(typ: Ty<'_>) -> u32 { - match typ.kind() { + match typ.data() { ty::Float(FloatTy::F32) => 23, ty::Float(FloatTy::F64) | ty::Infer(InferTy::FloatVar(_)) => 52, _ => 0, @@ -1621,7 +1621,7 @@ impl<'tcx> LateLintPass<'tcx> for Casts { match lit.node { LitKind::Int(_, LitIntType::Unsuffixed) | LitKind::Float(_, LitFloatType::Unsuffixed) => {}, _ => { - if cast_from.kind() == cast_to.kind() && !in_external_macro(cx.sess(), expr.span) { + if cast_from.data() == cast_to.data() && !in_external_macro(cx.sess(), expr.span) { span_lint( cx, UNNECESSARY_CAST, @@ -1654,7 +1654,7 @@ fn lint_numeric_casts<'tcx>( match (cast_from.is_integral(), cast_to.is_integral()) { (true, false) => { let from_nbits = int_ty_to_nbits(cast_from, cx.tcx); - let to_nbits = if let ty::Float(FloatTy::F32) = cast_to.kind() { + let to_nbits = if let ty::Float(FloatTy::F32) = cast_to.data() { 32 } else { 64 @@ -1691,7 +1691,7 @@ fn lint_numeric_casts<'tcx>( check_lossless(cx, expr, cast_expr, cast_from, cast_to); }, (false, false) => { - if let (&ty::Float(FloatTy::F64), &ty::Float(FloatTy::F32)) = (&cast_from.kind(), &cast_to.kind()) { + if let (&ty::Float(FloatTy::F64), &ty::Float(FloatTy::F32)) = (&cast_from.data(), &cast_to.data()) { span_lint( cx, CAST_POSSIBLE_TRUNCATION, @@ -1699,7 +1699,7 @@ fn lint_numeric_casts<'tcx>( "casting `f64` to `f32` may truncate the value", ); } - if let (&ty::Float(FloatTy::F32), &ty::Float(FloatTy::F64)) = (&cast_from.kind(), &cast_to.kind()) { + if let (&ty::Float(FloatTy::F32), &ty::Float(FloatTy::F64)) = (&cast_from.data(), &cast_to.data()) { span_lossless_lint(cx, expr, cast_expr, cast_from, cast_to); } }, @@ -1708,8 +1708,8 @@ fn lint_numeric_casts<'tcx>( fn lint_cast_ptr_alignment<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, cast_from: Ty<'tcx>, cast_to: Ty<'tcx>) { if_chain! { - if let ty::RawPtr(from_ptr_ty) = &cast_from.kind(); - if let ty::RawPtr(to_ptr_ty) = &cast_to.kind(); + if let ty::RawPtr(from_ptr_ty) = &cast_from.data(); + if let ty::RawPtr(to_ptr_ty) = &cast_to.data(); if let Ok(from_layout) = cx.layout_of(from_ptr_ty.ty); if let Ok(to_layout) = cx.layout_of(to_ptr_ty.ty); if from_layout.align.abi < to_layout.align.abi; @@ -1742,11 +1742,11 @@ fn lint_fn_to_numeric_cast( cast_to: Ty<'_>, ) { // We only want to check casts to `ty::Uint` or `ty::Int` - match cast_to.kind() { + match cast_to.data() { ty::Uint(_) | ty::Int(..) => { /* continue on */ }, _ => return, } - match cast_from.kind() { + match cast_from.data() { ty::FnDef(..) | ty::FnPtr(_) => { let mut applicability = Applicability::MaybeIncorrect; let from_snippet = snippet_with_applicability(cx, cast_expr.span, "x", &mut applicability); @@ -1765,7 +1765,7 @@ fn lint_fn_to_numeric_cast( format!("{} as usize", from_snippet), applicability, ); - } else if *cast_to.kind() != ty::Uint(UintTy::Usize) { + } else if *cast_to.data() != ty::Uint(UintTy::Usize) { span_lint_and_sugg( cx, FN_TO_NUMERIC_CAST, @@ -1982,7 +1982,7 @@ impl<'tcx> LateLintPass<'tcx> for CharLitAsU8 { if let ExprKind::Cast(e, _) = &expr.kind; if let ExprKind::Lit(l) = &e.kind; if let LitKind::Char(c) = l.node; - if ty::Uint(UintTy::U8) == *cx.typeck_results().expr_ty(expr).kind(); + if ty::Uint(UintTy::U8) == *cx.typeck_results().expr_ty(expr).data(); then { let mut applicability = Applicability::MachineApplicable; let snippet = snippet_with_applicability(cx, e.span, "'x'", &mut applicability); @@ -2121,7 +2121,7 @@ fn detect_extreme_expr<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Op let cv = constant(cx, cx.typeck_results(), expr)?.0; - let which = match (ty.kind(), cv) { + let which = match (ty.data(), cv) { (&ty::Bool, Constant::Bool(false)) | (&ty::Uint(_), Constant::Int(0)) => Minimum, (&ty::Int(ity), Constant::Int(i)) if i == unsext(cx.tcx, i128::MIN >> (128 - int_bits(cx.tcx, ity)), ity) => { Minimum @@ -2256,7 +2256,7 @@ fn numeric_cast_precast_bounds<'a>(cx: &LateContext<'_>, expr: &'a Expr<'_>) -> if cx.layout_of(pre_cast_ty).ok().map(|l| l.size) == cx.layout_of(cast_ty).ok().map(|l| l.size) { return None; } - match pre_cast_ty.kind() { + match pre_cast_ty.data() { ty::Int(int_ty) => Some(match int_ty { IntTy::I8 => (FullInt::S(i128::from(i8::MIN)), FullInt::S(i128::from(i8::MAX))), IntTy::I16 => (FullInt::S(i128::from(i16::MIN)), FullInt::S(i128::from(i16::MAX))), @@ -2283,7 +2283,7 @@ fn numeric_cast_precast_bounds<'a>(cx: &LateContext<'_>, expr: &'a Expr<'_>) -> fn node_as_const_fullint<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option { let val = constant(cx, cx.typeck_results(), expr)?.0; if let Constant::Int(const_int) = val { - match *cx.typeck_results().expr_ty(expr).kind() { + match *cx.typeck_results().expr_ty(expr).data() { ty::Int(ity) => Some(FullInt::S(sext(cx.tcx, const_int, ity))), ty::Uint(_) => Some(FullInt::U(const_int)), _ => None, @@ -2786,7 +2786,7 @@ impl<'tcx> LateLintPass<'tcx> for RefToMut { if let TyKind::Ptr(MutTy { mutbl: Mutability::Mut, .. }) = t.kind; if let ExprKind::Cast(e, t) = &e.kind; if let TyKind::Ptr(MutTy { mutbl: Mutability::Not, .. }) = t.kind; - if let ty::Ref(..) = cx.typeck_results().node_type(e.hir_id).kind(); + if let ty::Ref(..) = cx.typeck_results().node_type(e.hir_id).data(); then { span_lint( cx, diff --git a/src/tools/clippy/clippy_lints/src/unit_return_expecting_ord.rs b/src/tools/clippy/clippy_lints/src/unit_return_expecting_ord.rs index 0d5a5017331b7..52230572b18f7 100644 --- a/src/tools/clippy/clippy_lints/src/unit_return_expecting_ord.rs +++ b/src/tools/clippy/clippy_lints/src/unit_return_expecting_ord.rs @@ -110,7 +110,7 @@ fn get_args_to_check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Ve fn check_arg<'tcx>(cx: &LateContext<'tcx>, arg: &'tcx Expr<'tcx>) -> Option<(Span, Option)> { if_chain! { if let ExprKind::Closure(_, _fn_decl, body_id, span, _) = arg.kind; - if let ty::Closure(_def_id, substs) = &cx.typeck_results().node_type(arg.hir_id).kind(); + if let ty::Closure(_def_id, substs) = &cx.typeck_results().node_type(arg.hir_id).data(); let ret_ty = substs.as_closure().sig().output(); let ty = cx.tcx.erase_late_bound_regions(&ret_ty); if ty.is_unit(); diff --git a/src/tools/clippy/clippy_lints/src/unnamed_address.rs b/src/tools/clippy/clippy_lints/src/unnamed_address.rs index 9582c162e77b2..73cd684dc93e1 100644 --- a/src/tools/clippy/clippy_lints/src/unnamed_address.rs +++ b/src/tools/clippy/clippy_lints/src/unnamed_address.rs @@ -65,14 +65,14 @@ impl LateLintPass<'_> for UnnamedAddress { } fn is_trait_ptr(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { - match cx.typeck_results().expr_ty_adjusted(expr).kind() { + match cx.typeck_results().expr_ty_adjusted(expr).data() { ty::RawPtr(ty::TypeAndMut { ty, .. }) => ty.is_trait(), _ => false, } } fn is_fn_def(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { - matches!(cx.typeck_results().expr_ty(expr).kind(), ty::FnDef(..)) + matches!(cx.typeck_results().expr_ty(expr).data(), ty::FnDef(..)) } if_chain! { diff --git a/src/tools/clippy/clippy_lints/src/unnecessary_sort_by.rs b/src/tools/clippy/clippy_lints/src/unnecessary_sort_by.rs index 1307237dbc70a..5beb0ac033f45 100644 --- a/src/tools/clippy/clippy_lints/src/unnecessary_sort_by.rs +++ b/src/tools/clippy/clippy_lints/src/unnecessary_sort_by.rs @@ -225,7 +225,7 @@ fn detect_lint(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option { fn expr_borrows(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { let ty = cx.typeck_results().expr_ty(expr); - matches!(ty.kind(), ty::Ref(..)) || ty.walk().any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(_))) + matches!(ty.data(), ty::Ref(..)) || ty.walk().any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(_))) } impl LateLintPass<'_> for UnnecessarySortBy { diff --git a/src/tools/clippy/clippy_lints/src/useless_conversion.rs b/src/tools/clippy/clippy_lints/src/useless_conversion.rs index 4e4a206a583a2..79580c55eedde 100644 --- a/src/tools/clippy/clippy_lints/src/useless_conversion.rs +++ b/src/tools/clippy/clippy_lints/src/useless_conversion.rs @@ -107,7 +107,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion { let a = cx.typeck_results().expr_ty(e); let b = cx.typeck_results().expr_ty(&args[0]); if is_type_diagnostic_item(cx, a, sym!(result_type)); - if let ty::Adt(_, substs) = a.kind(); + if let ty::Adt(_, substs) = a.data(); if let Some(a_type) = substs.types().next(); if TyS::same_type(a_type, b); @@ -137,7 +137,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion { if_chain! { if match_def_path(cx, def_id, &paths::TRY_FROM); if is_type_diagnostic_item(cx, a, sym!(result_type)); - if let ty::Adt(_, substs) = a.kind(); + if let ty::Adt(_, substs) = a.data(); if let Some(a_type) = substs.types().next(); if TyS::same_type(a_type, b); diff --git a/src/tools/clippy/clippy_lints/src/utils/mod.rs b/src/tools/clippy/clippy_lints/src/utils/mod.rs index 790ac4f7dd8aa..4c4625d0995ac 100644 --- a/src/tools/clippy/clippy_lints/src/utils/mod.rs +++ b/src/tools/clippy/clippy_lints/src/utils/mod.rs @@ -135,7 +135,7 @@ pub fn is_wild<'tcx>(pat: &impl std::ops::Deref>) -> bool { /// If the type is a diagnostic item, use `is_type_diagnostic_item` instead. /// If you change the signature, remember to update the internal lint `MatchTypeOnDiagItem` pub fn match_type(cx: &LateContext<'_>, ty: Ty<'_>, path: &[&str]) -> bool { - match ty.kind() { + match ty.data() { ty::Adt(adt, _) => match_def_path(cx, adt.did, path), _ => false, } @@ -145,7 +145,7 @@ pub fn match_type(cx: &LateContext<'_>, ty: Ty<'_>, path: &[&str]) -> bool { /// /// If you change the signature, remember to update the internal lint `MatchTypeOnDiagItem` pub fn is_type_diagnostic_item(cx: &LateContext<'_>, ty: Ty<'_>, diag_item: Symbol) -> bool { - match ty.kind() { + match ty.data() { ty::Adt(adt, _) => cx.tcx.is_diagnostic_item(diag_item, adt.did), _ => false, } @@ -153,7 +153,7 @@ pub fn is_type_diagnostic_item(cx: &LateContext<'_>, ty: Ty<'_>, diag_item: Symb /// Checks if the type is equal to a lang item pub fn is_type_lang_item(cx: &LateContext<'_>, ty: Ty<'_>, lang_item: hir::LangItem) -> bool { - match ty.kind() { + match ty.data() { ty::Adt(adt, _) => cx.tcx.lang_items().require(lang_item).unwrap() == adt.did, _ => false, } @@ -758,7 +758,7 @@ pub fn walk_ptrs_hir_ty<'tcx>(ty: &'tcx hir::Ty<'tcx>) -> &'tcx hir::Ty<'tcx> { /// depth. pub fn walk_ptrs_ty_depth(ty: Ty<'_>) -> (Ty<'_>, usize) { fn inner(ty: Ty<'_>, depth: usize) -> (Ty<'_>, usize) { - match ty.kind() { + match ty.data() { ty::Ref(_, ty, _) => inner(ty, depth + 1), _ => (ty, depth), } @@ -871,7 +871,7 @@ pub fn contains_ty(ty: Ty<'_>, other_ty: Ty<'_>) -> bool { /// Returns `true` if the given type is an `unsafe` function. pub fn type_is_unsafe_function<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool { - match ty.kind() { + match ty.data() { ty::FnDef(..) | ty::FnPtr(_) => ty.fn_sig(cx.tcx).unsafety() == Unsafety::Unsafe, _ => false, } @@ -928,7 +928,7 @@ pub fn is_refutable(cx: &LateContext<'_>, pat: &Pat<'_>) -> bool { is_enum_variant(cx, qpath, pat.hir_id) || are_refutable(cx, pats.iter().map(|pat| &**pat)) }, PatKind::Slice(ref head, ref middle, ref tail) => { - match &cx.typeck_results().node_type(pat.hir_id).kind() { + match &cx.typeck_results().node_type(pat.hir_id).data() { ty::Slice(..) => { // [..] is the only irrefutable slice pattern. !head.is_empty() || middle.is_none() || !tail.is_empty() @@ -1142,12 +1142,12 @@ pub fn has_iter_method(cx: &LateContext<'_>, probably_ref_ty: Ty<'_>) -> Option< &paths::RECEIVER, ]; - let ty_to_check = match probably_ref_ty.kind() { + let ty_to_check = match probably_ref_ty.data() { ty::Ref(_, ty_to_check, _) => ty_to_check, _ => probably_ref_ty, }; - let def_id = match ty_to_check.kind() { + let def_id = match ty_to_check.data() { ty::Array(..) => return Some("array"), ty::Slice(..) => return Some("slice"), ty::Adt(adt, _) => adt.did, @@ -1263,7 +1263,7 @@ pub fn must_use_attr(attrs: &[Attribute]) -> Option<&Attribute> { // Returns whether the type has #[must_use] attribute pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool { - match ty.kind() { + match ty.data() { ty::Adt(ref adt, _) => must_use_attr(&cx.tcx.get_attrs(adt.did)).is_some(), ty::Foreign(ref did) => must_use_attr(&cx.tcx.get_attrs(*did)).is_some(), ty::Slice(ref ty) @@ -1395,9 +1395,9 @@ pub fn run_lints(cx: &LateContext<'_>, lints: &[&'static Lint], id: HirId) -> bo /// Returns true iff 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.data() { ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Str => true, - ty::Ref(_, inner, _) if *inner.kind() == ty::Str => true, + ty::Ref(_, inner, _) if *inner.data() == ty::Str => true, ty::Array(inner_type, _) | ty::Slice(inner_type) => is_recursively_primitive_type(inner_type), ty::Tuple(inner_types) => inner_types.types().all(is_recursively_primitive_type), _ => false, @@ -1409,11 +1409,11 @@ pub fn is_recursively_primitive_type(ty: Ty<'_>) -> bool { /// `is_recursively_primitive_type` function) and None otherwise. pub fn is_slice_of_primitives(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option { let expr_type = cx.typeck_results().expr_ty_adjusted(expr); - let expr_kind = expr_type.kind(); + let expr_kind = expr_type.data(); let is_primitive = match expr_kind { ty::Slice(element_type) => is_recursively_primitive_type(element_type), - ty::Ref(_, inner_ty, _) if matches!(inner_ty.kind(), &ty::Slice(_)) => { - if let ty::Slice(element_type) = inner_ty.kind() { + ty::Ref(_, inner_ty, _) if matches!(inner_ty.data(), &ty::Slice(_)) => { + if let ty::Slice(element_type) = inner_ty.data() { is_recursively_primitive_type(element_type) } else { unreachable!() @@ -1425,7 +1425,7 @@ pub fn is_slice_of_primitives(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option return Some("slice".into()), ty::Array(..) => return Some("array".into()), ty::Tuple(..) => return Some("tuple".into()), diff --git a/src/tools/clippy/clippy_lints/src/utils/qualify_min_const_fn.rs b/src/tools/clippy/clippy_lints/src/utils/qualify_min_const_fn.rs index 1b4f20342729a..7f0e310cf56de 100644 --- a/src/tools/clippy/clippy_lints/src/utils/qualify_min_const_fn.rs +++ b/src/tools/clippy/clippy_lints/src/utils/qualify_min_const_fn.rs @@ -34,7 +34,7 @@ pub fn is_min_const_fn(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>) -> McfResult { if Some(pred.def_id()) == tcx.lang_items().sized_trait() { continue; } - match pred.self_ty().kind() { + match pred.self_ty().data() { ty::Param(ref p) => { let generics = tcx.generics_of(current); let def = generics.type_param(p, tcx); @@ -88,7 +88,7 @@ fn check_ty(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, span: Span) -> McfResult { GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => continue, }; - match ty.kind() { + match ty.data() { ty::Ref(_, _, hir::Mutability::Mut) => { return Err((span, "mutable references in const fn are unstable".into())); }, @@ -162,7 +162,7 @@ fn check_rvalue(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: DefId, rvalue: &Rv return Err((span, "unsizing casts are only allowed for references right now".into())); }; let unsized_ty = tcx.struct_tail_erasing_lifetimes(pointee_ty, tcx.param_env(def_id)); - if let ty::Slice(_) | ty::Str = unsized_ty.kind() { + if let ty::Slice(_) | ty::Str = unsized_ty.data() { check_operand(tcx, op, span, body)?; // Casting/coercing things to slices is fine. Ok(()) @@ -300,7 +300,7 @@ fn check_terminator(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, terminator: &Termin 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.data() { if !rustc_mir::const_eval::is_min_const_fn(tcx, fn_def_id) { return Err(( span, diff --git a/src/tools/clippy/clippy_lints/src/vec.rs b/src/tools/clippy/clippy_lints/src/vec.rs index 149cceb39dd99..d8eae69784ed6 100644 --- a/src/tools/clippy/clippy_lints/src/vec.rs +++ b/src/tools/clippy/clippy_lints/src/vec.rs @@ -44,8 +44,8 @@ impl<'tcx> LateLintPass<'tcx> for UselessVec { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { // search for `&vec![_]` expressions where the adjusted type is `&[_]` if_chain! { - if let ty::Ref(_, ty, _) = cx.typeck_results().expr_ty_adjusted(expr).kind(); - if let ty::Slice(..) = ty.kind(); + if let ty::Ref(_, ty, _) = cx.typeck_results().expr_ty_adjusted(expr).data(); + if let ty::Slice(..) = ty.data(); if let ExprKind::AddrOf(BorrowKind::Ref, _, ref addressee) = expr.kind; if let Some(vec_args) = higher::vec_macro(cx, addressee); then { @@ -127,7 +127,7 @@ fn size_of(cx: &LateContext<'_>, expr: &Expr<'_>) -> u64 { /// Returns the item type of the vector (i.e., the `T` in `Vec`). fn vec_type(ty: Ty<'_>) -> Ty<'_> { - if let ty::Adt(_, substs) = ty.kind() { + if let ty::Adt(_, substs) = ty.data() { substs.type_at(0) } else { panic!("The type of `vec!` is a not a struct?");