Skip to content

Commit 55c4057

Browse files
authored
Rollup merge of #74516 - lcnr:min-specialization-ice, r=matthewjasper
do not try fetching the ancestors of errored trait impls fixes #74483 While building the specialization graph, we use `tcx.all_impls` which discards impls with incorrect self types, we do however call `trait_def.ancestors` with these impls which caused an ICE as they aren't part of the specialization graph.
2 parents 3981386 + 455e614 commit 55c4057

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/librustc_middle/traits/specialization_graph.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::ich::{self, StableHashingContext};
22
use crate::ty::fast_reject::SimplifiedType;
3+
use crate::ty::fold::TypeFoldable;
34
use crate::ty::{self, TyCtxt};
45
use rustc_data_structures::fx::FxHashMap;
56
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
@@ -226,7 +227,8 @@ pub fn ancestors(
226227
start_from_impl: DefId,
227228
) -> Result<Ancestors<'tcx>, ErrorReported> {
228229
let specialization_graph = tcx.specialization_graph_of(trait_def_id);
229-
if specialization_graph.has_errored {
230+
231+
if specialization_graph.has_errored || tcx.type_of(start_from_impl).references_error() {
230232
Err(ErrorReported)
231233
} else {
232234
Ok(Ancestors {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#![feature(min_specialization)]
2+
3+
trait Trait {}
4+
impl Trait for NonExistent {}
5+
//~^ ERROR cannot find type `NonExistent` in this scope
6+
7+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0412]: cannot find type `NonExistent` in this scope
2+
--> $DIR/impl-on-nonexisting.rs:4:16
3+
|
4+
LL | impl Trait for NonExistent {}
5+
| ^^^^^^^^^^^ not found in this scope
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0412`.

0 commit comments

Comments
 (0)