diff --git a/src/librustc_ast_lowering/expr.rs b/src/librustc_ast_lowering/expr.rs index ee020c7e589..9a229e709a5 100644 --- a/src/librustc_ast_lowering/expr.rs +++ b/src/librustc_ast_lowering/expr.rs @@ -202,7 +202,12 @@ impl<'hir> LoweringContext<'_, 'hir> { ExprKind::Mac(_) => panic!("Shouldn't exist here"), }; - hir::Expr { hir_id: self.lower_node_id(e.id), kind, span: e.span, attrs: e.attrs.clone() } + hir::Expr { + hir_id: self.lower_node_id(e.id), + kind, + span: e.span, + attrs: e.attrs.iter().map(|a| self.lower_attr(a)).collect::>().into(), + } } fn lower_unop(&mut self, u: UnOp) -> hir::UnOp { diff --git a/src/test/ui/macros/issue-68058.rs b/src/test/ui/macros/issue-68058.rs new file mode 100644 index 00000000000..24da2620c2e --- /dev/null +++ b/src/test/ui/macros/issue-68058.rs @@ -0,0 +1,14 @@ +// check-pass + +macro_rules! foo { + ($doc: expr) => { + fn f() { + #[doc = $doc] + () + } + }; +} + +foo!("doc"); + +fn main() {}