diff options
| author | est31 <MTest31@outlook.com> | 2022-05-25 02:30:55 +0200 |
|---|---|---|
| committer | est31 <MTest31@outlook.com> | 2022-06-01 02:44:12 +0200 |
| commit | 0a24b9493b12b71db28d11afd360dc2fea88e466 (patch) | |
| tree | a215895b5772ca897c9d84f136c6fe2adba22269 | |
| parent | 535e28b6c66a4e3fd5370a4f8b2fcecf12c4cc6a (diff) | |
| download | rust-0a24b9493b12b71db28d11afd360dc2fea88e466.tar.gz rust-0a24b9493b12b71db28d11afd360dc2fea88e466.zip | |
Remove #[rustc_box] attr during lowering
| -rw-r--r-- | compiler/rustc_ast_lowering/src/expr.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 04d88282862..539e33702aa 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -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 |
