Skip to content

Commit 0a24b94

Browse files
committed
Remove #[rustc_box] attr during lowering
1 parent 535e28b commit 0a24b94

File tree

1 file changed

+6
-3
lines changed
  • compiler/rustc_ast_lowering/src

1 file changed

+6
-3
lines changed

compiler/rustc_ast_lowering/src/expr.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
4242
ExprKind::Tup(ref elts) => hir::ExprKind::Tup(self.lower_exprs(elts)),
4343
ExprKind::Call(ref f, ref args) => {
4444
if e.attrs.get(0).map_or(false, |a| a.has_name(sym::rustc_box)) {
45-
if let [inner] = &args[..] {
46-
hir::ExprKind::Box(self.lower_expr(&inner))
45+
if let [inner] = &args[..] && e.attrs.len() == 1 {
46+
let kind = hir::ExprKind::Box(self.lower_expr(&inner));
47+
let hir_id = self.lower_node_id(e.id);
48+
return hir::Expr { hir_id, kind, span: self.lower_span(e.span) };
4749
} else {
4850
self.sess
4951
.struct_span_err(
5052
e.span,
51-
"rustc_box requires precisely one argument",
53+
"#[rustc_box] requires precisely one argument \
54+
and no other attributes are allowed",
5255
)
5356
.emit();
5457
hir::ExprKind::Err

0 commit comments

Comments
 (0)