Remove mgca_direct_lit_hack indirection

This commit is contained in:
Redddy
2026-02-25 04:19:38 +00:00
parent 5127108400
commit d2619b5dcf
4 changed files with 4 additions and 15 deletions
+1 -2
View File
@@ -1628,8 +1628,7 @@ fn parse_expr_array_or_repeat(&mut self, close: ExpTokenPair) -> PResult<'a, Box
let first_expr = self.parse_expr()?;
if self.eat(exp!(Semi)) {
// Repeating array syntax: `[ 0; 512 ]`
let count =
self.parse_expr_anon_const(|this, expr| this.mgca_direct_lit_hack(expr))?;
let count = self.parse_expr_anon_const(|_, _| MgcaDisambiguation::Direct)?;
self.expect(close)?;
ExprKind::Repeat(first_expr, count)
} else if self.eat(exp!(Comma)) {
+1 -3
View File
@@ -1587,9 +1587,7 @@ fn parse_const_item(
let rhs = match (self.eat(exp!(Eq)), const_arg) {
(true, true) => ConstItemRhsKind::TypeConst {
rhs: Some(
self.parse_expr_anon_const(|this, expr| this.mgca_direct_lit_hack(expr))?,
),
rhs: Some(self.parse_expr_anon_const(|_, _| MgcaDisambiguation::Direct)?),
},
(true, false) => ConstItemRhsKind::Body { rhs: Some(self.parse_expr()?) },
(false, true) => ConstItemRhsKind::TypeConst { rhs: None },
+1 -8
View File
@@ -915,14 +915,7 @@ pub(super) fn parse_unambiguous_unbraced_const_arg(
});
}
let mgca_disambiguation = self.mgca_direct_lit_hack(&expr);
Ok((expr, mgca_disambiguation))
}
/// Under `min_generic_const_args`, prefer direct const arguments rather than
/// wrapping literals in anon consts.
pub fn mgca_direct_lit_hack(&self, _expr: &Expr) -> MgcaDisambiguation {
MgcaDisambiguation::Direct
Ok((expr, MgcaDisambiguation::Direct))
}
/// Parse a generic argument in a path segment.
+1 -2
View File
@@ -658,8 +658,7 @@ fn parse_array_or_slice_ty(&mut self) -> PResult<'a, TyKind> {
};
let ty = if self.eat(exp!(Semi)) {
let mut length =
self.parse_expr_anon_const(|this, expr| this.mgca_direct_lit_hack(expr))?;
let mut length = self.parse_expr_anon_const(|_, _| MgcaDisambiguation::Direct)?;
if let Err(e) = self.expect(exp!(CloseBracket)) {
// Try to recover from `X<Y, ...>` when `X::<Y, ...>` works