Skip to content

Commit efc51ce

Browse files
committed
Add DefPathData::NestedStatic instead of reusing DefPathData::AnonConst
1 parent ddff387 commit efc51ce

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

compiler/rustc_const_eval/src/interpret/intern.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ use hir::def::DefKind;
1717
use rustc_ast::Mutability;
1818
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
1919
use rustc_hir as hir;
20-
use rustc_hir::definitions::DisambiguatorState;
20+
use rustc_hir::definitions::{DefPathData, DisambiguatorState};
2121
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
2222
use rustc_middle::mir::interpret::{ConstAllocation, CtfeProvenance, InterpResult};
2323
use rustc_middle::query::TyCtxtAt;
2424
use rustc_middle::span_bug;
2525
use rustc_middle::ty::layout::TyAndLayout;
2626
use rustc_span::def_id::LocalDefId;
27-
use rustc_span::sym;
2827
use tracing::{instrument, trace};
2928

3029
use super::{
@@ -108,9 +107,9 @@ fn intern_as_new_static<'tcx>(
108107
) {
109108
let feed = tcx.create_def(
110109
static_id,
111-
Some(sym::nested),
112-
DefKind::Static { safety: hir::Safety::Safe, mutability: alloc.0.mutability, nested: true },
113110
None,
111+
DefKind::Static { safety: hir::Safety::Safe, mutability: alloc.0.mutability, nested: true },
112+
Some(DefPathData::NestedStatic),
114113
disambiguator,
115114
);
116115
tcx.set_nested_alloc_id_static(alloc_id, feed.def_id());

compiler/rustc_hir/src/def.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,6 @@ impl DefKind {
273273
// but those provide their own DefPathData.
274274
DefKind::AssocTy => DefPathData::TypeNs(name.unwrap()),
275275

276-
// It's not exactly an anon const, but wrt DefPathData, there
277-
// is no difference.
278-
DefKind::Static { nested: true, .. } => DefPathData::AnonConst,
279276
DefKind::Fn
280277
| DefKind::Const
281278
| DefKind::ConstParam

compiler/rustc_hir/src/definitions.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ pub enum DefPathData {
313313
AnonAssocTy(Symbol),
314314
/// A synthetic body for a coroutine's by-move body.
315315
SyntheticCoroutineBody,
316+
/// Additional static data referred to by a static.
317+
NestedStatic,
316318
}
317319

318320
impl Definitions {
@@ -455,7 +457,8 @@ impl DefPathData {
455457
| Ctor
456458
| AnonConst
457459
| OpaqueTy
458-
| SyntheticCoroutineBody => None,
460+
| SyntheticCoroutineBody
461+
| NestedStatic => None,
459462
}
460463
}
461464

@@ -477,6 +480,7 @@ impl DefPathData {
477480
OpaqueTy => DefPathDataName::Anon { namespace: sym::opaque },
478481
AnonAssocTy(..) => DefPathDataName::Anon { namespace: sym::anon_assoc },
479482
SyntheticCoroutineBody => DefPathDataName::Anon { namespace: sym::synthetic },
483+
NestedStatic => DefPathDataName::Anon { namespace: sym::nested },
480484
}
481485
}
482486
}

compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ fn encode_ty_name(tcx: TyCtxt<'_>, def_id: DefId) -> String {
717717
hir::definitions::DefPathData::AnonConst => "k",
718718
hir::definitions::DefPathData::OpaqueTy => "i",
719719
hir::definitions::DefPathData::SyntheticCoroutineBody => "s",
720+
hir::definitions::DefPathData::NestedStatic => "n",
720721
hir::definitions::DefPathData::CrateRoot
721722
| hir::definitions::DefPathData::Use
722723
| hir::definitions::DefPathData::GlobalAsm

compiler/rustc_symbol_mangling/src/v0.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
851851
DefPathData::AnonConst => 'k',
852852
DefPathData::OpaqueTy => 'i',
853853
DefPathData::SyntheticCoroutineBody => 's',
854+
DefPathData::NestedStatic => 'n',
854855

855856
// These should never show up as `path_append` arguments.
856857
DefPathData::CrateRoot

0 commit comments

Comments
 (0)