Skip to content

Commit c8d8f52

Browse files
authored
Rollup merge of #66388 - estebank:melt-ice, r=Centril
Do not ICE on recovery from unmet associated type bound obligation Fix #66353. r? @Centril
2 parents 8405fc6 + b884205 commit c8d8f52

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

src/librustc_typeck/check/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -3108,7 +3108,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
31083108
fallback_has_occurred: bool,
31093109
mutate_fullfillment_errors: impl Fn(&mut Vec<traits::FulfillmentError<'tcx>>),
31103110
) {
3111-
if let Err(mut errors) = self.fulfillment_cx.borrow_mut().select_where_possible(self) {
3111+
let result = self.fulfillment_cx.borrow_mut().select_where_possible(self);
3112+
if let Err(mut errors) = result {
31123113
mutate_fullfillment_errors(&mut errors);
31133114
self.report_fulfillment_errors(&errors, self.inh.body_id, fallback_has_occurred);
31143115
}

src/test/ui/issues/issue-66353.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// #66353: ICE when trying to recover from incorrect associated type
2+
3+
trait _Func<T> {
4+
fn func(_: Self);
5+
}
6+
7+
trait _A {
8+
type AssocT;
9+
}
10+
11+
fn main() {
12+
_Func::< <() as _A>::AssocT >::func(());
13+
//~^ ERROR the trait bound `(): _A` is not satisfied
14+
//~| ERROR the trait bound `(): _Func<_>` is not satisfied
15+
}

src/test/ui/issues/issue-66353.stderr

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0277]: the trait bound `(): _A` is not satisfied
2+
--> $DIR/issue-66353.rs:12:14
3+
|
4+
LL | _Func::< <() as _A>::AssocT >::func(());
5+
| ^^^^^^^^^^^^^^^^^^ the trait `_A` is not implemented for `()`
6+
7+
error[E0277]: the trait bound `(): _Func<_>` is not satisfied
8+
--> $DIR/issue-66353.rs:12:41
9+
|
10+
LL | fn func(_: Self);
11+
| ----------------- required by `_Func::func`
12+
...
13+
LL | _Func::< <() as _A>::AssocT >::func(());
14+
| ^^ the trait `_Func<_>` is not implemented for `()`
15+
16+
error: aborting due to 2 previous errors
17+
18+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)