@@ -250,20 +250,23 @@ pub struct ConstArg<'hir> {
250250pub enum ConstArgKind < ' hir > {
251251 AnonConst ( Span , AnonConst ) ,
252252 Param ( HirId , QPath < ' hir > ) ,
253+ Infer ( HirId , Span ) ,
253254}
254255
255256impl < ' hir > ConstArg < ' hir > {
256257 pub fn span ( & self ) -> Span {
257258 match self . kind {
258259 ConstArgKind :: AnonConst ( span, _) => span,
259260 ConstArgKind :: Param ( _, qpath) => qpath. span ( ) ,
261+ ConstArgKind :: Infer ( _, span) => span,
260262 }
261263 }
262264
263265 pub fn hir_id ( & self ) -> HirId {
264266 match self . kind {
265267 ConstArgKind :: AnonConst ( _, ct) => ct. hir_id ,
266268 ConstArgKind :: Param ( id, _) => id,
269+ ConstArgKind :: Infer ( id, _) => id,
267270 }
268271 }
269272}
@@ -1667,20 +1670,6 @@ impl fmt::Display for ConstContext {
16671670/// A literal.
16681671pub type Lit = Spanned < LitKind > ;
16691672
1670- #[ derive( Copy , Clone , Debug , HashStable_Generic ) ]
1671- pub enum ArrayLen {
1672- Infer ( HirId , Span ) ,
1673- Body ( AnonConst ) ,
1674- }
1675-
1676- impl ArrayLen {
1677- pub fn hir_id ( & self ) -> HirId {
1678- match self {
1679- & ArrayLen :: Infer ( hir_id, _) | & ArrayLen :: Body ( AnonConst { hir_id, .. } ) => hir_id,
1680- }
1681- }
1682- }
1683-
16841673/// A constant (expression) that's not an item or associated item,
16851674/// but needs its own `DefId` for type-checking, const-eval, etc.
16861675/// These are usually found nested inside types (e.g., array lengths)
@@ -2055,7 +2044,7 @@ pub enum ExprKind<'hir> {
20552044 ///
20562045 /// E.g., `[1; 5]`. The first expression is the element
20572046 /// to be repeated; the second is the number of times to repeat it.
2058- Repeat ( & ' hir Expr < ' hir > , ArrayLen ) ,
2047+ Repeat ( & ' hir Expr < ' hir > , & ' hir ConstArg < ' hir > ) ,
20592048
20602049 /// A suspension point for generators (i.e., `yield <expr>`).
20612050 Yield ( & ' hir Expr < ' hir > , YieldSource ) ,
@@ -2692,7 +2681,7 @@ pub enum TyKind<'hir> {
26922681 /// A variable length slice (i.e., `[T]`).
26932682 Slice ( & ' hir Ty < ' hir > ) ,
26942683 /// A fixed length array (i.e., `[T; n]`).
2695- Array ( & ' hir Ty < ' hir > , ArrayLen ) ,
2684+ Array ( & ' hir Ty < ' hir > , & ' hir ConstArg < ' hir > ) ,
26962685 /// A raw pointer (i.e., `*const T` or `*mut T`).
26972686 Ptr ( MutTy < ' hir > ) ,
26982687 /// A reference (i.e., `&'a T` or `&'a mut T`).
@@ -3778,7 +3767,10 @@ impl<'hir> Node<'hir> {
37783767 kind :
37793768 ExprKind :: ConstBlock ( AnonConst { body, .. } )
37803769 | ExprKind :: Closure ( Closure { body, .. } )
3781- | ExprKind :: Repeat ( _, ArrayLen :: Body ( AnonConst { body, .. } ) ) ,
3770+ | ExprKind :: Repeat (
3771+ _,
3772+ ConstArg { kind : ConstArgKind :: AnonConst ( _, AnonConst { body, .. } ) } ,
3773+ ) ,
37823774 ..
37833775 } ) => Some ( * body) ,
37843776 _ => None ,
0 commit comments