diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2019-11-15 18:36:25 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-11-15 18:36:25 +0900 |
| commit | c8d8f52b7673687d2ebca6c568262d4634998ba5 (patch) | |
| tree | 04ef62821a784ae6889a9b9fa9d8c8cb40941c41 | |
| parent | 8405fc6b70e7d48a3daf15c593f071731d314446 (diff) | |
| parent | b884205cf451463c9b0bda6e694831c1494e28d6 (diff) | |
| download | rust-c8d8f52b7673687d2ebca6c568262d4634998ba5.tar.gz rust-c8d8f52b7673687d2ebca6c568262d4634998ba5.zip | |
Rollup merge of #66388 - estebank:melt-ice, r=Centril
Do not ICE on recovery from unmet associated type bound obligation Fix #66353. r? @Centril
| -rw-r--r-- | src/librustc_typeck/check/mod.rs | 3 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-66353.rs | 15 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-66353.stderr | 18 |
3 files changed, 35 insertions, 1 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 41c8fc02662..a8418c5f349 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -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); } diff --git a/src/test/ui/issues/issue-66353.rs b/src/test/ui/issues/issue-66353.rs new file mode 100644 index 00000000000..d8abdd5206e --- /dev/null +++ b/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 +} diff --git a/src/test/ui/issues/issue-66353.stderr b/src/test/ui/issues/issue-66353.stderr new file mode 100644 index 00000000000..8fd50300ca6 --- /dev/null +++ b/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`. |
