Skip to content

Commit a0df7b2

Browse files
committed
compiler: Forward attributes to eii-expanded macros
Otherwise you get errors like these if you have an Externally Implementable Item defined in std: error: attribute macro has missing stability attribute --> library/std/src/io/mod.rs:2269:1 | 2269 | #[eii(on_broken_pipe)] | ^^^^^^^^^^^^^^^^^^^^-- | | | in this attribute macro expansion | ::: library/core/src/macros/mod.rs:1899:5 | 1899 | pub macro eii($item:item) { | ------------- in this expansion of `#[eii]` Or (fatal) warnings like these: warning: missing documentation for an attribute macro --> library/std/src/io/mod.rs:2269:1
1 parent 2b82e05 commit a0df7b2

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

  • compiler/rustc_builtin_macros/src

compiler/rustc_builtin_macros/src/eii.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ fn eii_(
133133
macro_name,
134134
foreign_item_name,
135135
impl_unsafe,
136+
&attrs_from_decl,
136137
)));
137138

138139
return_items.into_iter().map(wrap_item).collect()
@@ -416,9 +417,14 @@ fn generate_attribute_macro_to_implement(
416417
macro_name: Ident,
417418
foreign_item_name: Ident,
418419
impl_unsafe: bool,
420+
attrs_from_decl: &[Attribute],
419421
) -> ast::Item {
420422
let mut macro_attrs = ThinVec::new();
421423

424+
// To avoid e.g. `error: attribute macro has missing stability attribute`
425+
// errors for eii's in std.
426+
macro_attrs.extend_from_slice(attrs_from_decl);
427+
422428
// #[builtin_macro(eii_shared_macro)]
423429
macro_attrs.push(ecx.attr_nested_word(sym::rustc_builtin_macro, sym::eii_shared_macro, span));
424430

0 commit comments

Comments
 (0)