about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-08-10 08:13:22 +0200
committerGitHub <noreply@github.com>2019-08-10 08:13:22 +0200
commit9e613c74be901b86860aa2f6987228e6328e7a18 (patch)
tree0ef9fcd21d37b54db2b07b855e8dcba28880616e /src/test
parent5ed195baaa7d8753053c13a8bb932385becf64a6 (diff)
parent75c5ad2e827a077c3738dee11d9e0dc99962f384 (diff)
downloadrust-9e613c74be901b86860aa2f6987228e6328e7a18.tar.gz
rust-9e613c74be901b86860aa2f6987228e6328e7a18.zip
Rollup merge of #63399 - estebank:vec-in-pat, r=Centril
More explicit diagnostic when using a `vec![]` in a pattern

```
error: unexpected `(` after qualified path
  --> $DIR/vec-macro-in-pattern.rs:3:14
   |
LL |         Some(vec![x]) => (),
   |              ^^^^^^^
   |              |
   |              unexpected `(` after qualified path
   |              in this macro invocation
   |              use a slice pattern here instead
   |
   = help: for more information, see https://doc.rust-lang.org/edition-guide/rust-2018/slice-patterns.html
   = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
```

Fix #61933.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/proc-macro/lifetimes.stderr2
-rw-r--r--src/test/ui/suggestions/vec-macro-in-pattern.fixed8
-rw-r--r--src/test/ui/suggestions/vec-macro-in-pattern.rs8
-rw-r--r--src/test/ui/suggestions/vec-macro-in-pattern.stderr15
-rw-r--r--src/test/ui/type/ascription/issue-47666.stderr1
5 files changed, 33 insertions, 1 deletions
diff --git a/src/test/ui/proc-macro/lifetimes.stderr b/src/test/ui/proc-macro/lifetimes.stderr
index 2356a119530..6e91201405c 100644
--- a/src/test/ui/proc-macro/lifetimes.stderr
+++ b/src/test/ui/proc-macro/lifetimes.stderr
@@ -2,7 +2,7 @@ error: expected type, found `'`
   --> $DIR/lifetimes.rs:9:10
    |
 LL | type A = single_quote_alone!();
-   |          ^^^^^^^^^^^^^^^^^^^^^
+   |          ^^^^^^^^^^^^^^^^^^^^^ this macro call doesn't expand to a type
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/suggestions/vec-macro-in-pattern.fixed b/src/test/ui/suggestions/vec-macro-in-pattern.fixed
new file mode 100644
index 00000000000..e1695d6820a
--- /dev/null
+++ b/src/test/ui/suggestions/vec-macro-in-pattern.fixed
@@ -0,0 +1,8 @@
+// run-rustfix
+fn main() {
+    // everything after `.as_ref` should be suggested
+    match Some(vec![3]).as_ref().map(|v| v.as_slice()) {
+        Some([_x]) => (), //~ ERROR unexpected `(` after qualified path
+        _ => (),
+    }
+}
diff --git a/src/test/ui/suggestions/vec-macro-in-pattern.rs b/src/test/ui/suggestions/vec-macro-in-pattern.rs
new file mode 100644
index 00000000000..4843629fbcf
--- /dev/null
+++ b/src/test/ui/suggestions/vec-macro-in-pattern.rs
@@ -0,0 +1,8 @@
+// run-rustfix
+fn main() {
+    // everything after `.as_ref` should be suggested
+    match Some(vec![3]).as_ref().map(|v| v.as_slice()) {
+        Some(vec![_x]) => (), //~ ERROR unexpected `(` after qualified path
+        _ => (),
+    }
+}
diff --git a/src/test/ui/suggestions/vec-macro-in-pattern.stderr b/src/test/ui/suggestions/vec-macro-in-pattern.stderr
new file mode 100644
index 00000000000..59ca8ebbf63
--- /dev/null
+++ b/src/test/ui/suggestions/vec-macro-in-pattern.stderr
@@ -0,0 +1,15 @@
+error: unexpected `(` after qualified path
+  --> $DIR/vec-macro-in-pattern.rs:5:14
+   |
+LL |         Some(vec![_x]) => (),
+   |              ^^^^^^^^
+   |              |
+   |              unexpected `(` after qualified path
+   |              in this macro invocation
+   |              help: use a slice pattern here instead: `[_x]`
+   |
+   = help: for more information, see https://doc.rust-lang.org/edition-guide/rust-2018/slice-patterns.html
+   = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/type/ascription/issue-47666.stderr b/src/test/ui/type/ascription/issue-47666.stderr
index 965bbe5ea41..2f052341fae 100644
--- a/src/test/ui/type/ascription/issue-47666.stderr
+++ b/src/test/ui/type/ascription/issue-47666.stderr
@@ -6,6 +6,7 @@ LL |     let _ = Option:Some(vec![0, 1]);
    |                   |     |
    |                   |     expected type
    |                   |     in this macro invocation
+   |                   |     this macro call doesn't expand to a type
    |                   help: maybe write a path separator here: `::`
    |
    = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>`