Skip to content
Permalink
Browse files

add tests

  • Loading branch information...
estebank committed Apr 30, 2019
1 parent 742b48d commit ff6867338792042b13d401d7c2c3f0aee8d04e62
Showing with 81 additions and 0 deletions.
  1. +40 −0 src/test/ui/suggestions/match-ergonomics.rs
  2. +41 −0 src/test/ui/suggestions/match-ergonomics.stderr
@@ -0,0 +1,40 @@
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 => {},
_ => {},
}
}
@@ -0,0 +1,41 @@
error[E0308]: mismatched types
--> $DIR/match-ergonomics.rs:4:10
|
LL | [&v] => {},
| ^^
| |
| expected i32, found reference
| help: you can probaly 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
|
= note: expected type `i32`
found type `&_`
help: you can rely on match ergonomics and remove the explicit borrow
|
LL | v => {},
| ^

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0308, E0529.
For more information about an error, try `rustc --explain E0308`.

0 comments on commit ff68673

Please sign in to comment.
You can’t perform that action at this time.