do not try fetching the ancestors of errored trait impls

This commit is contained in:
Bastian Kauschke 2020-07-19 15:45:44 +02:00
parent d3df8512d2
commit 455e6140d8
3 changed files with 19 additions and 1 deletions

View file

@ -1,5 +1,6 @@
use crate::ich::{self, StableHashingContext};
use crate::ty::fast_reject::SimplifiedType;
use crate::ty::fold::TypeFoldable;
use crate::ty::{self, TyCtxt};
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
@ -226,7 +227,8 @@ pub fn ancestors(
start_from_impl: DefId,
) -> Result<Ancestors<'tcx>, ErrorReported> {
let specialization_graph = tcx.specialization_graph_of(trait_def_id);
if specialization_graph.has_errored {
if specialization_graph.has_errored || tcx.type_of(start_from_impl).references_error() {
Err(ErrorReported)
} else {
Ok(Ancestors {

View file

@ -0,0 +1,7 @@
#![feature(min_specialization)]
trait Trait {}
impl Trait for NonExistent {}
//~^ ERROR cannot find type `NonExistent` in this scope
fn main() {}

View file

@ -0,0 +1,9 @@
error[E0412]: cannot find type `NonExistent` in this scope
--> $DIR/impl-on-nonexisting.rs:4:16
|
LL | impl Trait for NonExistent {}
| ^^^^^^^^^^^ not found in this scope
error: aborting due to previous error
For more information about this error, try `rustc --explain E0412`.