diff options
| author | Aaron Hill <aa1ronham@gmail.com> | 2022-01-02 22:37:05 -0500 |
|---|---|---|
| committer | Aaron Hill <aa1ronham@gmail.com> | 2022-01-11 10:16:22 -0500 |
| commit | 450ef8613ce80278b98e1b1a73448ea810322567 (patch) | |
| tree | e08cf73fb202a792894812d4e8c435940196b496 /compiler/rustc_codegen_llvm/src | |
| parent | e4b1d5841494d6eb7f4944c91a057e16b0f0a9ea (diff) | |
| download | rust-450ef8613ce80278b98e1b1a73448ea810322567.tar.gz rust-450ef8613ce80278b98e1b1a73448ea810322567.zip | |
Store a `Symbol` instead of an `Ident` in `VariantDef`/`FieldDef`
The field is also renamed from `ident` to `name. In most cases, we don't actually need the `Span`. A new `ident` method is added to `VariantDef` and `FieldDef`, which constructs the full `Ident` using `tcx.def_ident_span()`. This method is used in the cases where we actually need an `Ident`. This makes incremental compilation properly track changes to the `Span`, without all of the invalidations caused by storing a `Span` directly via an `Ident`.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs | 12 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/type_of.rs | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index 60ff18af0a9..5c02e3d0fa7 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -1300,7 +1300,7 @@ impl<'tcx> StructMemberDescriptionFactory<'tcx> { let name = if self.variant.ctor_kind == CtorKind::Fn { format!("__{}", i) } else { - f.ident.to_string() + f.name.to_string() }; let field = layout.field(cx, i); MemberDescription { @@ -1480,7 +1480,7 @@ impl<'tcx> UnionMemberDescriptionFactory<'tcx> { .map(|(i, f)| { let field = self.layout.field(cx, i); MemberDescription { - name: f.ident.to_string(), + name: f.name.to_string(), type_metadata: type_metadata(cx, field.ty, self.span), offset: Size::ZERO, size: field.size, @@ -1950,7 +1950,7 @@ enum VariantInfo<'a, 'tcx> { impl<'tcx> VariantInfo<'_, 'tcx> { fn map_struct_name<R>(&self, f: impl FnOnce(&str) -> R) -> R { match self { - VariantInfo::Adt(variant) => f(variant.ident.as_str()), + VariantInfo::Adt(variant) => f(variant.name.as_str()), VariantInfo::Generator { variant_index, .. } => { f(&GeneratorSubsts::variant_name(*variant_index)) } @@ -1959,7 +1959,7 @@ impl<'tcx> VariantInfo<'_, 'tcx> { fn variant_name(&self) -> String { match self { - VariantInfo::Adt(variant) => variant.ident.to_string(), + VariantInfo::Adt(variant) => variant.name.to_string(), VariantInfo::Generator { variant_index, .. } => { // Since GDB currently prints out the raw discriminant along // with every variant, make each variant name be just the value @@ -1973,7 +1973,7 @@ impl<'tcx> VariantInfo<'_, 'tcx> { fn field_name(&self, i: usize) -> String { let field_name = match *self { VariantInfo::Adt(variant) if variant.ctor_kind != CtorKind::Fn => { - Some(variant.fields[i].ident.name) + Some(variant.fields[i].name) } VariantInfo::Generator { generator_layout, @@ -2063,7 +2063,7 @@ fn prepare_enum_metadata<'ll, 'tcx>( let enumerators_metadata: Vec<_> = match enum_type.kind() { ty::Adt(def, _) => iter::zip(def.discriminants(tcx), &def.variants) .map(|((_, discr), v)| { - let name = v.ident.as_str(); + let name = v.name.as_str(); let is_unsigned = match discr.ty.kind() { ty::Int(_) => false, ty::Uint(_) => true, diff --git a/compiler/rustc_codegen_llvm/src/type_of.rs b/compiler/rustc_codegen_llvm/src/type_of.rs index f8c919ec2aa..81d0603bc52 100644 --- a/compiler/rustc_codegen_llvm/src/type_of.rs +++ b/compiler/rustc_codegen_llvm/src/type_of.rs @@ -49,7 +49,7 @@ fn uncached_llvm_type<'a, 'tcx>( (layout.ty.kind(), &layout.variants) { if def.is_enum() && !def.variants.is_empty() { - write!(&mut name, "::{}", def.variants[index].ident).unwrap(); + write!(&mut name, "::{}", def.variants[index].name).unwrap(); } } if let (&ty::Generator(_, _, _), &Variants::Single { index }) = |
