Skip to content

Commit

Permalink
Do not ICE on recovery from unmet associated type bound obligation
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Nov 13, 2019
1 parent 695fe96 commit bc1bd95
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/librustc_typeck/check/mod.rs
Expand Up @@ -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)
Expand Down
15 changes: 15 additions & 0 deletions src/test/ui/issues/issue-66353.rs
@@ -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
}
18 changes: 18 additions & 0 deletions src/test/ui/issues/issue-66353.stderr
@@ -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`.

0 comments on commit bc1bd95

Please sign in to comment.