diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-03-24 07:13:04 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-24 07:13:04 +0100 |
| commit | 98254c5cc7828370eeec18e2646d70846a826b5a (patch) | |
| tree | 3dda71277fea5895e92901be76f4ec3813ebc287 | |
| parent | 936377a0aabd4e383e619aaff51a01cdffc154d0 (diff) | |
| parent | 7bffe945af456df6ad3294bdf82a67d727880adc (diff) | |
| download | rust-98254c5cc7828370eeec18e2646d70846a826b5a.tar.gz rust-98254c5cc7828370eeec18e2646d70846a826b5a.zip | |
Rollup merge of #109433 - chenyukang:yukang/fix-109188-ice, r=lcnr
Return equal for two identical projections Fixes #109188
| -rw-r--r-- | compiler/rustc_hir_typeck/src/upvar.rs | 10 | ||||
| -rw-r--r-- | tests/ui/closures/issue-109188.rs | 22 | ||||
| -rw-r--r-- | tests/ui/closures/issue-109188.stderr | 19 |
3 files changed, 48 insertions, 3 deletions
diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs index d5d260d7138..eadc30a799b 100644 --- a/compiler/rustc_hir_typeck/src/upvar.rs +++ b/compiler/rustc_hir_typeck/src/upvar.rs @@ -712,10 +712,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - unreachable!( - "we captured two identical projections: capture1 = {:?}, capture2 = {:?}", - capture1, capture2 + self.tcx.sess.delay_span_bug( + closure_span, + &format!( + "two identical projections: ({:?}, {:?})", + capture1.place.projections, capture2.place.projections + ), ); + std::cmp::Ordering::Equal }); } diff --git a/tests/ui/closures/issue-109188.rs b/tests/ui/closures/issue-109188.rs new file mode 100644 index 00000000000..cae1ced9958 --- /dev/null +++ b/tests/ui/closures/issue-109188.rs @@ -0,0 +1,22 @@ +enum Either { + One(X), + Two(X), +} + +struct X(Y); + +struct Y; + +fn consume_fnmut(f: &dyn FnMut()) { + f(); +} + +fn move_into_fnmut() { + let x = move_into_fnmut(); + consume_fnmut(&|| { + let Either::One(_t) = x; //~ ERROR mismatched types + let Either::Two(_t) = x; //~ ERROR mismatched types + }); +} + +fn main() { } diff --git a/tests/ui/closures/issue-109188.stderr b/tests/ui/closures/issue-109188.stderr new file mode 100644 index 00000000000..d52b516294f --- /dev/null +++ b/tests/ui/closures/issue-109188.stderr @@ -0,0 +1,19 @@ +error[E0308]: mismatched types + --> $DIR/issue-109188.rs:17:13 + | +LL | let Either::One(_t) = x; + | ^^^^^^^^^^^^^^^ - this expression has type `()` + | | + | expected `()`, found `Either` + +error[E0308]: mismatched types + --> $DIR/issue-109188.rs:18:13 + | +LL | let Either::Two(_t) = x; + | ^^^^^^^^^^^^^^^ - this expression has type `()` + | | + | expected `()`, found `Either` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. |
