From ca5525d5643f4eb7de5c5e69d0691fc8f1cacfca Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Sat, 5 Mar 2022 07:28:41 +1100 Subject: Improve `AdtDef` interning. This commit makes `AdtDef` use `Interned`. Much the commit is tedious changes to introduce getter functions. The interesting changes are in `compiler/rustc_middle/src/ty/adt.rs`. --- compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'compiler/rustc_codegen_ssa/src/debuginfo') diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs index 62a297937d4..67df64e9b1b 100644 --- a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs +++ b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs @@ -74,7 +74,7 @@ fn push_debuginfo_type_name<'tcx>( if def.is_enum() && cpp_like_debuginfo { msvc_enum_fallback(tcx, t, def, substs, output, visited); } else { - push_item_name(tcx, def.did, qualified, output); + push_item_name(tcx, def.did(), qualified, output); push_generic_params_internal(tcx, substs, output, visited); } } @@ -405,15 +405,15 @@ fn push_debuginfo_type_name<'tcx>( fn msvc_enum_fallback<'tcx>( tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, - def: &AdtDef, + def: AdtDef<'tcx>, substs: SubstsRef<'tcx>, output: &mut String, visited: &mut FxHashSet>, ) { - let layout = tcx.layout_of(tcx.param_env(def.did).and(ty)).expect("layout error"); + let layout = tcx.layout_of(tcx.param_env(def.did()).and(ty)).expect("layout error"); output.push_str("enum$<"); - push_item_name(tcx, def.did, true, output); + push_item_name(tcx, def.did(), true, output); push_generic_params_internal(tcx, substs, output, visited); if let Variants::Multiple { @@ -435,14 +435,14 @@ fn push_debuginfo_type_name<'tcx>( let max = dataful_discriminant_range.end; let max = tag.value.size(&tcx).truncate(max); - let dataful_variant_name = def.variants[*dataful_variant].name.as_str(); + let dataful_variant_name = def.variant(*dataful_variant).name.as_str(); output.push_str(&format!(", {}, {}, {}", min, max, dataful_variant_name)); } else if let Variants::Single { index: variant_idx } = &layout.variants { // Uninhabited enums can't be constructed and should never need to be visualized so // skip this step for them. - if def.variants.len() != 0 { - let variant = def.variants[*variant_idx].name.as_str(); + if def.variants().len() != 0 { + let variant = def.variant(*variant_idx).name.as_str(); output.push_str(&format!(", {}", variant)); } -- cgit 1.4.1-3-g733a5