Skip to content

Commit c55819a

Browse files
committed
Make stability interning follow the usual pattern.
1 parent bd3cb52 commit c55819a

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

compiler/rustc_middle/src/ty/context.rs

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ pub struct CtxtInterners<'tcx> {
113113
bound_variable_kinds: InternedSet<'tcx, List<ty::BoundVariableKind>>,
114114
layout: InternedSet<'tcx, Layout>,
115115
adt_def: InternedSet<'tcx, AdtDef>,
116+
117+
/// `#[stable]` and `#[unstable]` attributes
118+
stability: InternedSet<'tcx, attr::Stability>,
119+
120+
/// `#[rustc_const_stable]` and `#[rustc_const_unstable]` attributes
121+
const_stability: InternedSet<'tcx, attr::ConstStability>,
116122
}
117123

118124
impl<'tcx> CtxtInterners<'tcx> {
@@ -134,6 +140,8 @@ impl<'tcx> CtxtInterners<'tcx> {
134140
bound_variable_kinds: Default::default(),
135141
layout: Default::default(),
136142
adt_def: Default::default(),
143+
stability: Default::default(),
144+
const_stability: Default::default(),
137145
}
138146
}
139147

@@ -1035,12 +1043,6 @@ pub struct GlobalCtxt<'tcx> {
10351043
/// Data layout specification for the current target.
10361044
pub data_layout: TargetDataLayout,
10371045

1038-
/// `#[stable]` and `#[unstable]` attributes
1039-
stability_interner: ShardedHashMap<&'tcx attr::Stability, ()>,
1040-
1041-
/// `#[rustc_const_stable]` and `#[rustc_const_unstable]` attributes
1042-
const_stability_interner: ShardedHashMap<&'tcx attr::ConstStability, ()>,
1043-
10441046
/// Stores memory for globals (statics/consts).
10451047
pub(crate) alloc_map: Lock<interpret::AllocMap<'tcx>>,
10461048

@@ -1092,16 +1094,6 @@ impl<'tcx> TyCtxt<'tcx> {
10921094
self.create_memory_alloc(alloc)
10931095
}
10941096

1095-
// FIXME(eddyb) move to `direct_interners!`.
1096-
pub fn intern_stability(self, stab: attr::Stability) -> &'tcx attr::Stability {
1097-
self.stability_interner.intern(stab, |stab| self.arena.alloc(stab))
1098-
}
1099-
1100-
// FIXME(eddyb) move to `direct_interners!`.
1101-
pub fn intern_const_stability(self, stab: attr::ConstStability) -> &'tcx attr::ConstStability {
1102-
self.const_stability_interner.intern(stab, |stab| self.arena.alloc(stab))
1103-
}
1104-
11051097
/// Returns a range of the start/end indices specified with the
11061098
/// `rustc_layout_scalar_valid_range` attribute.
11071099
// FIXME(eddyb) this is an awkward spot for this method, maybe move it?
@@ -1185,8 +1177,6 @@ impl<'tcx> TyCtxt<'tcx> {
11851177
evaluation_cache: Default::default(),
11861178
crate_name: Symbol::intern(crate_name),
11871179
data_layout,
1188-
stability_interner: Default::default(),
1189-
const_stability_interner: Default::default(),
11901180
alloc_map: Lock::new(interpret::AllocMap::new()),
11911181
output_filenames: Arc::new(output_filenames),
11921182
}
@@ -1935,11 +1925,11 @@ impl<'tcx> TyCtxt<'tcx> {
19351925

19361926
writeln!(fmt, "InternalSubsts interner: #{}", self.0.interners.substs.len())?;
19371927
writeln!(fmt, "Region interner: #{}", self.0.interners.region.len())?;
1938-
writeln!(fmt, "Stability interner: #{}", self.0.stability_interner.len())?;
1928+
writeln!(fmt, "Stability interner: #{}", self.0.interners.stability.len())?;
19391929
writeln!(
19401930
fmt,
19411931
"Const Stability interner: #{}",
1942-
self.0.const_stability_interner.len()
1932+
self.0.interners.const_stability.len()
19431933
)?;
19441934
writeln!(
19451935
fmt,
@@ -2072,6 +2062,8 @@ direct_interners! {
20722062
const_allocation: intern_const_alloc(Allocation),
20732063
layout: intern_layout(Layout),
20742064
adt_def: intern_adt_def(AdtDef),
2065+
stability: intern_stability(attr::Stability),
2066+
const_stability: intern_const_stability(attr::ConstStability),
20752067
}
20762068

20772069
macro_rules! slice_interners {

0 commit comments

Comments
 (0)