Skip to content

Commit 8846a6b

Browse files
committed
Test that nested type ascription is banned.
1 parent c37bd26 commit 8846a6b

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Here we check that type ascription is syntactically invalid when
2+
// not in the top position of a ascribing a let binding or function parameter.
3+
4+
#![feature(bindings_after_at)]
5+
//~^ WARN the feature `bindings_after_at` is incomplete
6+
7+
// This has no effect.
8+
// We include it to demonstrate that this is the case:
9+
#![feature(type_ascription)]
10+
11+
fn main() {}
12+
13+
fn _ok() {
14+
let _a @ _b: u8 = 0; // OK.
15+
fn _f(_a @ _b: u8) {} // OK.
16+
}
17+
18+
#[cfg(FALSE)]
19+
fn case_1() {
20+
let a: u8 @ b = 0;
21+
//~^ ERROR expected one of `!`
22+
}
23+
24+
#[cfg(FALSE)]
25+
fn case_2() {
26+
let a @ (b: u8);
27+
//~^ ERROR expected one of `!`
28+
//~| ERROR expected one of `)`
29+
}
30+
31+
#[cfg(FALSE)]
32+
fn case_3() {
33+
let a: T1 @ Outer(b: T2);
34+
//~^ ERROR expected one of `!`
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found `@`
2+
--> $DIR/nested-type-ascription-syntactically-invalid.rs:20:15
3+
|
4+
LL | let a: u8 @ b = 0;
5+
| ^ expected one of 7 possible tokens
6+
7+
error: expected one of `)`, `,`, `@`, or `|`, found `:`
8+
--> $DIR/nested-type-ascription-syntactically-invalid.rs:26:15
9+
|
10+
LL | let a @ (b: u8);
11+
| ^ expected one of `)`, `,`, `@`, or `|`
12+
13+
error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found `)`
14+
--> $DIR/nested-type-ascription-syntactically-invalid.rs:26:19
15+
|
16+
LL | let a @ (b: u8);
17+
| ^ expected one of 7 possible tokens
18+
19+
error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found `@`
20+
--> $DIR/nested-type-ascription-syntactically-invalid.rs:33:15
21+
|
22+
LL | let a: T1 @ Outer(b: T2);
23+
| ^ expected one of 7 possible tokens
24+
25+
warning: the feature `bindings_after_at` is incomplete and may cause the compiler to crash
26+
--> $DIR/nested-type-ascription-syntactically-invalid.rs:4:12
27+
|
28+
LL | #![feature(bindings_after_at)]
29+
| ^^^^^^^^^^^^^^^^^
30+
|
31+
= note: `#[warn(incomplete_features)]` on by default
32+
33+
error: aborting due to 4 previous errors
34+

0 commit comments

Comments
 (0)