mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 06:22:00 +00:00
Rollup merge of #109433 - chenyukang:yukang/fix-109188-ice, r=lcnr
Return equal for two identical projections Fixes #109188
This commit is contained in:
commit
98254c5cc7
@ -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
|
||||
});
|
||||
}
|
||||
|
||||
|
22
tests/ui/closures/issue-109188.rs
Normal file
22
tests/ui/closures/issue-109188.rs
Normal file
@ -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() { }
|
19
tests/ui/closures/issue-109188.stderr
Normal file
19
tests/ui/closures/issue-109188.stderr
Normal file
@ -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`.
|
Loading…
Reference in New Issue
Block a user