Auto merge of #149200 - yaahc:helper-compat-test, r=petrochenkov
Add test for derive helper compat collisions Resolves https://github.com/rust-lang/reference/pull/2055#discussion_r2549423194 r? `@petrochenkov`
This commit is contained in:
commit
cdb4236e65
2 changed files with 30 additions and 0 deletions
7
tests/ui/proc-macro/auxiliary/extra-empty-derive.rs
Normal file
7
tests/ui/proc-macro/auxiliary/extra-empty-derive.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
extern crate proc_macro;
|
||||
use proc_macro::{TokenStream, TokenTree};
|
||||
|
||||
#[proc_macro_derive(Empty2, attributes(empty_helper))]
|
||||
pub fn empty_derive2(_: TokenStream) -> TokenStream {
|
||||
TokenStream::new()
|
||||
}
|
||||
23
tests/ui/proc-macro/helper-attr-compat-collision.rs
Normal file
23
tests/ui/proc-macro/helper-attr-compat-collision.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
//@ proc-macro: test-macros.rs
|
||||
//@ proc-macro: extra-empty-derive.rs
|
||||
//@ check-pass
|
||||
|
||||
#[macro_use(Empty)]
|
||||
extern crate test_macros;
|
||||
#[macro_use(Empty2)]
|
||||
extern crate extra_empty_derive;
|
||||
|
||||
// Testing the behavior of derive attributes with helpers that share the same name.
|
||||
//
|
||||
// Normally if the first derive below were absent the call to #[empty_helper] before it it
|
||||
// introduced by its own derive would produce a future incompat error.
|
||||
//
|
||||
// With the extra derive also introducing that attribute in advanced the warning gets supressed.
|
||||
// Demonstrates a lack of identity to helper attributes, the compiler does not track which derive
|
||||
// introduced a helper, just that a derive introduced the helper.
|
||||
#[derive(Empty)]
|
||||
#[empty_helper]
|
||||
#[derive(Empty2)]
|
||||
struct S;
|
||||
|
||||
fn main() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue