@@ -250,20 +250,23 @@ pub struct ConstArg<'hir> {
250
250
pub enum ConstArgKind < ' hir > {
251
251
AnonConst ( Span , AnonConst ) ,
252
252
Param ( HirId , QPath < ' hir > ) ,
253
+ Infer ( HirId , Span ) ,
253
254
}
254
255
255
256
impl < ' hir > ConstArg < ' hir > {
256
257
pub fn span ( & self ) -> Span {
257
258
match self . kind {
258
259
ConstArgKind :: AnonConst ( span, _) => span,
259
260
ConstArgKind :: Param ( _, qpath) => qpath. span ( ) ,
261
+ ConstArgKind :: Infer ( _, span) => span,
260
262
}
261
263
}
262
264
263
265
pub fn hir_id ( & self ) -> HirId {
264
266
match self . kind {
265
267
ConstArgKind :: AnonConst ( _, ct) => ct. hir_id ,
266
268
ConstArgKind :: Param ( id, _) => id,
269
+ ConstArgKind :: Infer ( id, _) => id,
267
270
}
268
271
}
269
272
}
@@ -1667,20 +1670,6 @@ impl fmt::Display for ConstContext {
1667
1670
/// A literal.
1668
1671
pub type Lit = Spanned < LitKind > ;
1669
1672
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
-
1684
1673
/// A constant (expression) that's not an item or associated item,
1685
1674
/// but needs its own `DefId` for type-checking, const-eval, etc.
1686
1675
/// These are usually found nested inside types (e.g., array lengths)
@@ -2055,7 +2044,7 @@ pub enum ExprKind<'hir> {
2055
2044
///
2056
2045
/// E.g., `[1; 5]`. The first expression is the element
2057
2046
/// 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 > ) ,
2059
2048
2060
2049
/// A suspension point for generators (i.e., `yield <expr>`).
2061
2050
Yield ( & ' hir Expr < ' hir > , YieldSource ) ,
@@ -2692,7 +2681,7 @@ pub enum TyKind<'hir> {
2692
2681
/// A variable length slice (i.e., `[T]`).
2693
2682
Slice ( & ' hir Ty < ' hir > ) ,
2694
2683
/// A fixed length array (i.e., `[T; n]`).
2695
- Array ( & ' hir Ty < ' hir > , ArrayLen ) ,
2684
+ Array ( & ' hir Ty < ' hir > , & ' hir ConstArg < ' hir > ) ,
2696
2685
/// A raw pointer (i.e., `*const T` or `*mut T`).
2697
2686
Ptr ( MutTy < ' hir > ) ,
2698
2687
/// A reference (i.e., `&'a T` or `&'a mut T`).
@@ -3778,7 +3767,10 @@ impl<'hir> Node<'hir> {
3778
3767
kind :
3779
3768
ExprKind :: ConstBlock ( AnonConst { body, .. } )
3780
3769
| ExprKind :: Closure ( Closure { body, .. } )
3781
- | ExprKind :: Repeat ( _, ArrayLen :: Body ( AnonConst { body, .. } ) ) ,
3770
+ | ExprKind :: Repeat (
3771
+ _,
3772
+ ConstArg { kind : ConstArgKind :: AnonConst ( _, AnonConst { body, .. } ) } ,
3773
+ ) ,
3782
3774
..
3783
3775
} ) => Some ( * body) ,
3784
3776
_ => None ,
0 commit comments