Skip to content

Commit acc68e9

Browse files
authored
Rollup merge of #117136 - compiler-errors:defid-list, r=oli-obk
Intern `LocalDefId` list from `opaque_types_defined_by` query r? oli-obk
2 parents 96074be + 18b7d9e commit acc68e9

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

compiler/rustc_middle/src/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ rustc_queries! {
341341

342342
query opaque_types_defined_by(
343343
key: LocalDefId
344-
) -> &'tcx [LocalDefId] {
344+
) -> &'tcx ty::List<LocalDefId> {
345345
desc {
346346
|tcx| "computing the opaque types defined by `{}`",
347347
tcx.def_path_str(key.to_def_id())

compiler/rustc_middle/src/ty/context.rs

+10
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ pub struct CtxtInterners<'tcx> {
161161
external_constraints: InternedSet<'tcx, ExternalConstraintsData<'tcx>>,
162162
predefined_opaques_in_body: InternedSet<'tcx, PredefinedOpaquesData<'tcx>>,
163163
fields: InternedSet<'tcx, List<FieldIdx>>,
164+
local_def_ids: InternedSet<'tcx, List<LocalDefId>>,
164165
}
165166

166167
impl<'tcx> CtxtInterners<'tcx> {
@@ -186,6 +187,7 @@ impl<'tcx> CtxtInterners<'tcx> {
186187
external_constraints: Default::default(),
187188
predefined_opaques_in_body: Default::default(),
188189
fields: Default::default(),
190+
local_def_ids: Default::default(),
189191
}
190192
}
191193

@@ -1572,6 +1574,7 @@ slice_interners!(
15721574
place_elems: pub mk_place_elems(PlaceElem<'tcx>),
15731575
bound_variable_kinds: pub mk_bound_variable_kinds(ty::BoundVariableKind),
15741576
fields: pub mk_fields(FieldIdx),
1577+
local_def_ids: intern_local_def_ids(LocalDefId),
15751578
);
15761579

15771580
impl<'tcx> TyCtxt<'tcx> {
@@ -1801,6 +1804,13 @@ impl<'tcx> TyCtxt<'tcx> {
18011804
self.intern_clauses(clauses)
18021805
}
18031806

1807+
pub fn mk_local_def_ids(self, clauses: &[LocalDefId]) -> &'tcx List<LocalDefId> {
1808+
// FIXME consider asking the input slice to be sorted to avoid
1809+
// re-interning permutations, in which case that would be asserted
1810+
// here.
1811+
self.intern_local_def_ids(clauses)
1812+
}
1813+
18041814
pub fn mk_const_list_from_iter<I, T>(self, iter: I) -> T::Output
18051815
where
18061816
I: Iterator<Item = T>,

compiler/rustc_ty_utils/src/opaque_types.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,10 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector<'tcx> {
264264
}
265265
}
266266

267-
fn opaque_types_defined_by<'tcx>(tcx: TyCtxt<'tcx>, item: LocalDefId) -> &'tcx [LocalDefId] {
267+
fn opaque_types_defined_by<'tcx>(
268+
tcx: TyCtxt<'tcx>,
269+
item: LocalDefId,
270+
) -> &'tcx ty::List<LocalDefId> {
268271
let kind = tcx.def_kind(item);
269272
trace!(?kind);
270273
let mut collector = OpaqueTypeCollector::new(tcx, item);
@@ -306,7 +309,7 @@ fn opaque_types_defined_by<'tcx>(tcx: TyCtxt<'tcx>, item: LocalDefId) -> &'tcx [
306309
collector.opaques.extend(tcx.opaque_types_defined_by(tcx.local_parent(item)));
307310
}
308311
}
309-
tcx.arena.alloc_from_iter(collector.opaques)
312+
tcx.mk_local_def_ids(&collector.opaques)
310313
}
311314

312315
pub(super) fn provide(providers: &mut Providers) {

0 commit comments

Comments
 (0)