Skip to content

Commit

Permalink
Test invalid tuple field identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
clubby789 committed Jun 2, 2023
1 parent 731601c commit d722f27
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/ui/offset-of/offset-of-tuple.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#![feature(offset_of)]
#![feature(builtin_syntax)]

fn main() {
core::mem::offset_of!((u8, u8), _0); //~ ERROR no field `_0`
core::mem::offset_of!((u8, u8), +1); //~ ERROR no rules expected
core::mem::offset_of!((u8, u8), -1); //~ ERROR no rules expected
builtin # offset_of((u8, u8), _0); //~ ERROR no field `_0`
builtin # offset_of((u8, u8), +1); //~ ERROR expected identifier
}
37 changes: 37 additions & 0 deletions tests/ui/offset-of/offset-of-tuple.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
error: expected identifier, found `+`
--> $DIR/offset-of-tuple.rs:9:35
|
LL | builtin # offset_of((u8, u8), +1);
| ^ expected identifier

error: no rules expected the token `1`
--> $DIR/offset-of-tuple.rs:6:38
|
LL | core::mem::offset_of!((u8, u8), +1);
| ^ no rules expected this token in macro call
|
= note: while trying to match sequence start

error: no rules expected the token `1`
--> $DIR/offset-of-tuple.rs:7:38
|
LL | core::mem::offset_of!((u8, u8), -1);
| ^ no rules expected this token in macro call
|
= note: while trying to match sequence start

error[E0609]: no field `_0` on type `(u8, u8)`
--> $DIR/offset-of-tuple.rs:5:37
|
LL | core::mem::offset_of!((u8, u8), _0);
| ^^

error[E0609]: no field `_0` on type `(u8, u8)`
--> $DIR/offset-of-tuple.rs:8:35
|
LL | builtin # offset_of((u8, u8), _0);
| ^^

error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0609`.

0 comments on commit d722f27

Please sign in to comment.