Skip to content

Commit d2619b5

Browse files
committed
Remove mgca_direct_lit_hack indirection
1 parent 5127108 commit d2619b5

4 files changed

Lines changed: 4 additions & 15 deletions

File tree

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,8 +1628,7 @@ impl<'a> Parser<'a> {
16281628
let first_expr = self.parse_expr()?;
16291629
if self.eat(exp!(Semi)) {
16301630
// Repeating array syntax: `[ 0; 512 ]`
1631-
let count =
1632-
self.parse_expr_anon_const(|this, expr| this.mgca_direct_lit_hack(expr))?;
1631+
let count = self.parse_expr_anon_const(|_, _| MgcaDisambiguation::Direct)?;
16331632
self.expect(close)?;
16341633
ExprKind::Repeat(first_expr, count)
16351634
} else if self.eat(exp!(Comma)) {

compiler/rustc_parse/src/parser/item.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,9 +1587,7 @@ impl<'a> Parser<'a> {
15871587

15881588
let rhs = match (self.eat(exp!(Eq)), const_arg) {
15891589
(true, true) => ConstItemRhsKind::TypeConst {
1590-
rhs: Some(
1591-
self.parse_expr_anon_const(|this, expr| this.mgca_direct_lit_hack(expr))?,
1592-
),
1590+
rhs: Some(self.parse_expr_anon_const(|_, _| MgcaDisambiguation::Direct)?),
15931591
},
15941592
(true, false) => ConstItemRhsKind::Body { rhs: Some(self.parse_expr()?) },
15951593
(false, true) => ConstItemRhsKind::TypeConst { rhs: None },

compiler/rustc_parse/src/parser/path.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -915,14 +915,7 @@ impl<'a> Parser<'a> {
915915
});
916916
}
917917

918-
let mgca_disambiguation = self.mgca_direct_lit_hack(&expr);
919-
Ok((expr, mgca_disambiguation))
920-
}
921-
922-
/// Under `min_generic_const_args`, prefer direct const arguments rather than
923-
/// wrapping literals in anon consts.
924-
pub fn mgca_direct_lit_hack(&self, _expr: &Expr) -> MgcaDisambiguation {
925-
MgcaDisambiguation::Direct
918+
Ok((expr, MgcaDisambiguation::Direct))
926919
}
927920

928921
/// Parse a generic argument in a path segment.

compiler/rustc_parse/src/parser/ty.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,8 +658,7 @@ impl<'a> Parser<'a> {
658658
};
659659

660660
let ty = if self.eat(exp!(Semi)) {
661-
let mut length =
662-
self.parse_expr_anon_const(|this, expr| this.mgca_direct_lit_hack(expr))?;
661+
let mut length = self.parse_expr_anon_const(|_, _| MgcaDisambiguation::Direct)?;
663662

664663
if let Err(e) = self.expect(exp!(CloseBracket)) {
665664
// Try to recover from `X<Y, ...>` when `X::<Y, ...>` works

0 commit comments

Comments
 (0)