Skip to content

Commit 3e14b68

Browse files
Change ty.kind to a method
1 parent ef55a0a commit 3e14b68

File tree

189 files changed

+947
-899
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

189 files changed

+947
-899
lines changed

compiler/rustc_codegen_llvm/src/builder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,10 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
306306
use rustc_ast::UintTy::*;
307307
use rustc_middle::ty::{Int, Uint};
308308

309-
let new_kind = match ty.kind {
309+
let new_kind = match ty.kind() {
310310
Int(t @ Isize) => Int(t.normalize(self.tcx.sess.target.ptr_width)),
311311
Uint(t @ Usize) => Uint(t.normalize(self.tcx.sess.target.ptr_width)),
312-
ref t @ (Uint(_) | Int(_)) => t.clone(),
312+
t @ (Uint(_) | Int(_)) => t.clone(),
313313
_ => panic!("tried to get overflow intrinsic for op applied to non-int type"),
314314
};
315315

compiler/rustc_codegen_llvm/src/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ fn check_and_apply_linkage(
125125
// extern "C" fn() from being non-null, so we can't just declare a
126126
// static and call it a day. Some linkages (like weak) will make it such
127127
// that the static actually has a null value.
128-
let llty2 = if let ty::RawPtr(ref mt) = ty.kind {
128+
let llty2 = if let ty::RawPtr(ref mt) = ty.kind() {
129129
cx.layout_of(mt.ty).llvm_type(cx)
130130
} else {
131131
cx.sess().span_fatal(

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ fn fixed_vec_metadata(
343343

344344
let (size, align) = cx.size_and_align_of(array_or_slice_type);
345345

346-
let upper_bound = match array_or_slice_type.kind {
346+
let upper_bound = match array_or_slice_type.kind() {
347347
ty::Array(_, len) => len.eval_usize(cx.tcx, ty::ParamEnv::reveal_all()) as c_longlong,
348348
_ => -1,
349349
};
@@ -432,7 +432,7 @@ fn subroutine_type_metadata(
432432

433433
let signature_metadata: Vec<_> = iter::once(
434434
// return type
435-
match signature.output().kind {
435+
match signature.output().kind() {
436436
ty::Tuple(ref tys) if tys.is_empty() => None,
437437
_ => Some(type_metadata(cx, signature.output(), span)),
438438
},
@@ -472,7 +472,7 @@ fn trait_pointer_metadata(
472472
// type is assigned the correct name, size, namespace, and source location.
473473
// However, it does not describe the trait's methods.
474474

475-
let containing_scope = match trait_type.kind {
475+
let containing_scope = match trait_type.kind() {
476476
ty::Dynamic(ref data, ..) => {
477477
data.principal_def_id().map(|did| get_namespace_for_item(cx, did))
478478
}
@@ -572,7 +572,7 @@ pub fn type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>, usage_site_span: Sp
572572

573573
debug!("type_metadata: {:?}", t);
574574

575-
let ptr_metadata = |ty: Ty<'tcx>| match ty.kind {
575+
let ptr_metadata = |ty: Ty<'tcx>| match *ty.kind() {
576576
ty::Slice(typ) => Ok(vec_slice_metadata(cx, t, typ, unique_type_id, usage_site_span)),
577577
ty::Str => Ok(vec_slice_metadata(cx, t, cx.tcx.types.u8, unique_type_id, usage_site_span)),
578578
ty::Dynamic(..) => Ok(MetadataCreationResult::new(
@@ -592,7 +592,7 @@ pub fn type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>, usage_site_span: Sp
592592
}
593593
};
594594

595-
let MetadataCreationResult { metadata, already_stored_in_typemap } = match t.kind {
595+
let MetadataCreationResult { metadata, already_stored_in_typemap } = match *t.kind() {
596596
ty::Never | ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) => {
597597
MetadataCreationResult::new(basic_type_metadata(cx, t), false)
598598
}
@@ -876,7 +876,7 @@ fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType {
876876
// .natvis visualizers (and perhaps other existing native debuggers?)
877877
let msvc_like_names = cx.tcx.sess.target.target.options.is_like_msvc;
878878

879-
let (name, encoding) = match t.kind {
879+
let (name, encoding) = match t.kind() {
880880
ty::Never => ("!", DW_ATE_unsigned),
881881
ty::Tuple(ref elements) if elements.is_empty() => ("()", DW_ATE_unsigned),
882882
ty::Bool => ("bool", DW_ATE_boolean),
@@ -904,7 +904,7 @@ fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType {
904904
return ty_metadata;
905905
}
906906

907-
let typedef_name = match t.kind {
907+
let typedef_name = match t.kind() {
908908
ty::Int(int_ty) => int_ty.name_str(),
909909
ty::Uint(uint_ty) => uint_ty.name_str(),
910910
ty::Float(float_ty) => float_ty.name_str(),
@@ -1239,7 +1239,7 @@ fn prepare_struct_metadata(
12391239
) -> RecursiveTypeDescription<'ll, 'tcx> {
12401240
let struct_name = compute_debuginfo_type_name(cx.tcx, struct_type, false);
12411241

1242-
let (struct_def_id, variant) = match struct_type.kind {
1242+
let (struct_def_id, variant) = match struct_type.kind() {
12431243
ty::Adt(def, _) => (def.did, def.non_enum_variant()),
12441244
_ => bug!("prepare_struct_metadata on a non-ADT"),
12451245
};
@@ -1373,7 +1373,7 @@ fn prepare_union_metadata(
13731373
) -> RecursiveTypeDescription<'ll, 'tcx> {
13741374
let union_name = compute_debuginfo_type_name(cx.tcx, union_type, false);
13751375

1376-
let (union_def_id, variant) = match union_type.kind {
1376+
let (union_def_id, variant) = match union_type.kind() {
13771377
ty::Adt(def, _) => (def.did, def.non_enum_variant()),
13781378
_ => bug!("prepare_union_metadata on a non-ADT"),
13791379
};
@@ -1457,14 +1457,14 @@ struct EnumMemberDescriptionFactory<'ll, 'tcx> {
14571457

14581458
impl EnumMemberDescriptionFactory<'ll, 'tcx> {
14591459
fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>) -> Vec<MemberDescription<'ll>> {
1460-
let generator_variant_info_data = match self.enum_type.kind {
1460+
let generator_variant_info_data = match *self.enum_type.kind() {
14611461
ty::Generator(def_id, ..) => {
14621462
Some(generator_layout_and_saved_local_names(cx.tcx, def_id))
14631463
}
14641464
_ => None,
14651465
};
14661466

1467-
let variant_info_for = |index: VariantIdx| match self.enum_type.kind {
1467+
let variant_info_for = |index: VariantIdx| match *self.enum_type.kind() {
14681468
ty::Adt(adt, _) => VariantInfo::Adt(&adt.variants[index]),
14691469
ty::Generator(def_id, _, _) => {
14701470
let (generator_layout, generator_saved_local_names) =
@@ -1486,14 +1486,14 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
14861486
} else {
14871487
type_metadata(cx, self.enum_type, self.span)
14881488
};
1489-
let flags = match self.enum_type.kind {
1489+
let flags = match self.enum_type.kind() {
14901490
ty::Generator(..) => DIFlags::FlagArtificial,
14911491
_ => DIFlags::FlagZero,
14921492
};
14931493

14941494
match self.layout.variants {
14951495
Variants::Single { index } => {
1496-
if let ty::Adt(adt, _) = &self.enum_type.kind {
1496+
if let ty::Adt(adt, _) = self.enum_type.kind() {
14971497
if adt.variants.is_empty() {
14981498
return vec![];
14991499
}
@@ -1942,7 +1942,7 @@ fn prepare_enum_metadata(
19421942
let tcx = cx.tcx;
19431943
let enum_name = compute_debuginfo_type_name(tcx, enum_type, false);
19441944
// FIXME(tmandry): This doesn't seem to have any effect.
1945-
let enum_flags = match enum_type.kind {
1945+
let enum_flags = match enum_type.kind() {
19461946
ty::Generator(..) => DIFlags::FlagArtificial,
19471947
_ => DIFlags::FlagZero,
19481948
};
@@ -1957,13 +1957,13 @@ fn prepare_enum_metadata(
19571957
let file_metadata = unknown_file_metadata(cx);
19581958

19591959
let discriminant_type_metadata = |discr: Primitive| {
1960-
let enumerators_metadata: Vec<_> = match enum_type.kind {
1960+
let enumerators_metadata: Vec<_> = match enum_type.kind() {
19611961
ty::Adt(def, _) => def
19621962
.discriminants(tcx)
19631963
.zip(&def.variants)
19641964
.map(|((_, discr), v)| {
19651965
let name = v.ident.as_str();
1966-
let is_unsigned = match discr.ty.kind {
1966+
let is_unsigned = match discr.ty.kind() {
19671967
ty::Int(_) => false,
19681968
ty::Uint(_) => true,
19691969
_ => bug!("non integer discriminant"),
@@ -2012,7 +2012,7 @@ fn prepare_enum_metadata(
20122012
type_metadata(cx, discr.to_ty(tcx), rustc_span::DUMMY_SP);
20132013

20142014
let item_name;
2015-
let discriminant_name = match enum_type.kind {
2015+
let discriminant_name = match enum_type.kind() {
20162016
ty::Adt(..) => {
20172017
item_name = tcx.item_name(enum_def_id).as_str();
20182018
&*item_name
@@ -2105,7 +2105,7 @@ fn prepare_enum_metadata(
21052105
);
21062106
}
21072107

2108-
let discriminator_name = match &enum_type.kind {
2108+
let discriminator_name = match enum_type.kind() {
21092109
ty::Generator(..) => "__state",
21102110
_ => "",
21112111
};
@@ -2328,7 +2328,7 @@ fn set_members_of_composite_type(
23282328

23292329
/// Computes the type parameters for a type, if any, for the given metadata.
23302330
fn compute_type_parameters(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>) -> Option<&'ll DIArray> {
2331-
if let ty::Adt(def, substs) = ty.kind {
2331+
if let ty::Adt(def, substs) = *ty.kind() {
23322332
if substs.types().next().is_some() {
23332333
let generics = cx.tcx.generics_of(def.did);
23342334
let names = get_parameter_names(cx, generics);

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,9 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
361361
// already inaccurate due to ABI adjustments (see #42800).
362362
signature.extend(fn_abi.args.iter().map(|arg| {
363363
let t = arg.layout.ty;
364-
let t = match t.kind {
364+
let t = match t.kind() {
365365
ty::Array(ct, _)
366-
if (ct == cx.tcx.types.u8) || cx.layout_of(ct).is_zst() =>
366+
if (*ct == cx.tcx.types.u8) || cx.layout_of(ct).is_zst() =>
367367
{
368368
cx.tcx.mk_imm_ptr(ct)
369369
}
@@ -467,7 +467,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
467467

468468
// Only "class" methods are generally understood by LLVM,
469469
// so avoid methods on other types (e.g., `<*mut T>::null`).
470-
match impl_self_ty.kind {
470+
match impl_self_ty.kind() {
471471
ty::Adt(def, ..) if !def.is_box() => {
472472
// Again, only create type information if full debuginfo is enabled
473473
if cx.sess().opts.debuginfo == DebugInfo::Full

0 commit comments

Comments
 (0)