about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-12-15 04:52:13 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2019-12-23 14:47:20 +0100
commit8846a6b6bb2dc9d776335fda01f68c9c1c7b94e6 (patch)
treee62b352d94402ffe1a59a8670b8d8aafe62209fe /src/test
parentc37bd26eaa350d2837dfc50412a823142405307f (diff)
downloadrust-8846a6b6bb2dc9d776335fda01f68c9c1c7b94e6.tar.gz
rust-8846a6b6bb2dc9d776335fda01f68c9c1c7b94e6.zip
Test that nested type ascription is banned.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.rs35
-rw-r--r--src/test/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.stderr34
2 files changed, 69 insertions, 0 deletions
diff --git a/src/test/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.rs b/src/test/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.rs
new file mode 100644
index 00000000000..493f1cbb470
--- /dev/null
+++ b/src/test/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.rs
@@ -0,0 +1,35 @@
+// Here we check that type ascription is syntactically invalid when
+// not in the top position of a ascribing a let binding or function parameter.
+
+#![feature(bindings_after_at)]
+//~^ WARN the feature `bindings_after_at` is incomplete
+
+// This has no effect.
+// We include it to demonstrate that this is the case:
+#![feature(type_ascription)]
+
+fn main() {}
+
+fn _ok() {
+    let _a @ _b: u8 = 0; // OK.
+    fn _f(_a @ _b: u8) {} // OK.
+}
+
+#[cfg(FALSE)]
+fn case_1() {
+    let a: u8 @ b = 0;
+    //~^ ERROR expected one of `!`
+}
+
+#[cfg(FALSE)]
+fn case_2() {
+    let a @ (b: u8);
+    //~^ ERROR expected one of `!`
+    //~| ERROR expected one of `)`
+}
+
+#[cfg(FALSE)]
+fn case_3() {
+    let a: T1 @ Outer(b: T2);
+    //~^ ERROR expected one of `!`
+}
diff --git a/src/test/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.stderr b/src/test/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.stderr
new file mode 100644
index 00000000000..cdd1574f2b6
--- /dev/null
+++ b/src/test/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.stderr
@@ -0,0 +1,34 @@
+error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found `@`
+  --> $DIR/nested-type-ascription-syntactically-invalid.rs:20:15
+   |
+LL |     let a: u8 @ b = 0;
+   |               ^ expected one of 7 possible tokens
+
+error: expected one of `)`, `,`, `@`, or `|`, found `:`
+  --> $DIR/nested-type-ascription-syntactically-invalid.rs:26:15
+   |
+LL |     let a @ (b: u8);
+   |               ^ expected one of `)`, `,`, `@`, or `|`
+
+error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found `)`
+  --> $DIR/nested-type-ascription-syntactically-invalid.rs:26:19
+   |
+LL |     let a @ (b: u8);
+   |                   ^ expected one of 7 possible tokens
+
+error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found `@`
+  --> $DIR/nested-type-ascription-syntactically-invalid.rs:33:15
+   |
+LL |     let a: T1 @ Outer(b: T2);
+   |               ^ expected one of 7 possible tokens
+
+warning: the feature `bindings_after_at` is incomplete and may cause the compiler to crash
+  --> $DIR/nested-type-ascription-syntactically-invalid.rs:4:12
+   |
+LL | #![feature(bindings_after_at)]
+   |            ^^^^^^^^^^^^^^^^^
+   |
+   = note: `#[warn(incomplete_features)]` on by default
+
+error: aborting due to 4 previous errors
+