summaryrefslogtreecommitdiffstats
path: root/src/test/ui/suggestions/match-ergonomics.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/suggestions/match-ergonomics.rs')
-rw-r--r--src/test/ui/suggestions/match-ergonomics.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/test/ui/suggestions/match-ergonomics.rs b/src/test/ui/suggestions/match-ergonomics.rs
new file mode 100644
index 000000000..c4fc01469
--- /dev/null
+++ b/src/test/ui/suggestions/match-ergonomics.rs
@@ -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
+}