@@ -1424,28 +1424,33 @@ pub struct EarlyBoundRegion {
14241424 pub name : Symbol ,
14251425}
14261426
1427+ /// A **ty**pe **v**ariable **ID**.
14271428#[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash , TyEncodable , TyDecodable ) ]
14281429pub struct TyVid {
14291430 pub index : u32 ,
14301431}
14311432
1433+ /// A **`const`** **v**ariable **ID**.
14321434#[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash , TyEncodable , TyDecodable ) ]
14331435pub struct ConstVid < ' tcx > {
14341436 pub index : u32 ,
14351437 pub phantom : PhantomData < & ' tcx ( ) > ,
14361438}
14371439
1440+ /// An **int**egral (`u32`, `i32`, `usize`, etc.) type **v**ariable **ID**.
14381441#[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash , TyEncodable , TyDecodable ) ]
14391442pub struct IntVid {
14401443 pub index : u32 ,
14411444}
14421445
1446+ /// An **float**ing-point (`f32` or `f64`) type **v**ariable **ID**.
14431447#[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash , TyEncodable , TyDecodable ) ]
14441448pub struct FloatVid {
14451449 pub index : u32 ,
14461450}
14471451
14481452rustc_index:: newtype_index! {
1453+ /// A **region** (lifetime) **v**ariable **ID**.
14491454 pub struct RegionVid {
14501455 DEBUG_FORMAT = custom,
14511456 }
@@ -1457,18 +1462,40 @@ impl Atom for RegionVid {
14571462 }
14581463}
14591464
1465+ /// A placeholder for a type that hasn't been inferred yet.
1466+ ///
1467+ /// E.g., if we have an empty array (`[]`), then we create a fresh
1468+ /// type variable for the element type since we won't know until it's
1469+ /// used what the element type is supposed to be.
14601470#[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash , TyEncodable , TyDecodable ) ]
14611471#[ derive( HashStable ) ]
14621472pub enum InferTy {
1473+ /// A type variable.
14631474 TyVar ( TyVid ) ,
1475+ /// An integral type variable (`{integer}`).
1476+ ///
1477+ /// These are created when the compiler sees an integer literal like
1478+ /// `1` that could be several different types (`u8`, `i32`, `u32`, etc.).
1479+ /// We don't know until it's used what type it's supposed to be, so
1480+ /// we create a fresh type variable.
14641481 IntVar ( IntVid ) ,
1482+ /// A floating-point type variable (`{float}`).
1483+ ///
1484+ /// These are created when the compiler sees an float literal like
1485+ /// `1.0` that could be either an `f32` or an `f64`.
1486+ /// We don't know until it's used what type it's supposed to be, so
1487+ /// we create a fresh type variable.
14651488 FloatVar ( FloatVid ) ,
14661489
1467- /// A `FreshTy` is one that is generated as a replacement for an
1468- /// unbound type variable. This is convenient for caching etc. See
1469- /// `infer::freshen` for more details.
1490+ /// A [`FreshTy`][Self::FreshTy] is one that is generated as a replacement
1491+ /// for an unbound type variable. This is convenient for caching etc. See
1492+ /// `rustc_infer::infer::freshen` for more details.
1493+ ///
1494+ /// Compare with [`TyVar`][Self::TyVar].
14701495 FreshTy ( u32 ) ,
1496+ /// Like [`FreshTy`][Self::FreshTy], but as a replacement for [`IntVar`][Self::IntVar].
14711497 FreshIntTy ( u32 ) ,
1498+ /// Like [`FreshTy`][Self::FreshTy], but as a replacement for [`FloatVar`][Self::FloatVar].
14721499 FreshFloatTy ( u32 ) ,
14731500}
14741501
0 commit comments