Skip to content

Commit

Permalink
Rollup merge of rust-lang#66388 - estebank:melt-ice, r=Centril
Browse files Browse the repository at this point in the history
Do not ICE on recovery from unmet associated type bound obligation

Fix rust-lang#66353.

r? @Centril
  • Loading branch information
JohnTitor committed Nov 15, 2019
2 parents 2ddd3aa + b884205 commit f353022
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/librustc_typeck/check/mod.rs
Expand Up @@ -3108,7 +3108,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fallback_has_occurred: bool,
mutate_fullfillment_errors: impl Fn(&mut Vec<traits::FulfillmentError<'tcx>>),
) {
if let Err(mut errors) = self.fulfillment_cx.borrow_mut().select_where_possible(self) {
let result = self.fulfillment_cx.borrow_mut().select_where_possible(self);
if let Err(mut errors) = result {
mutate_fullfillment_errors(&mut errors);
self.report_fulfillment_errors(&errors, self.inh.body_id, fallback_has_occurred);
}
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 f353022

Please sign in to comment.