mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Address review comments
This commit is contained in:
parent
f6caae52c1
commit
d8af6de911
@ -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)
|
||||
}
|
||||
|
||||
|
11
src/test/ui/derives/derive-renamed.rs
Normal file
11
src/test/ui/derives/derive-renamed.rs
Normal file
@ -0,0 +1,11 @@
|
||||
// check-pass
|
||||
// edition:2018
|
||||
|
||||
use derive as my_derive;
|
||||
|
||||
#[my_derive(Debug)]
|
||||
struct S;
|
||||
|
||||
fn main() {
|
||||
println!("{:?}", S); // OK
|
||||
}
|
@ -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() {}
|
||||
|
21
src/test/ui/proc-macro/derive-helper-legacy-limits.rs
Normal file
21
src/test/ui/proc-macro/derive-helper-legacy-limits.rs
Normal 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() {}
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user