From 8846a6b6bb2dc9d776335fda01f68c9c1c7b94e6 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sun, 15 Dec 2019 04:52:13 +0100 Subject: Test that nested type ascription is banned. --- ...nested-type-ascription-syntactically-invalid.rs | 35 ++++++++++++++++++++++ ...ed-type-ascription-syntactically-invalid.stderr | 34 +++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 src/test/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.rs create mode 100644 src/test/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.stderr (limited to 'src/test/ui/pattern') 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 + -- cgit 1.4.1-3-g733a5