@@ -275,6 +275,7 @@ impl<'hir> ConstArg<'hir> {
275275        match  self . kind  { 
276276            ConstArgKind :: Path ( path)  => path. span ( ) , 
277277            ConstArgKind :: Anon ( anon)  => anon. span , 
278+             ConstArgKind :: Infer ( span)  => span, 
278279        } 
279280    } 
280281} 
@@ -289,6 +290,11 @@ pub enum ConstArgKind<'hir> {
289290     /// However, in the future, we'll be using it for all of those. 
290291     Path ( QPath < ' hir > ) , 
291292    Anon ( & ' hir  AnonConst ) , 
293+     /// **Note:** Not all inferred consts are represented as 
294+      /// `ConstArgKind::Infer`. In cases where it is ambiguous whether 
295+      /// a generic arg is a type or a const, inference variables are 
296+      /// represented as `GenericArg::Infer` instead. 
297+      Infer ( Span ) , 
292298} 
293299
294300#[ derive( Clone ,  Copy ,  Debug ,  HashStable_Generic ) ]  
@@ -308,6 +314,10 @@ pub enum GenericArg<'hir> {
308314    Lifetime ( & ' hir  Lifetime ) , 
309315    Type ( & ' hir  Ty < ' hir > ) , 
310316    Const ( & ' hir  ConstArg < ' hir > ) , 
317+     /// **Note:** Inference variables are only represented as 
318+      /// `GenericArg::Infer` in cases where it is ambiguous whether 
319+      /// a generic arg is a type or a const. Otherwise, inference variables 
320+      /// are represented as `TyKind::Infer` or `ConstArgKind::Infer`. 
311321     Infer ( InferArg ) , 
312322} 
313323
@@ -1645,29 +1655,6 @@ impl fmt::Display for ConstContext {
16451655/// A literal. 
16461656pub  type  Lit  = Spanned < LitKind > ; 
16471657
1648- #[ derive( Copy ,  Clone ,  Debug ,  HashStable_Generic ) ]  
1649- pub  enum  ArrayLen < ' hir >  { 
1650-     Infer ( InferArg ) , 
1651-     Body ( & ' hir  ConstArg < ' hir > ) , 
1652- } 
1653- 
1654- impl  ArrayLen < ' _ >  { 
1655-     pub  fn  span ( self )  -> Span  { 
1656-         match  self  { 
1657-             ArrayLen :: Infer ( arg)  => arg. span , 
1658-             ArrayLen :: Body ( body)  => body. span ( ) , 
1659-         } 
1660-     } 
1661- 
1662-     pub  fn  hir_id ( self )  -> HirId  { 
1663-         match  self  { 
1664-             ArrayLen :: Infer ( InferArg  {  hir_id,  .. } )  | ArrayLen :: Body ( & ConstArg  {  hir_id,  .. } )  => { 
1665-                 hir_id
1666-             } 
1667-         } 
1668-     } 
1669- } 
1670- 
16711658/// A constant (expression) that's not an item or associated item, 
16721659/// but needs its own `DefId` for type-checking, const-eval, etc. 
16731660/// These are usually found nested inside types (e.g., array lengths) 
@@ -2115,7 +2102,7 @@ pub enum ExprKind<'hir> {
21152102     /// 
21162103     /// E.g., `[1; 5]`. The first expression is the element 
21172104     /// to be repeated; the second is the number of times to repeat it. 
2118-      Repeat ( & ' hir  Expr < ' hir > ,  ArrayLen < ' hir > ) , 
2105+      Repeat ( & ' hir  Expr < ' hir > ,  & ' hir   ConstArg < ' hir > ) , 
21192106
21202107    /// A suspension point for coroutines (i.e., `yield <expr>`). 
21212108     Yield ( & ' hir  Expr < ' hir > ,  YieldSource ) , 
@@ -2625,7 +2612,7 @@ impl<'hir> Ty<'hir> {
26252612            TyKind :: Infer  => true , 
26262613            TyKind :: Slice ( ty)  => ty. is_suggestable_infer_ty ( ) , 
26272614            TyKind :: Array ( ty,  length)  => { 
2628-                 ty. is_suggestable_infer_ty ( )  || matches ! ( length,   ArrayLen :: Infer ( ..) ) 
2615+                 ty. is_suggestable_infer_ty ( )  || matches ! ( length. kind ,   ConstArgKind :: Infer ( ..) ) 
26292616            } 
26302617            TyKind :: Tup ( tys)  => tys. iter ( ) . any ( Self :: is_suggestable_infer_ty) , 
26312618            TyKind :: Ptr ( mut_ty)  | TyKind :: Ref ( _,  mut_ty)  => mut_ty. ty . is_suggestable_infer_ty ( ) , 
@@ -2834,7 +2821,7 @@ pub enum TyKind<'hir> {
28342821    /// A variable length slice (i.e., `[T]`). 
28352822     Slice ( & ' hir  Ty < ' hir > ) , 
28362823    /// A fixed length array (i.e., `[T; n]`). 
2837-      Array ( & ' hir  Ty < ' hir > ,  ArrayLen < ' hir > ) , 
2824+      Array ( & ' hir  Ty < ' hir > ,  & ' hir   ConstArg < ' hir > ) , 
28382825    /// A raw pointer (i.e., `*const T` or `*mut T`). 
28392826     Ptr ( MutTy < ' hir > ) , 
28402827    /// A reference (i.e., `&'a T` or `&'a mut T`). 
@@ -2861,6 +2848,11 @@ pub enum TyKind<'hir> {
28612848     Typeof ( & ' hir  AnonConst ) , 
28622849    /// `TyKind::Infer` means the type should be inferred instead of it having been 
28632850     /// specified. This can appear anywhere in a type. 
2851+      /// 
2852+      /// **Note:** Not all inferred types are represented as 
2853+      /// `TyKind::Infer`. In cases where it is ambiguous whether 
2854+      /// a generic arg is a type or a const, inference variables are 
2855+      /// represented as `GenericArg::Infer` instead. 
28642856     Infer , 
28652857    /// Placeholder for a type that has failed to be defined. 
28662858     Err ( rustc_span:: ErrorGuaranteed ) , 
@@ -3801,8 +3793,6 @@ pub enum Node<'hir> {
38013793    Crate ( & ' hir  Mod < ' hir > ) , 
38023794    Infer ( & ' hir  InferArg ) , 
38033795    WherePredicate ( & ' hir  WherePredicate < ' hir > ) , 
3804-     // FIXME: Merge into `Node::Infer`. 
3805-     ArrayLenInfer ( & ' hir  InferArg ) , 
38063796    PreciseCapturingNonLifetimeArg ( & ' hir  PreciseCapturingNonLifetimeArg ) , 
38073797    // Created by query feeding 
38083798    Synthetic , 
@@ -3856,7 +3846,6 @@ impl<'hir> Node<'hir> {
38563846            | Node :: OpaqueTy ( ..) 
38573847            | Node :: Infer ( ..) 
38583848            | Node :: WherePredicate ( ..) 
3859-             | Node :: ArrayLenInfer ( ..) 
38603849            | Node :: Synthetic 
38613850            | Node :: Err ( ..)  => None , 
38623851        } 
0 commit comments