Skip to content

Commit df5a341

Browse files
committed
Add test type-mismatch-suggest-wrap-issue-145634
Signed-off-by: xizheyin <[email protected]>
1 parent 425a9c0 commit df5a341

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// We should not suggest wrapping rhs with `Some`
2+
// when the found type is an unresolved type variable
3+
//
4+
// See https://github.com/rust-lang/rust/issues/145634
5+
6+
fn main() {
7+
let foo = Some(&(1, 2));
8+
assert!(matches!(foo, &Some((1, 2)))); //~ ERROR mismatched types [E0308]
9+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/type-mismatch-suggest-wrap-issue-145634.rs:8:27
3+
|
4+
LL | assert!(matches!(foo, &Some((1, 2))));
5+
| --- ^^^^^^^^^^^^^ expected `Option<&({integer}, {integer})>`, found `&_`
6+
| |
7+
| this expression has type `Option<&({integer}, {integer})>`
8+
|
9+
= note: expected enum `Option<&({integer}, {integer})>`
10+
found reference `&_`
11+
help: try wrapping the pattern in `Some`
12+
|
13+
LL | assert!(matches!(foo, Some(&Some((1, 2)))));
14+
| +++++ +
15+
16+
error: aborting due to 1 previous error
17+
18+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)