forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#60393 - estebank:pat-sugg, r=oli-obk
Do not suggest incorrect syntax on pattern type error due to borrow Fix rust-lang#55174.
- Loading branch information
Showing
5 changed files
with
151 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
fn main() { | ||
let x = vec![1i32]; | ||
match &x[..] { | ||
[&v] => {}, //~ ERROR mismatched types | ||
_ => {}, | ||
} | ||
match x { | ||
[&v] => {}, //~ ERROR expected an array or slice | ||
_ => {}, | ||
} | ||
match &x[..] { | ||
[v] => {}, | ||
_ => {}, | ||
} | ||
match &x[..] { | ||
&[v] => {}, | ||
_ => {}, | ||
} | ||
match x { | ||
[v] => {}, //~ ERROR expected an array or slice | ||
_ => {}, | ||
} | ||
let y = 1i32; | ||
match &y { | ||
&v => {}, | ||
_ => {}, | ||
} | ||
match y { | ||
&v => {}, //~ ERROR mismatched types | ||
_ => {}, | ||
} | ||
match &y { | ||
v => {}, | ||
_ => {}, | ||
} | ||
match y { | ||
v => {}, | ||
_ => {}, | ||
} | ||
if let [&v] = &x[..] {} //~ ERROR mismatched types | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/match-ergonomics.rs:4:10 | ||
| | ||
LL | [&v] => {}, | ||
| ^^ | ||
| | | ||
| expected i32, found reference | ||
| help: you can probably remove the explicit borrow: `v` | ||
| | ||
= note: expected type `i32` | ||
found type `&_` | ||
|
||
error[E0529]: expected an array or slice, found `std::vec::Vec<i32>` | ||
--> $DIR/match-ergonomics.rs:8:9 | ||
| | ||
LL | [&v] => {}, | ||
| ^^^^ pattern cannot match with input type `std::vec::Vec<i32>` | ||
|
||
error[E0529]: expected an array or slice, found `std::vec::Vec<i32>` | ||
--> $DIR/match-ergonomics.rs:20:9 | ||
| | ||
LL | [v] => {}, | ||
| ^^^ pattern cannot match with input type `std::vec::Vec<i32>` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/match-ergonomics.rs:29:9 | ||
| | ||
LL | &v => {}, | ||
| ^^ | ||
| | | ||
| expected i32, found reference | ||
| help: you can probably remove the explicit borrow: `v` | ||
| | ||
= note: expected type `i32` | ||
found type `&_` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/match-ergonomics.rs:40:13 | ||
| | ||
LL | if let [&v] = &x[..] {} | ||
| ^^ | ||
| | | ||
| expected i32, found reference | ||
| help: you can probably remove the explicit borrow: `v` | ||
| | ||
= note: expected type `i32` | ||
found type `&_` | ||
|
||
error: aborting due to 5 previous errors | ||
|
||
Some errors have detailed explanations: E0308, E0529. | ||
For more information about an error, try `rustc --explain E0308`. |