diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-03-05 07:28:41 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-03-11 13:31:24 +1100 |
| commit | ca5525d5643f4eb7de5c5e69d0691fc8f1cacfca (patch) | |
| tree | cbe3682d3e3ff0d1a48b76f972f0322ea28c9542 /compiler/rustc_passes/src/intrinsicck.rs | |
| parent | 5f4e0677190b82e61dc507e3e72caf89da8e5e28 (diff) | |
| download | rust-ca5525d5643f4eb7de5c5e69d0691fc8f1cacfca.tar.gz rust-ca5525d5643f4eb7de5c5e69d0691fc8f1cacfca.zip | |
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`.
Diffstat (limited to 'compiler/rustc_passes/src/intrinsicck.rs')
| -rw-r--r-- | compiler/rustc_passes/src/intrinsicck.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/compiler/rustc_passes/src/intrinsicck.rs b/compiler/rustc_passes/src/intrinsicck.rs index b2129ce9f24..6316f3b8459 100644 --- a/compiler/rustc_passes/src/intrinsicck.rs +++ b/compiler/rustc_passes/src/intrinsicck.rs @@ -38,22 +38,22 @@ struct ExprVisitor<'tcx> { fn unpack_option_like<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> { let ty::Adt(def, substs) = *ty.kind() else { return ty }; - if def.variants.len() == 2 && !def.repr.c() && def.repr.int.is_none() { + if def.variants().len() == 2 && !def.repr().c() && def.repr().int.is_none() { let data_idx; let one = VariantIdx::new(1); let zero = VariantIdx::new(0); - if def.variants[zero].fields.is_empty() { + if def.variant(zero).fields.is_empty() { data_idx = one; - } else if def.variants[one].fields.is_empty() { + } else if def.variant(one).fields.is_empty() { data_idx = zero; } else { return ty; } - if def.variants[data_idx].fields.len() == 1 { - return def.variants[data_idx].fields[0].ty(tcx, substs); + if def.variant(data_idx).fields.len() == 1 { + return def.variant(data_idx).fields[0].ty(tcx, substs); } } @@ -165,7 +165,7 @@ impl<'tcx> ExprVisitor<'tcx> { ty::RawPtr(ty::TypeAndMut { ty, mutbl: _ }) if self.is_thin_ptr_ty(ty) => { Some(asm_ty_isize) } - ty::Adt(adt, substs) if adt.repr.simd() => { + 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() { |
