Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion compiler/rustc_trait_selection/src/solve/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ impl<'tcx> NormalizationFolder<'_, 'tcx> {
// keep the projection unnormalized. This is the case for projections
// with a `T: Trait` where-clause and opaque types outside of the defining
// scope.
let result = if infcx.predicate_may_hold(&obligation) {
// HACK: if alias_ty references errors, then there's a possibility that the
// normalized type may remain unconstrained. In that case, let's just bail.
// See `dont-try-normalizing-proj-with-errors.rs` in the test suite.
let result = if infcx.predicate_may_hold(&obligation) && !alias.references_error() {
self.fulfill_cx.register_predicate_obligation(infcx, obligation);
let errors = self.fulfill_cx.select_all_or_error(infcx);
if !errors.is_empty() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// compile-flags: -Ztrait-solver=next

trait Mirror {
type Assoc: ?Sized;
}

struct Wrapper<T: ?Sized>(T);
impl<T: ?Sized> Mirror for Wrapper<T> {
type Assoc = T;
}

fn mirror<W: Mirror>(_: W) -> Box<W::Assoc> { todo!() }

fn type_error() -> TypeError { todo!() }
//~^ ERROR cannot find type `TypeError` in this scope

fn main() {
let x = mirror(type_error());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0412]: cannot find type `TypeError` in this scope
--> $DIR/dont-try-normalizing-proj-with-errors.rs:14:20
|
LL | fn type_error() -> TypeError { todo!() }
| ^^^^^^^^^ not found in this scope

error: aborting due to previous error

For more information about this error, try `rustc --explain E0412`.