Skip to content

Commit

Permalink
Remove #[rustc_box] attr during lowering
Browse files Browse the repository at this point in the history
  • Loading branch information
est31 committed Jun 1, 2022
1 parent 535e28b commit 0a24b94
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
ExprKind::Tup(ref elts) => hir::ExprKind::Tup(self.lower_exprs(elts)),
ExprKind::Call(ref f, ref args) => {
if e.attrs.get(0).map_or(false, |a| a.has_name(sym::rustc_box)) {
if let [inner] = &args[..] {
hir::ExprKind::Box(self.lower_expr(&inner))
if let [inner] = &args[..] && e.attrs.len() == 1 {
let kind = hir::ExprKind::Box(self.lower_expr(&inner));
let hir_id = self.lower_node_id(e.id);
return hir::Expr { hir_id, kind, span: self.lower_span(e.span) };
} else {
self.sess
.struct_span_err(
e.span,
"rustc_box requires precisely one argument",
"#[rustc_box] requires precisely one argument \
and no other attributes are allowed",
)
.emit();
hir::ExprKind::Err
Expand Down

0 comments on commit 0a24b94

Please sign in to comment.