about summary refs log tree commit diff
path: root/src/test/ui/parser
diff options
context:
space:
mode:
authorCaio <c410.f3r@gmail.com>2022-12-11 19:43:42 -0300
committerCaio <c410.f3r@gmail.com>2022-12-11 19:43:42 -0300
commit645fac3e1d788b0d9a2fe150f185be496a0bf885 (patch)
tree786bd050f05b278b027d091fd93d665a0502d265 /src/test/ui/parser
parent657eefe2dcf18f76ac67a39945810128e101178c (diff)
Move tests
Diffstat (limited to 'src/test/ui/parser')
-rw-r--r--src/test/ui/parser/issue-39616.rs3
-rw-r--r--src/test/ui/parser/issue-39616.stderr8
-rw-r--r--src/test/ui/parser/issue-49257.rs14
-rw-r--r--src/test/ui/parser/issue-49257.stderr42
4 files changed, 67 insertions, 0 deletions
diff --git a/src/test/ui/parser/issue-39616.rs b/src/test/ui/parser/issue-39616.rs
new file mode 100644
index 00000000000..46b5aa334ca
--- /dev/null
+++ b/src/test/ui/parser/issue-39616.rs
@@ -0,0 +1,3 @@
+fn foo(a: [0; 1]) {} //~ ERROR expected type, found `0`
+
+fn main() {}
diff --git a/src/test/ui/parser/issue-39616.stderr b/src/test/ui/parser/issue-39616.stderr
new file mode 100644
index 00000000000..393d1f2e2ce
--- /dev/null
+++ b/src/test/ui/parser/issue-39616.stderr
@@ -0,0 +1,8 @@
+error: expected type, found `0`
+  --> $DIR/issue-39616.rs:1:12
+   |
+LL | fn foo(a: [0; 1]) {}
+   |            ^ expected type
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/parser/issue-49257.rs b/src/test/ui/parser/issue-49257.rs
new file mode 100644
index 00000000000..a7fa19d52fd
--- /dev/null
+++ b/src/test/ui/parser/issue-49257.rs
@@ -0,0 +1,14 @@
+// Test for #49257:
+// emits good diagnostics for `..` pattern fragments not in the last position.
+
+#![allow(unused)]
+
+struct Point { x: u8, y: u8 }
+
+fn main() {
+    let p = Point { x: 0, y: 0 };
+    let Point { .., y, } = p; //~ ERROR expected `}`, found `,`
+    let Point { .., y } = p; //~ ERROR expected `}`, found `,`
+    let Point { .., } = p; //~ ERROR expected `}`, found `,`
+    let Point { .. } = p;
+}
diff --git a/src/test/ui/parser/issue-49257.stderr b/src/test/ui/parser/issue-49257.stderr
new file mode 100644
index 00000000000..846467f7f22
--- /dev/null
+++ b/src/test/ui/parser/issue-49257.stderr
@@ -0,0 +1,42 @@
+error: expected `}`, found `,`
+  --> $DIR/issue-49257.rs:10:19
+   |
+LL |     let Point { .., y, } = p;
+   |                 --^
+   |                 | |
+   |                 | expected `}`
+   |                 `..` must be at the end and cannot have a trailing comma
+   |
+help: move the `..` to the end of the field list
+   |
+LL -     let Point { .., y, } = p;
+LL +     let Point { y, .. } = p;
+   |
+
+error: expected `}`, found `,`
+  --> $DIR/issue-49257.rs:11:19
+   |
+LL |     let Point { .., y } = p;
+   |                 --^
+   |                 | |
+   |                 | expected `}`
+   |                 `..` must be at the end and cannot have a trailing comma
+   |
+help: move the `..` to the end of the field list
+   |
+LL -     let Point { .., y } = p;
+LL +     let Point { y , .. } = p;
+   |
+
+error: expected `}`, found `,`
+  --> $DIR/issue-49257.rs:12:19
+   |
+LL |     let Point { .., } = p;
+   |                 --^
+   |                 | |
+   |                 | expected `}`
+   |                 | help: remove this comma
+   |                 `..` must be at the end and cannot have a trailing comma
+
+error: aborting due to 3 previous errors
+