Move special treatment of derive(Copy, PartialEq, Eq) from expansion infrastructure to elsewhere

This commit is contained in:
Vadim Petrochenkov 2019-08-03 04:22:44 +03:00
parent a457433456
commit 2a9b75281b
17 changed files with 167 additions and 108 deletions

View file

@ -124,40 +124,40 @@ PRINT-BANG INPUT (DISPLAY): struct M ($crate :: S) ;
PRINT-BANG INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
span: #10 bytes(LO..HI),
span: #9 bytes(LO..HI),
},
Ident {
ident: "M",
span: #10 bytes(LO..HI),
span: #9 bytes(LO..HI),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "$crate",
span: #10 bytes(LO..HI),
span: #9 bytes(LO..HI),
},
Punct {
ch: ':',
spacing: Joint,
span: #10 bytes(LO..HI),
span: #9 bytes(LO..HI),
},
Punct {
ch: ':',
spacing: Alone,
span: #10 bytes(LO..HI),
span: #9 bytes(LO..HI),
},
Ident {
ident: "S",
span: #10 bytes(LO..HI),
span: #9 bytes(LO..HI),
},
],
span: #10 bytes(LO..HI),
span: #9 bytes(LO..HI),
},
Punct {
ch: ';',
spacing: Alone,
span: #10 bytes(LO..HI),
span: #9 bytes(LO..HI),
},
]
PRINT-ATTR INPUT (DISPLAY): struct A(::dollar_crate_external::S);
@ -165,40 +165,40 @@ PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ($crate :: S) ;
PRINT-ATTR INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
span: #10 bytes(LO..HI),
span: #9 bytes(LO..HI),
},
Ident {
ident: "A",
span: #10 bytes(LO..HI),
span: #9 bytes(LO..HI),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "$crate",
span: #10 bytes(LO..HI),
span: #9 bytes(LO..HI),
},
Punct {
ch: ':',
spacing: Joint,
span: #10 bytes(LO..HI),
span: #9 bytes(LO..HI),
},
Punct {
ch: ':',
spacing: Alone,
span: #10 bytes(LO..HI),
span: #9 bytes(LO..HI),
},
Ident {
ident: "S",
span: #10 bytes(LO..HI),
span: #9 bytes(LO..HI),
},
],
span: #10 bytes(LO..HI),
span: #9 bytes(LO..HI),
},
Punct {
ch: ';',
spacing: Alone,
span: #10 bytes(LO..HI),
span: #9 bytes(LO..HI),
},
]
PRINT-DERIVE INPUT (DISPLAY): struct D(::dollar_crate_external::S);
@ -206,39 +206,39 @@ PRINT-DERIVE RE-COLLECTED (DISPLAY): struct D ($crate :: S) ;
PRINT-DERIVE INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
span: #10 bytes(LO..HI),
span: #9 bytes(LO..HI),
},
Ident {
ident: "D",
span: #10 bytes(LO..HI),
span: #9 bytes(LO..HI),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "$crate",
span: #10 bytes(LO..HI),
span: #9 bytes(LO..HI),
},
Punct {
ch: ':',
spacing: Joint,
span: #10 bytes(LO..HI),
span: #9 bytes(LO..HI),
},
Punct {
ch: ':',
spacing: Alone,
span: #10 bytes(LO..HI),
span: #9 bytes(LO..HI),
},
Ident {
ident: "S",
span: #10 bytes(LO..HI),
span: #9 bytes(LO..HI),
},
],
span: #10 bytes(LO..HI),
span: #9 bytes(LO..HI),
},
Punct {
ch: ';',
spacing: Alone,
span: #10 bytes(LO..HI),
span: #9 bytes(LO..HI),
},
]

View file

@ -46,18 +46,6 @@ error: expected attribute, found derive macro `MyTrait`
LL | #[MyTrait]
| ^^^^^^^ not an attribute
error: can't use a procedural macro from the same crate that defines it
--> $DIR/macro-namespace-reserved-2.rs:49:10
|
LL | #[derive(crate::my_macro)]
| ^^^^^^^^^^^^^^^
error: expected derive macro, found macro `crate::my_macro`
--> $DIR/macro-namespace-reserved-2.rs:49:10
|
LL | #[derive(crate::my_macro)]
| ^^^^^^^^^^^^^^^ not a derive macro
error: can't use a procedural macro from the same crate that defines it
--> $DIR/macro-namespace-reserved-2.rs:52:10
|
@ -88,6 +76,18 @@ error: expected attribute, found macro `crate::my_macro`
LL | #[crate::my_macro]
| ^^^^^^^^^^^^^^^ not an attribute
error: can't use a procedural macro from the same crate that defines it
--> $DIR/macro-namespace-reserved-2.rs:49:10
|
LL | #[derive(crate::my_macro)]
| ^^^^^^^^^^^^^^^
error: expected derive macro, found macro `crate::my_macro`
--> $DIR/macro-namespace-reserved-2.rs:49:10
|
LL | #[derive(crate::my_macro)]
| ^^^^^^^^^^^^^^^ not a derive macro
error: cannot find attribute macro `my_macro` in this scope
--> $DIR/macro-namespace-reserved-2.rs:38:3
|

View file

@ -2,6 +2,9 @@
#![derive(Debug, PartialEq, Eq)] // should be an outer attribute!
//~^ ERROR `derive` may only be applied to structs, enums and unions
//~| ERROR cannot determine resolution for the derive macro `Debug`
//~| ERROR cannot determine resolution for the derive macro `PartialEq`
//~| ERROR cannot determine resolution for the derive macro `Eq`
struct DerivedOn;
fn main() {}

View file

@ -4,5 +4,29 @@ error: `derive` may only be applied to structs, enums and unions
LL | #![derive(Debug, PartialEq, Eq)] // should be an outer attribute!
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try an outer attribute: `#[derive(Debug, PartialEq, Eq)]`
error: aborting due to previous error
error: cannot determine resolution for the derive macro `Debug`
--> $DIR/issue-43927-non-ADT-derive.rs:3:11
|
LL | #![derive(Debug, PartialEq, Eq)] // should be an outer attribute!
| ^^^^^
|
= note: import resolution is stuck, try simplifying macro imports
error: cannot determine resolution for the derive macro `PartialEq`
--> $DIR/issue-43927-non-ADT-derive.rs:3:18
|
LL | #![derive(Debug, PartialEq, Eq)] // should be an outer attribute!
| ^^^^^^^^^
|
= note: import resolution is stuck, try simplifying macro imports
error: cannot determine resolution for the derive macro `Eq`
--> $DIR/issue-43927-non-ADT-derive.rs:3:29
|
LL | #![derive(Debug, PartialEq, Eq)] // should be an outer attribute!
| ^^
|
= note: import resolution is stuck, try simplifying macro imports
error: aborting due to 4 previous errors