Skip to content

Commit 571f945

Browse files
Ensure RPITITs are created before def-id freezing
1 parent fd27e87 commit 571f945

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

compiler/rustc_hir_analysis/src/collect.rs

+2
Original file line numberDiff line numberDiff line change
@@ -595,12 +595,14 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) {
595595
tcx.ensure().type_of(def_id);
596596
tcx.ensure().impl_trait_header(def_id);
597597
tcx.ensure().predicates_of(def_id);
598+
tcx.ensure().associated_items(def_id);
598599
}
599600
hir::ItemKind::Trait(..) => {
600601
tcx.ensure().generics_of(def_id);
601602
tcx.ensure().trait_def(def_id);
602603
tcx.at(it.span).super_predicates_of(def_id);
603604
tcx.ensure().predicates_of(def_id);
605+
tcx.ensure().associated_items(def_id);
604606
}
605607
hir::ItemKind::TraitAlias(..) => {
606608
tcx.ensure().generics_of(def_id);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
trait Iterable {
2+
type Item;
3+
fn iter(&self) -> impl Sized;
4+
}
5+
6+
// `ty::Error` in a trait ref will silence any missing item errors, but will also
7+
// prevent the `associated_items` query from being called before def ids are frozen.
8+
impl Iterable for Missing {
9+
//~^ ERROR cannot find type `Missing` in this scope
10+
fn iter(&self) -> Self::Item {}
11+
}
12+
13+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0412]: cannot find type `Missing` in this scope
2+
--> $DIR/ensure-rpitits-are-created-before-freezing.rs:8:19
3+
|
4+
LL | impl Iterable for Missing {
5+
| ^^^^^^^ not found in this scope
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0412`.

0 commit comments

Comments
 (0)