about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorBoxy <rust@boxyuwu.dev>2025-04-10 17:48:33 +0100
committerBoxy <rust@boxyuwu.dev>2025-04-10 18:57:42 +0100
commit8f00b1fdad0c60220625bace86510db125ecf31a (patch)
treeb84a10847a25262415bfcd42fbb3f0e3511f0695 /compiler
parent69b3959afec9b5468d5de15133b199553f6e55d2 (diff)
downloadrust-8f00b1fdad0c60220625bace86510db125ecf31a.tar.gz
rust-8f00b1fdad0c60220625bace86510db125ecf31a.zip
Allow parenthesis around inferred array lengths
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_ast_lowering/src/lib.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs
index 6aa6a18ee9a..f62d250fcbe 100644
--- a/compiler/rustc_ast_lowering/src/lib.rs
+++ b/compiler/rustc_ast_lowering/src/lib.rs
@@ -2034,7 +2034,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
     }
 
     fn lower_array_length_to_const_arg(&mut self, c: &AnonConst) -> &'hir hir::ConstArg<'hir> {
-        match c.value.kind {
+        // We cannot just match on `ExprKind::Underscore` as `(_)` is represented as
+        // `ExprKind::Paren(ExprKind::Underscore)` and should also be lowered to `GenericArg::Infer`
+        match c.value.peel_parens().kind {
             ExprKind::Underscore => {
                 if !self.tcx.features().generic_arg_infer() {
                     feature_err(