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::<Vec<_>>().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..7679f8eaa79 --- /dev/null +++ b/src/test/ui/macros/issue-68058.rs @@ -0,0 +1,15 @@ +// check-pass + +macro_rules! def_target { + ($target: expr) => { + #[target_feature(enable=$target)] + unsafe fn f() { + #[target_feature(enable=$target)] + () + } + }; +} + +def_target!("avx2"); + +fn main() {}