mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 00:34:06 +00:00
ac26b883bf
When converting something like `#![cfg_attr(cond, attr)]` into `#![attr]`, we currently duplicate the `#` token and the `!` token. But weirdly, there is also this comment: // We don't really have a good span to use for the synthesized `[]` // in `#[attr]`, so just use the span of the `#` token. Maybe that comment used to be true? But now it is false: we can duplicate the existing delimiters (and their spans and spacing), much like we do for the `#` and `!`. This commit does that, thus removing the incorrect comment, and improving the spans on `Group`s in a few proc-macro tests.
260 lines
11 KiB
Plaintext
260 lines
11 KiB
Plaintext
PRINT-ATTR INPUT (DISPLAY): impl
|
|
Foo<[u8;
|
|
{
|
|
#![rustc_dummy(cursed_inner)] #![allow(unused)] struct Inner
|
|
{ field: [u8; { #![rustc_dummy(another_cursed_inner)] 1 }] } 0
|
|
}]> { #![rustc_dummy(evaluated_attr)] fn bar() {} }
|
|
PRINT-ATTR RE-COLLECTED (DISPLAY): impl Foo <
|
|
[u8;
|
|
{
|
|
#![rustc_dummy(cursed_inner)] #![allow(unused)] struct Inner
|
|
{ field: [u8; { #![rustc_dummy(another_cursed_inner)] 1 }] } 0
|
|
}] > { #![rustc_dummy(evaluated_attr)] fn bar() {} }
|
|
PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): impl Foo <
|
|
[u8;
|
|
{
|
|
#! [rustc_dummy(cursed_inner)] #! [allow(unused)] struct Inner
|
|
{ field : [u8; { #! [rustc_dummy(another_cursed_inner)] 1 }] } 0
|
|
}] > { #! [rustc_dummy(evaluated_attr)] fn bar() {} }
|
|
PRINT-ATTR INPUT (DEBUG): TokenStream [
|
|
Ident {
|
|
ident: "impl",
|
|
span: $DIR/cfg-eval-inner.rs:18:1: 18:5 (#0),
|
|
},
|
|
Ident {
|
|
ident: "Foo",
|
|
span: $DIR/cfg-eval-inner.rs:18:6: 18:9 (#0),
|
|
},
|
|
Punct {
|
|
ch: '<',
|
|
spacing: Alone,
|
|
span: $DIR/cfg-eval-inner.rs:18:9: 18:10 (#0),
|
|
},
|
|
Group {
|
|
delimiter: Bracket,
|
|
stream: TokenStream [
|
|
Ident {
|
|
ident: "u8",
|
|
span: $DIR/cfg-eval-inner.rs:18:11: 18:13 (#0),
|
|
},
|
|
Punct {
|
|
ch: ';',
|
|
spacing: Alone,
|
|
span: $DIR/cfg-eval-inner.rs:18:13: 18:14 (#0),
|
|
},
|
|
Group {
|
|
delimiter: Brace,
|
|
stream: TokenStream [
|
|
Punct {
|
|
ch: '#',
|
|
spacing: Joint,
|
|
span: $DIR/cfg-eval-inner.rs:19:5: 19:6 (#0),
|
|
},
|
|
Punct {
|
|
ch: '!',
|
|
spacing: Alone,
|
|
span: $DIR/cfg-eval-inner.rs:19:6: 19:7 (#0),
|
|
},
|
|
Group {
|
|
delimiter: Bracket,
|
|
stream: TokenStream [
|
|
Ident {
|
|
ident: "rustc_dummy",
|
|
span: $DIR/cfg-eval-inner.rs:19:29: 19:40 (#0),
|
|
},
|
|
Group {
|
|
delimiter: Parenthesis,
|
|
stream: TokenStream [
|
|
Ident {
|
|
ident: "cursed_inner",
|
|
span: $DIR/cfg-eval-inner.rs:19:41: 19:53 (#0),
|
|
},
|
|
],
|
|
span: $DIR/cfg-eval-inner.rs:19:40: 19:54 (#0),
|
|
},
|
|
],
|
|
span: $DIR/cfg-eval-inner.rs:19:7: 19:56 (#0),
|
|
},
|
|
Punct {
|
|
ch: '#',
|
|
spacing: Joint,
|
|
span: $DIR/cfg-eval-inner.rs:20:5: 20:6 (#0),
|
|
},
|
|
Punct {
|
|
ch: '!',
|
|
spacing: Alone,
|
|
span: $DIR/cfg-eval-inner.rs:20:6: 20:7 (#0),
|
|
},
|
|
Group {
|
|
delimiter: Bracket,
|
|
stream: TokenStream [
|
|
Ident {
|
|
ident: "allow",
|
|
span: $DIR/cfg-eval-inner.rs:20:8: 20:13 (#0),
|
|
},
|
|
Group {
|
|
delimiter: Parenthesis,
|
|
stream: TokenStream [
|
|
Ident {
|
|
ident: "unused",
|
|
span: $DIR/cfg-eval-inner.rs:20:14: 20:20 (#0),
|
|
},
|
|
],
|
|
span: $DIR/cfg-eval-inner.rs:20:13: 20:21 (#0),
|
|
},
|
|
],
|
|
span: $DIR/cfg-eval-inner.rs:20:7: 20:22 (#0),
|
|
},
|
|
Ident {
|
|
ident: "struct",
|
|
span: $DIR/cfg-eval-inner.rs:21:5: 21:11 (#0),
|
|
},
|
|
Ident {
|
|
ident: "Inner",
|
|
span: $DIR/cfg-eval-inner.rs:21:12: 21:17 (#0),
|
|
},
|
|
Group {
|
|
delimiter: Brace,
|
|
stream: TokenStream [
|
|
Ident {
|
|
ident: "field",
|
|
span: $DIR/cfg-eval-inner.rs:22:9: 22:14 (#0),
|
|
},
|
|
Punct {
|
|
ch: ':',
|
|
spacing: Alone,
|
|
span: $DIR/cfg-eval-inner.rs:22:14: 22:15 (#0),
|
|
},
|
|
Group {
|
|
delimiter: Bracket,
|
|
stream: TokenStream [
|
|
Ident {
|
|
ident: "u8",
|
|
span: $DIR/cfg-eval-inner.rs:22:17: 22:19 (#0),
|
|
},
|
|
Punct {
|
|
ch: ';',
|
|
spacing: Alone,
|
|
span: $DIR/cfg-eval-inner.rs:22:19: 22:20 (#0),
|
|
},
|
|
Group {
|
|
delimiter: Brace,
|
|
stream: TokenStream [
|
|
Punct {
|
|
ch: '#',
|
|
spacing: Joint,
|
|
span: $DIR/cfg-eval-inner.rs:23:13: 23:14 (#0),
|
|
},
|
|
Punct {
|
|
ch: '!',
|
|
spacing: Alone,
|
|
span: $DIR/cfg-eval-inner.rs:23:14: 23:15 (#0),
|
|
},
|
|
Group {
|
|
delimiter: Bracket,
|
|
stream: TokenStream [
|
|
Ident {
|
|
ident: "rustc_dummy",
|
|
span: $DIR/cfg-eval-inner.rs:23:37: 23:48 (#0),
|
|
},
|
|
Group {
|
|
delimiter: Parenthesis,
|
|
stream: TokenStream [
|
|
Ident {
|
|
ident: "another_cursed_inner",
|
|
span: $DIR/cfg-eval-inner.rs:23:49: 23:69 (#0),
|
|
},
|
|
],
|
|
span: $DIR/cfg-eval-inner.rs:23:48: 23:70 (#0),
|
|
},
|
|
],
|
|
span: $DIR/cfg-eval-inner.rs:23:15: 23:72 (#0),
|
|
},
|
|
Literal {
|
|
kind: Integer,
|
|
symbol: "1",
|
|
suffix: None,
|
|
span: $DIR/cfg-eval-inner.rs:24:13: 24:14 (#0),
|
|
},
|
|
],
|
|
span: $DIR/cfg-eval-inner.rs:22:21: 25:10 (#0),
|
|
},
|
|
],
|
|
span: $DIR/cfg-eval-inner.rs:22:16: 25:11 (#0),
|
|
},
|
|
],
|
|
span: $DIR/cfg-eval-inner.rs:21:18: 26:6 (#0),
|
|
},
|
|
Literal {
|
|
kind: Integer,
|
|
symbol: "0",
|
|
suffix: None,
|
|
span: $DIR/cfg-eval-inner.rs:28:5: 28:6 (#0),
|
|
},
|
|
],
|
|
span: $DIR/cfg-eval-inner.rs:18:15: 29:2 (#0),
|
|
},
|
|
],
|
|
span: $DIR/cfg-eval-inner.rs:18:10: 29:3 (#0),
|
|
},
|
|
Punct {
|
|
ch: '>',
|
|
spacing: Alone,
|
|
span: $DIR/cfg-eval-inner.rs:29:3: 29:4 (#0),
|
|
},
|
|
Group {
|
|
delimiter: Brace,
|
|
stream: TokenStream [
|
|
Punct {
|
|
ch: '#',
|
|
spacing: Joint,
|
|
span: $DIR/cfg-eval-inner.rs:32:5: 32:6 (#0),
|
|
},
|
|
Punct {
|
|
ch: '!',
|
|
spacing: Alone,
|
|
span: $DIR/cfg-eval-inner.rs:32:6: 32:7 (#0),
|
|
},
|
|
Group {
|
|
delimiter: Bracket,
|
|
stream: TokenStream [
|
|
Ident {
|
|
ident: "rustc_dummy",
|
|
span: $DIR/cfg-eval-inner.rs:32:29: 32:40 (#0),
|
|
},
|
|
Group {
|
|
delimiter: Parenthesis,
|
|
stream: TokenStream [
|
|
Ident {
|
|
ident: "evaluated_attr",
|
|
span: $DIR/cfg-eval-inner.rs:32:41: 32:55 (#0),
|
|
},
|
|
],
|
|
span: $DIR/cfg-eval-inner.rs:32:40: 32:56 (#0),
|
|
},
|
|
],
|
|
span: $DIR/cfg-eval-inner.rs:32:7: 32:58 (#0),
|
|
},
|
|
Ident {
|
|
ident: "fn",
|
|
span: $DIR/cfg-eval-inner.rs:34:5: 34:7 (#0),
|
|
},
|
|
Ident {
|
|
ident: "bar",
|
|
span: $DIR/cfg-eval-inner.rs:34:8: 34:11 (#0),
|
|
},
|
|
Group {
|
|
delimiter: Parenthesis,
|
|
stream: TokenStream [],
|
|
span: $DIR/cfg-eval-inner.rs:34:11: 34:13 (#0),
|
|
},
|
|
Group {
|
|
delimiter: Brace,
|
|
stream: TokenStream [],
|
|
span: $DIR/cfg-eval-inner.rs:34:14: 36:6 (#0),
|
|
},
|
|
],
|
|
span: $DIR/cfg-eval-inner.rs:29:5: 37:2 (#0),
|
|
},
|
|
]
|