expand: Preserve order of inert attributes during expansion
This commit is contained in:
parent
c02d21033d
commit
fc9d578bc5
5 changed files with 75 additions and 77 deletions
|
|
@ -6,8 +6,7 @@
|
|||
extern crate test_macros;
|
||||
|
||||
#[derive(Empty)] //~ ERROR cannot determine resolution for the attribute macro `derive`
|
||||
#[empty_helper] //~ WARN derive helper attribute is used before it is introduced
|
||||
//~| WARN this was previously accepted
|
||||
#[empty_helper] //~ ERROR cannot find attribute `empty_helper` in this scope
|
||||
struct Foo {}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -12,17 +12,11 @@ LL | #[derive(Empty)]
|
|||
|
|
||||
= note: import resolution is stuck, try simplifying macro imports
|
||||
|
||||
warning: derive helper attribute is used before it is introduced
|
||||
error: cannot find attribute `empty_helper` in this scope
|
||||
--> $DIR/derive-helper-legacy-spurious.rs:9:3
|
||||
|
|
||||
LL | #[derive(Empty)]
|
||||
| ----- the attribute is introduced here
|
||||
LL | #[empty_helper]
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(legacy_derive_helpers)]` on by default
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202>
|
||||
|
||||
error: aborting due to 2 previous errors; 1 warning emitted
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
PRINT-ATTR INPUT (DISPLAY): /// 1
|
||||
#[doc = "3"] #[doc = "4"] #[rustfmt :: attr5] /// 6
|
||||
#[print_attr(nodebug)] #[rustfmt :: attr2] struct S ;
|
||||
PRINT-ATTR RE-COLLECTED (DISPLAY): #[doc = " 1"] #[doc = "3"] #[doc = "4"] #[rustfmt :: attr5] #[doc = " 6"]
|
||||
#[print_attr(nodebug)] #[rustfmt :: attr2] struct S ;
|
||||
PRINT-ATTR INPUT (DISPLAY): #[doc = " 1"] #[doc = "3"] #[doc = "4"] #[doc = " 6"] #[rustfmt :: attr2]
|
||||
#[rustfmt :: attr5] struct S ;
|
||||
#[rustfmt :: attr2] #[doc = "3"] #[doc = "4"] #[rustfmt :: attr5] /// 6
|
||||
#[print_attr(nodebug)] struct S ;
|
||||
PRINT-ATTR RE-COLLECTED (DISPLAY): #[doc = " 1"] #[rustfmt :: attr2] #[doc = "3"] #[doc = "4"]
|
||||
#[rustfmt :: attr5] #[doc = " 6"] #[print_attr(nodebug)] struct S ;
|
||||
PRINT-ATTR INPUT (DISPLAY): #[doc = " 1"] #[rustfmt :: attr2] #[doc = "3"] #[doc = "4"]
|
||||
#[rustfmt :: attr5] #[doc = " 6"] struct S ;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
PRINT-ATTR INPUT (DISPLAY): #[allow(dead_code)] #[derive(Print)] #[print_helper(b)] #[print_helper(a)]
|
||||
PRINT-ATTR INPUT (DISPLAY): #[print_helper(a)] #[allow(dead_code)] #[derive(Print)] #[print_helper(b)]
|
||||
struct Foo < #[cfg(FALSE)] A, B >
|
||||
{
|
||||
#[cfg(FALSE)] first : String, #[cfg_attr(FALSE, deny(warnings))] second :
|
||||
|
|
@ -23,6 +23,31 @@ struct Foo < #[cfg(FALSE)] A, B >
|
|||
}], #[print_helper(d)] fourth : B
|
||||
}
|
||||
PRINT-ATTR INPUT (DEBUG): TokenStream [
|
||||
Punct {
|
||||
ch: '#',
|
||||
spacing: Alone,
|
||||
span: $DIR/issue-75930-derive-cfg.rs:16:1: 16:2 (#0),
|
||||
},
|
||||
Group {
|
||||
delimiter: Bracket,
|
||||
stream: TokenStream [
|
||||
Ident {
|
||||
ident: "print_helper",
|
||||
span: $DIR/issue-75930-derive-cfg.rs:16:3: 16:15 (#0),
|
||||
},
|
||||
Group {
|
||||
delimiter: Parenthesis,
|
||||
stream: TokenStream [
|
||||
Ident {
|
||||
ident: "a",
|
||||
span: $DIR/issue-75930-derive-cfg.rs:16:16: 16:17 (#0),
|
||||
},
|
||||
],
|
||||
span: $DIR/issue-75930-derive-cfg.rs:16:15: 16:18 (#0),
|
||||
},
|
||||
],
|
||||
span: $DIR/issue-75930-derive-cfg.rs:16:2: 16:19 (#0),
|
||||
},
|
||||
Punct {
|
||||
ch: '#',
|
||||
spacing: Alone,
|
||||
|
|
@ -98,31 +123,6 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
|
|||
],
|
||||
span: $DIR/issue-75930-derive-cfg.rs:21:2: 21:19 (#0),
|
||||
},
|
||||
Punct {
|
||||
ch: '#',
|
||||
spacing: Alone,
|
||||
span: $DIR/issue-75930-derive-cfg.rs:16:1: 16:2 (#0),
|
||||
},
|
||||
Group {
|
||||
delimiter: Bracket,
|
||||
stream: TokenStream [
|
||||
Ident {
|
||||
ident: "print_helper",
|
||||
span: $DIR/issue-75930-derive-cfg.rs:16:3: 16:15 (#0),
|
||||
},
|
||||
Group {
|
||||
delimiter: Parenthesis,
|
||||
stream: TokenStream [
|
||||
Ident {
|
||||
ident: "a",
|
||||
span: $DIR/issue-75930-derive-cfg.rs:16:16: 16:17 (#0),
|
||||
},
|
||||
],
|
||||
span: $DIR/issue-75930-derive-cfg.rs:16:15: 16:18 (#0),
|
||||
},
|
||||
],
|
||||
span: $DIR/issue-75930-derive-cfg.rs:16:2: 16:19 (#0),
|
||||
},
|
||||
Ident {
|
||||
ident: "struct",
|
||||
span: $DIR/issue-75930-derive-cfg.rs:22:1: 22:7 (#0),
|
||||
|
|
@ -1194,7 +1194,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
|
|||
span: $DIR/issue-75930-derive-cfg.rs:22:32: 65:2 (#0),
|
||||
},
|
||||
]
|
||||
PRINT-DERIVE INPUT (DISPLAY): #[allow(dead_code)] #[print_helper(b)] #[print_helper(a)] struct Foo < B >
|
||||
PRINT-DERIVE INPUT (DISPLAY): #[print_helper(a)] #[allow(dead_code)] #[print_helper(b)] struct Foo < B >
|
||||
{
|
||||
second : bool, third :
|
||||
[u8 ;
|
||||
|
|
@ -1208,6 +1208,31 @@ PRINT-DERIVE INPUT (DISPLAY): #[allow(dead_code)] #[print_helper(b)] #[print_hel
|
|||
}], #[print_helper(d)] fourth : B,
|
||||
}
|
||||
PRINT-DERIVE INPUT (DEBUG): TokenStream [
|
||||
Punct {
|
||||
ch: '#',
|
||||
spacing: Alone,
|
||||
span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0),
|
||||
},
|
||||
Group {
|
||||
delimiter: Bracket,
|
||||
stream: TokenStream [
|
||||
Ident {
|
||||
ident: "print_helper",
|
||||
span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0),
|
||||
},
|
||||
Group {
|
||||
delimiter: Parenthesis,
|
||||
stream: TokenStream [
|
||||
Ident {
|
||||
ident: "a",
|
||||
span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0),
|
||||
},
|
||||
],
|
||||
span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0),
|
||||
},
|
||||
],
|
||||
span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0),
|
||||
},
|
||||
Punct {
|
||||
ch: '#',
|
||||
spacing: Alone,
|
||||
|
|
@ -1258,31 +1283,6 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [
|
|||
],
|
||||
span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0),
|
||||
},
|
||||
Punct {
|
||||
ch: '#',
|
||||
spacing: Alone,
|
||||
span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0),
|
||||
},
|
||||
Group {
|
||||
delimiter: Bracket,
|
||||
stream: TokenStream [
|
||||
Ident {
|
||||
ident: "print_helper",
|
||||
span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0),
|
||||
},
|
||||
Group {
|
||||
delimiter: Parenthesis,
|
||||
stream: TokenStream [
|
||||
Ident {
|
||||
ident: "a",
|
||||
span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0),
|
||||
},
|
||||
],
|
||||
span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0),
|
||||
},
|
||||
],
|
||||
span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0),
|
||||
},
|
||||
Ident {
|
||||
ident: "struct",
|
||||
span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue