mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Rollup merge of #132651 - PonasKovas:master, r=fmease
Remove attributes from generics in built-in derive macros Related issue #132561 Removes all attributes from generics in the expanded implementations of built-in derive macros.
This commit is contained in:
commit
b18ee9858b
@ -680,6 +680,12 @@ impl<'a> TraitDef<'a> {
|
|||||||
param_clone
|
param_clone
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.map(|mut param| {
|
||||||
|
// Remove all attributes, because there might be helper attributes
|
||||||
|
// from other macros that will not be valid in the expanded implementation.
|
||||||
|
param.attrs.clear();
|
||||||
|
param
|
||||||
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
// and similarly for where clauses
|
// and similarly for where clauses
|
||||||
|
12
tests/ui/proc-macro/auxiliary/helper-attr.rs
Normal file
12
tests/ui/proc-macro/auxiliary/helper-attr.rs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
//@ force-host
|
||||||
|
//@ no-prefer-dynamic
|
||||||
|
|
||||||
|
#![crate_type = "proc-macro"]
|
||||||
|
|
||||||
|
extern crate proc_macro;
|
||||||
|
|
||||||
|
// Doesn't do anything, but has a helper attribute.
|
||||||
|
#[proc_macro_derive(WithHelperAttr, attributes(x))]
|
||||||
|
pub fn derive(_input: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
||||||
|
proc_macro::TokenStream::new()
|
||||||
|
}
|
19
tests/ui/proc-macro/helper-attr-builtin-derive.rs
Normal file
19
tests/ui/proc-macro/helper-attr-builtin-derive.rs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// This test checks that helper attributes of a derive proc macro can be used together with
|
||||||
|
// other built-in derive macros.
|
||||||
|
// issue: rust-lang/rust#132561
|
||||||
|
//@ check-pass
|
||||||
|
//@ aux-build:helper-attr.rs
|
||||||
|
//@ edition:2021
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
extern crate helper_attr;
|
||||||
|
|
||||||
|
use helper_attr::WithHelperAttr;
|
||||||
|
|
||||||
|
#[derive(WithHelperAttr, Debug, Clone, PartialEq)]
|
||||||
|
struct MyStruct<#[x] 'a, #[x] const A: usize, #[x] B> {
|
||||||
|
#[x]
|
||||||
|
field: &'a [B; A],
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
Loading…
Reference in New Issue
Block a user