diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2025-05-07 17:40:30 +0200 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2025-06-18 10:20:20 +0200 |
| commit | 8ff2c1a97ed9dab37bca913fab0e4cce783e521c (patch) | |
| tree | 3c2f166635d440453bb6c6a7a6616363e5bd2c3c /compiler/rustc_ast_lowering/src/expr.rs | |
| parent | 27733d46d79f4eb92e240fbba502c43022665735 (diff) | |
| download | rust-8ff2c1a97ed9dab37bca913fab0e4cce783e521c.tar.gz rust-8ff2c1a97ed9dab37bca913fab0e4cce783e521c.zip | |
Allow storing `format_args!()` in `let`.
This uses `super let` to allow
let f = format_args!("Hello {}", world);
println!("{f}");
to work.
Diffstat (limited to 'compiler/rustc_ast_lowering/src/expr.rs')
| -rw-r--r-- | compiler/rustc_ast_lowering/src/expr.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 718edad0cc6..f297bf9f4cf 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -2289,12 +2289,12 @@ impl<'hir> LoweringContext<'_, 'hir> { span: Span, elements: &'hir [hir::Expr<'hir>], ) -> hir::Expr<'hir> { - let addrof = hir::ExprKind::AddrOf( - hir::BorrowKind::Ref, - hir::Mutability::Not, - self.arena.alloc(self.expr(span, hir::ExprKind::Array(elements))), - ); - self.expr(span, addrof) + let array = self.arena.alloc(self.expr(span, hir::ExprKind::Array(elements))); + self.expr_ref(span, array) + } + + pub(super) fn expr_ref(&mut self, span: Span, expr: &'hir hir::Expr<'hir>) -> hir::Expr<'hir> { + self.expr(span, hir::ExprKind::AddrOf(hir::BorrowKind::Ref, hir::Mutability::Not, expr)) } pub(super) fn expr(&mut self, span: Span, kind: hir::ExprKind<'hir>) -> hir::Expr<'hir> { |
