1
Fork 0

Allow parenthesis around inferred array lengths

This commit is contained in:
Boxy 2025-04-10 17:48:33 +01:00
parent 69b3959afe
commit 8f00b1fdad
3 changed files with 75 additions and 2 deletions

View file

@ -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(