Address review comments

This commit is contained in:
Vadim Petrochenkov 2021-02-07 19:26:33 +03:00
parent f6caae52c1
commit d8af6de911
5 changed files with 52 additions and 0 deletions

View File

@ -141,6 +141,9 @@ impl Annotatable {
}
crate fn into_tokens(self, sess: &ParseSess) -> TokenStream {
// Tokens of an attribute target may be invalidated by some outer `#[derive]` performing
// "full configuration" (attributes following derives on the same item should be the most
// common case), that's why synthesizing tokens is allowed.
nt_to_tokenstream(&self.into_nonterminal(), sess, CanSynthesizeMissingTokens::Yes)
}

View File

@ -0,0 +1,11 @@
// check-pass
// edition:2018
use derive as my_derive;
#[my_derive(Debug)]
struct S;
fn main() {
println!("{:?}", S); // OK
}

View File

@ -25,4 +25,13 @@ struct S3 {
field: [u8; #[identity_attr] 10], //~ ERROR macro attributes in `#[derive]` output are unstable
}
#[derive(Empty)]
struct S4 {
field: [u8; {
#[derive(Empty)] // OK, not gated
struct Inner;
10
}]
}
fn main() {}

View File

@ -0,0 +1,21 @@
// Support for legacy derive helpers is limited and heuristic-based
// (that's exactly the reason why they are deprecated).
// edition:2018
// aux-build:test-macros.rs
#[macro_use]
extern crate test_macros;
use derive as my_derive;
#[my_derive(Empty)]
#[empty_helper] // OK
struct S1;
// Legacy helper detection doesn't see through `derive` renaming.
#[empty_helper] //~ ERROR cannot find attribute `empty_helper` in this scope
#[my_derive(Empty)]
struct S2;
fn main() {}

View File

@ -0,0 +1,8 @@
error: cannot find attribute `empty_helper` in this scope
--> $DIR/derive-helper-legacy-limits.rs:17:3
|
LL | #[empty_helper]
| ^^^^^^^^^^^^
error: aborting due to previous error