Skip to content

Commit 7b4f1f7

Browse files
committed
view types: add parsing tests
1 parent 77fb8d1 commit 7b4f1f7

3 files changed

Lines changed: 103 additions & 0 deletions

File tree

tests/ui/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,11 @@ Tests on `enum` variants.
15501550

15511551
**FIXME**: Should be rehomed with `tests/ui/enum/`.
15521552

1553+
1554+
## `tests/ui/view-types`
1555+
1556+
Anything related to view types.
1557+
15531558
## `tests/ui/wasm/`
15541559

15551560
These tests target the `wasm32` architecture specifically. They are usually regression tests for WASM-specific bugs which were observed in the past.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#![feature(view_types)]
2+
#![allow(unused)]
3+
4+
struct Foo {
5+
bar: usize,
6+
baz: usize,
7+
}
8+
9+
impl Foo {
10+
fn not_a_field(&mut self.{ _ }, _: &mut Foo.{ _ }) {}
11+
//~^ ERROR expected parameter name
12+
//~| ERROR expected one of
13+
//~| ERROR expected identifier
14+
15+
fn keyword(&mut self.{ where }, _: &mut Foo.{ for }) {}
16+
//~^ ERROR expected parameter name
17+
//~| ERROR expected one of
18+
//~| ERROR expected identifier
19+
20+
fn no_comma(&mut self.{ bar baz }, _: &mut Foo.{ bar baz }) {}
21+
//~^ ERROR expected parameter name
22+
//~| ERROR expected one of
23+
//~| ERROR expected one of
24+
}
25+
26+
fn main() {}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
error: expected parameter name, found `{`
2+
--> $DIR/syntax-errors.rs:10:30
3+
|
4+
LL | fn not_a_field(&mut self.{ _ }, _: &mut Foo.{ _ }) {}
5+
| ^ expected parameter name
6+
7+
error: expected one of `)` or `,`, found `.`
8+
--> $DIR/syntax-errors.rs:10:29
9+
|
10+
LL | fn not_a_field(&mut self.{ _ }, _: &mut Foo.{ _ }) {}
11+
| ^
12+
| |
13+
| expected one of `)` or `,`
14+
| help: missing `,`
15+
16+
error: expected identifier, found reserved identifier `_`
17+
--> $DIR/syntax-errors.rs:10:51
18+
|
19+
LL | fn not_a_field(&mut self.{ _ }, _: &mut Foo.{ _ }) {}
20+
| ^ expected identifier, found reserved identifier
21+
22+
error: expected parameter name, found `{`
23+
--> $DIR/syntax-errors.rs:15:26
24+
|
25+
LL | fn keyword(&mut self.{ where }, _: &mut Foo.{ for }) {}
26+
| ^ expected parameter name
27+
28+
error: expected one of `)` or `,`, found `.`
29+
--> $DIR/syntax-errors.rs:15:25
30+
|
31+
LL | fn keyword(&mut self.{ where }, _: &mut Foo.{ for }) {}
32+
| ^
33+
| |
34+
| expected one of `)` or `,`
35+
| help: missing `,`
36+
37+
error: expected identifier, found keyword `for`
38+
--> $DIR/syntax-errors.rs:15:51
39+
|
40+
LL | fn keyword(&mut self.{ where }, _: &mut Foo.{ for }) {}
41+
| ^^^ expected identifier, found keyword
42+
|
43+
help: escape `for` to use it as an identifier
44+
|
45+
LL | fn keyword(&mut self.{ where }, _: &mut Foo.{ r#for }) {}
46+
| ++
47+
48+
error: expected parameter name, found `{`
49+
--> $DIR/syntax-errors.rs:20:27
50+
|
51+
LL | fn no_comma(&mut self.{ bar baz }, _: &mut Foo.{ bar baz }) {}
52+
| ^ expected parameter name
53+
54+
error: expected one of `)` or `,`, found `.`
55+
--> $DIR/syntax-errors.rs:20:26
56+
|
57+
LL | fn no_comma(&mut self.{ bar baz }, _: &mut Foo.{ bar baz }) {}
58+
| ^
59+
| |
60+
| expected one of `)` or `,`
61+
| help: missing `,`
62+
63+
error: expected one of `,` or `}`, found `baz`
64+
--> $DIR/syntax-errors.rs:20:58
65+
|
66+
LL | fn no_comma(&mut self.{ bar baz }, _: &mut Foo.{ bar baz }) {}
67+
| -^^^ expected one of `,` or `}`
68+
| |
69+
| help: missing `,`
70+
71+
error: aborting due to 9 previous errors
72+

0 commit comments

Comments
 (0)