Skip to content

Commit d722f27

Browse files
committed
Test invalid tuple field identifiers
1 parent 731601c commit d722f27

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

tests/ui/offset-of/offset-of-tuple.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#![feature(offset_of)]
2+
#![feature(builtin_syntax)]
3+
4+
fn main() {
5+
core::mem::offset_of!((u8, u8), _0); //~ ERROR no field `_0`
6+
core::mem::offset_of!((u8, u8), +1); //~ ERROR no rules expected
7+
core::mem::offset_of!((u8, u8), -1); //~ ERROR no rules expected
8+
builtin # offset_of((u8, u8), _0); //~ ERROR no field `_0`
9+
builtin # offset_of((u8, u8), +1); //~ ERROR expected identifier
10+
}
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
error: expected identifier, found `+`
2+
--> $DIR/offset-of-tuple.rs:9:35
3+
|
4+
LL | builtin # offset_of((u8, u8), +1);
5+
| ^ expected identifier
6+
7+
error: no rules expected the token `1`
8+
--> $DIR/offset-of-tuple.rs:6:38
9+
|
10+
LL | core::mem::offset_of!((u8, u8), +1);
11+
| ^ no rules expected this token in macro call
12+
|
13+
= note: while trying to match sequence start
14+
15+
error: no rules expected the token `1`
16+
--> $DIR/offset-of-tuple.rs:7:38
17+
|
18+
LL | core::mem::offset_of!((u8, u8), -1);
19+
| ^ no rules expected this token in macro call
20+
|
21+
= note: while trying to match sequence start
22+
23+
error[E0609]: no field `_0` on type `(u8, u8)`
24+
--> $DIR/offset-of-tuple.rs:5:37
25+
|
26+
LL | core::mem::offset_of!((u8, u8), _0);
27+
| ^^
28+
29+
error[E0609]: no field `_0` on type `(u8, u8)`
30+
--> $DIR/offset-of-tuple.rs:8:35
31+
|
32+
LL | builtin # offset_of((u8, u8), _0);
33+
| ^^
34+
35+
error: aborting due to 5 previous errors
36+
37+
For more information about this error, try `rustc --explain E0609`.

0 commit comments

Comments
 (0)