Skip to content

Commit b95e51b

Browse files
committed
Auto merge of #117136 - compiler-errors:defid-list, r=<try>
Intern `LocalDefId` list from `opaque_types_defined_by` query r? oli-obk
2 parents 07a4b7e + 18b7d9e commit b95e51b

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
@@ -148,6 +148,7 @@ pub struct CtxtInterners<'tcx> {
148148
external_constraints: InternedSet<'tcx, ExternalConstraintsData<'tcx>>,
149149
predefined_opaques_in_body: InternedSet<'tcx, PredefinedOpaquesData<'tcx>>,
150150
fields: InternedSet<'tcx, List<FieldIdx>>,
151+
local_def_ids: InternedSet<'tcx, List<LocalDefId>>,
151152
}
152153

153154
impl<'tcx> CtxtInterners<'tcx> {
@@ -173,6 +174,7 @@ impl<'tcx> CtxtInterners<'tcx> {
173174
external_constraints: Default::default(),
174175
predefined_opaques_in_body: Default::default(),
175176
fields: Default::default(),
177+
local_def_ids: Default::default(),
176178
}
177179
}
178180

@@ -1559,6 +1561,7 @@ slice_interners!(
15591561
place_elems: pub mk_place_elems(PlaceElem<'tcx>),
15601562
bound_variable_kinds: pub mk_bound_variable_kinds(ty::BoundVariableKind),
15611563
fields: pub mk_fields(FieldIdx),
1564+
local_def_ids: intern_local_def_ids(LocalDefId),
15621565
);
15631566

15641567
impl<'tcx> TyCtxt<'tcx> {
@@ -1788,6 +1791,13 @@ impl<'tcx> TyCtxt<'tcx> {
17881791
self.intern_clauses(clauses)
17891792
}
17901793

1794+
pub fn mk_local_def_ids(self, clauses: &[LocalDefId]) -> &'tcx List<LocalDefId> {
1795+
// FIXME consider asking the input slice to be sorted to avoid
1796+
// re-interning permutations, in which case that would be asserted
1797+
// here.
1798+
self.intern_local_def_ids(clauses)
1799+
}
1800+
17911801
pub fn mk_const_list_from_iter<I, T>(self, iter: I) -> T::Output
17921802
where
17931803
I: Iterator<Item = T>,

compiler/rustc_ty_utils/src/opaque_types.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,10 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector<'tcx> {
269269
}
270270
}
271271

272-
fn opaque_types_defined_by<'tcx>(tcx: TyCtxt<'tcx>, item: LocalDefId) -> &'tcx [LocalDefId] {
272+
fn opaque_types_defined_by<'tcx>(
273+
tcx: TyCtxt<'tcx>,
274+
item: LocalDefId,
275+
) -> &'tcx ty::List<LocalDefId> {
273276
let kind = tcx.def_kind(item);
274277
trace!(?kind);
275278
let mut collector = OpaqueTypeCollector::new(tcx, item);
@@ -327,7 +330,7 @@ fn opaque_types_defined_by<'tcx>(tcx: TyCtxt<'tcx>, item: LocalDefId) -> &'tcx [
327330
return tcx.opaque_types_defined_by(tcx.local_parent(item));
328331
}
329332
}
330-
tcx.arena.alloc_from_iter(collector.opaques)
333+
tcx.mk_local_def_ids(&collector.opaques)
331334
}
332335

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

0 commit comments

Comments
 (0)