]> git.lizzy.rs Git - rust.git/commitdiff
Improve `AdtDef` interning.
authorNicholas Nethercote <n.nethercote@gmail.com>
Fri, 4 Mar 2022 20:28:41 +0000 (07:28 +1100)
committerNicholas Nethercote <n.nethercote@gmail.com>
Fri, 11 Mar 2022 02:31:24 +0000 (13:31 +1100)
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`.

src/type_of.rs

index 0ada20cad2c3be3c3931a58151832a6c0d79a75b..649ffc16249a68c13a03e73977299e0ea7633b1a 100644 (file)
@@ -56,8 +56,8 @@ pub fn uncached_gcc_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, layout: TyAndLa
             if let (&ty::Adt(def, _), &Variants::Single { index }) =
                 (layout.ty.kind(), &layout.variants)
             {
-                if def.is_enum() && !def.variants.is_empty() {
-                    write!(&mut name, "::{}", def.variants[index].name).unwrap();
+                if def.is_enum() && !def.variants().is_empty() {
+                    write!(&mut name, "::{}", def.variant(index).name).unwrap();
                 }
             }
             if let (&ty::Generator(_, _, _), &Variants::Single { index }) =