Skip to content

Commit 48dd96c

Browse files
authored
Unrolled build for rust-lang#132651
Rollup merge of rust-lang#132651 - PonasKovas:master, r=fmease Remove attributes from generics in built-in derive macros Related issue rust-lang#132561 Removes all attributes from generics in the expanded implementations of built-in derive macros.
2 parents 9a9dadd + 7c0a7f7 commit 48dd96c

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,12 @@ impl<'a> TraitDef<'a> {
680680
param_clone
681681
}
682682
})
683+
.map(|mut param| {
684+
// Remove all attributes, because there might be helper attributes
685+
// from other macros that will not be valid in the expanded implementation.
686+
param.attrs.clear();
687+
param
688+
})
683689
.collect();
684690

685691
// and similarly for where clauses
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ force-host
2+
//@ no-prefer-dynamic
3+
4+
#![crate_type = "proc-macro"]
5+
6+
extern crate proc_macro;
7+
8+
// Doesn't do anything, but has a helper attribute.
9+
#[proc_macro_derive(WithHelperAttr, attributes(x))]
10+
pub fn derive(_input: proc_macro::TokenStream) -> proc_macro::TokenStream {
11+
proc_macro::TokenStream::new()
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// This test checks that helper attributes of a derive proc macro can be used together with
2+
// other built-in derive macros.
3+
// issue: rust-lang/rust#132561
4+
//@ check-pass
5+
//@ aux-build:helper-attr.rs
6+
//@ edition:2021
7+
8+
#[macro_use]
9+
extern crate helper_attr;
10+
11+
use helper_attr::WithHelperAttr;
12+
13+
#[derive(WithHelperAttr, Debug, Clone, PartialEq)]
14+
struct MyStruct<#[x] 'a, #[x] const A: usize, #[x] B> {
15+
#[x]
16+
field: &'a [B; A],
17+
}
18+
19+
fn main() {}

0 commit comments

Comments
 (0)