Do not ICE on recovery from unmet associated type bound obligation

This commit is contained in:
Esteban Küber 2019-11-13 14:28:15 -08:00
parent 695fe96517
commit bc1bd95e5a
3 changed files with 41 additions and 3 deletions

View file

@ -705,9 +705,14 @@ impl Inherited<'a, 'tcx> {
span_bug!(obligation.cause.span, "escaping bound vars in predicate {:?}",
obligation);
}
self.fulfillment_cx
.borrow_mut()
.register_predicate_obligation(self, obligation);
let _ = self.fulfillment_cx
.try_borrow_mut()
.map_err(|e| self.tcx.sess.delay_span_bug(obligation.cause.span, &format!(
"fullfillment context already borrowed: {:?} - {:?}",
e,
obligation,
)))
.map(|mut cx| cx.register_predicate_obligation(self, obligation));
}
fn register_predicates<I>(&self, obligations: I)

View file

@ -0,0 +1,15 @@
// #66353: ICE when trying to recover from incorrect associated type
trait _Func<T> {
fn func(_: Self);
}
trait _A {
type AssocT;
}
fn main() {
_Func::< <() as _A>::AssocT >::func(());
//~^ ERROR the trait bound `(): _A` is not satisfied
//~| ERROR the trait bound `(): _Func<_>` is not satisfied
}

View file

@ -0,0 +1,18 @@
error[E0277]: the trait bound `(): _A` is not satisfied
--> $DIR/issue-66353.rs:12:14
|
LL | _Func::< <() as _A>::AssocT >::func(());
| ^^^^^^^^^^^^^^^^^^ the trait `_A` is not implemented for `()`
error[E0277]: the trait bound `(): _Func<_>` is not satisfied
--> $DIR/issue-66353.rs:12:41
|
LL | fn func(_: Self);
| ----------------- required by `_Func::func`
...
LL | _Func::< <() as _A>::AssocT >::func(());
| ^^ the trait `_Func<_>` is not implemented for `()`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.