Return equal for two identical projections

This commit is contained in:
yukang 2023-03-21 15:27:08 +08:00
parent c90eb4825a
commit 8126ccb77d
3 changed files with 43 additions and 4 deletions

View File

@ -712,10 +712,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
unreachable!(
"we captured two identical projections: capture1 = {:?}, capture2 = {:?}",
capture1, capture2
);
// return Equal for two identical projections
std::cmp::Ordering::Equal
});
}

View 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() { }

View 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`.