Test that nested type ascription is banned.
This commit is contained in:
parent
c37bd26eaa
commit
8846a6b6bb
|
@ -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 `!`
|
||||
}
|
|
@ -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
|
||||
|
Loading…
Reference in New Issue