Skip to content

Commit bfbaac7

Browse files
authored
Rollup merge of #149200 - yaahc:helper-compat-test, r=petrochenkov
Add test for derive helper compat collisions Resolves rust-lang/reference#2055 (comment) r? `@petrochenkov`
2 parents c35d0f5 + 7537b0b commit bfbaac7

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
extern crate proc_macro;
2+
use proc_macro::{TokenStream, TokenTree};
3+
4+
#[proc_macro_derive(Empty2, attributes(empty_helper))]
5+
pub fn empty_derive2(_: TokenStream) -> TokenStream {
6+
TokenStream::new()
7+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//@ proc-macro: test-macros.rs
2+
//@ proc-macro: extra-empty-derive.rs
3+
//@ check-pass
4+
5+
#[macro_use(Empty)]
6+
extern crate test_macros;
7+
#[macro_use(Empty2)]
8+
extern crate extra_empty_derive;
9+
10+
// Testing the behavior of derive attributes with helpers that share the same name.
11+
//
12+
// Normally if the first derive below were absent the call to #[empty_helper] before it it
13+
// introduced by its own derive would produce a future incompat error.
14+
//
15+
// With the extra derive also introducing that attribute in advanced the warning gets supressed.
16+
// Demonstrates a lack of identity to helper attributes, the compiler does not track which derive
17+
// introduced a helper, just that a derive introduced the helper.
18+
#[derive(Empty)]
19+
#[empty_helper]
20+
#[derive(Empty2)]
21+
struct S;
22+
23+
fn main() {}

0 commit comments

Comments
 (0)