Rollup merge of #66935 - petrochenkov:attrtok2, r=Centril
syntax: Unify macro and attribute arguments in AST The unified form (`ast::MacArgs`) represents parsed arguments instead of an unstructured token stream that was previously used for attributes. It also tracks some spans and delimiter kinds better for fn-like macros and macro definitions. I've been talking about implementing this with @nnethercote in https://github.com/rust-lang/rust/pull/65750#issuecomment-546517322. The parsed representation is closer to `MetaItem` and requires less token juggling during conversions, so it potentially may be faster. r? @Centril
This commit is contained in:
commit
cf937fa84d
40 changed files with 395 additions and 327 deletions
|
|
@ -11,9 +11,9 @@ macro_rules! foo{
|
|||
pub fn main() {
|
||||
foo!();
|
||||
|
||||
assert!({one! two()}); //~ ERROR expected open delimiter
|
||||
assert!({one! two()}); //~ ERROR expected one of `(`, `[`, or `{`, found `two`
|
||||
|
||||
// regardless of whether nested macro_rules works, the following should at
|
||||
// least throw a conventional error.
|
||||
assert!({one! two}); //~ ERROR expected open delimiter
|
||||
assert!({one! two}); //~ ERROR expected one of `(`, `[`, or `{`, found `two`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
error: expected open delimiter
|
||||
error: expected one of `(`, `[`, or `{`, found `two`
|
||||
--> $DIR/issue-10536.rs:14:19
|
||||
|
|
||||
LL | assert!({one! two()});
|
||||
| ^^^ expected open delimiter
|
||||
| ^^^ expected one of `(`, `[`, or `{`
|
||||
|
||||
error: expected open delimiter
|
||||
error: expected one of `(`, `[`, or `{`, found `two`
|
||||
--> $DIR/issue-10536.rs:18:19
|
||||
|
|
||||
LL | assert!({one! two});
|
||||
| ^^^ expected open delimiter
|
||||
| ^^^ expected one of `(`, `[`, or `{`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
foo! bar < //~ ERROR expected open delimiter
|
||||
foo! bar < //~ ERROR expected one of `(`, `[`, or `{`, found `bar`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error: expected open delimiter
|
||||
error: expected one of `(`, `[`, or `{`, found `bar`
|
||||
--> $DIR/macro-bad-delimiter-ident.rs:2:10
|
||||
|
|
||||
LL | foo! bar <
|
||||
| ^^^ expected open delimiter
|
||||
| ^^^ expected one of `(`, `[`, or `{`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ mod _test2_inner {
|
|||
//~| ERROR: non-builtin inner attributes are unstable
|
||||
}
|
||||
|
||||
#[empty_attr = "y"] //~ ERROR: must only be followed by a delimiter token
|
||||
#[empty_attr = "y"] //~ ERROR: key-value macro attributes are not supported
|
||||
fn _test3() {}
|
||||
|
||||
fn attrs() {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ LL | #![empty_attr]
|
|||
= note: for more information, see https://github.com/rust-lang/rust/issues/54727
|
||||
= help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable
|
||||
|
||||
error: custom attribute invocations must be of the form `#[foo]` or `#[foo(..)]`, the macro name must only be followed by a delimiter token
|
||||
error: key-value macro attributes are not supported
|
||||
--> $DIR/proc-macro-gates.rs:21:1
|
||||
|
|
||||
LL | #[empty_attr = "y"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue