@@ -1424,28 +1424,33 @@ pub struct EarlyBoundRegion {
1424
1424
pub name : Symbol ,
1425
1425
}
1426
1426
1427
+ /// A **ty**pe **v**ariable **ID**.
1427
1428
#[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash , TyEncodable , TyDecodable ) ]
1428
1429
pub struct TyVid {
1429
1430
pub index : u32 ,
1430
1431
}
1431
1432
1433
+ /// A **`const`** **v**ariable **ID**.
1432
1434
#[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash , TyEncodable , TyDecodable ) ]
1433
1435
pub struct ConstVid < ' tcx > {
1434
1436
pub index : u32 ,
1435
1437
pub phantom : PhantomData < & ' tcx ( ) > ,
1436
1438
}
1437
1439
1440
+ /// An **int**egral (`u32`, `i32`, `usize`, etc.) type **v**ariable **ID**.
1438
1441
#[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash , TyEncodable , TyDecodable ) ]
1439
1442
pub struct IntVid {
1440
1443
pub index : u32 ,
1441
1444
}
1442
1445
1446
+ /// An **float**ing-point (`f32` or `f64`) type **v**ariable **ID**.
1443
1447
#[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash , TyEncodable , TyDecodable ) ]
1444
1448
pub struct FloatVid {
1445
1449
pub index : u32 ,
1446
1450
}
1447
1451
1448
1452
rustc_index:: newtype_index! {
1453
+ /// A **region** (lifetime) **v**ariable **ID**.
1449
1454
pub struct RegionVid {
1450
1455
DEBUG_FORMAT = custom,
1451
1456
}
@@ -1457,18 +1462,40 @@ impl Atom for RegionVid {
1457
1462
}
1458
1463
}
1459
1464
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.
1460
1470
#[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash , TyEncodable , TyDecodable ) ]
1461
1471
#[ derive( HashStable ) ]
1462
1472
pub enum InferTy {
1473
+ /// A type variable.
1463
1474
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.
1464
1481
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.
1465
1488
FloatVar ( FloatVid ) ,
1466
1489
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].
1470
1495
FreshTy ( u32 ) ,
1496
+ /// Like [`FreshTy`][Self::FreshTy], but as a replacement for [`IntVar`][Self::IntVar].
1471
1497
FreshIntTy ( u32 ) ,
1498
+ /// Like [`FreshTy`][Self::FreshTy], but as a replacement for [`FloatVar`][Self::FloatVar].
1472
1499
FreshFloatTy ( u32 ) ,
1473
1500
}
1474
1501
0 commit comments