@@ -989,11 +989,11 @@ impl<'a, 'gcx, 'tcx> ParamTy {
989
989
/// for<'a> fn(for<'b> fn(&'b isize, &'a isize), &'a char)
990
990
/// ^ ^ | | |
991
991
/// | | | | |
992
- /// | +------------+ 1 | |
992
+ /// | +------------+ 0 | |
993
993
/// | | |
994
- /// +--------------------------------+ 2 |
994
+ /// +--------------------------------+ 1 |
995
995
/// | |
996
- /// +------------------------------------------+ 1
996
+ /// +------------------------------------------+ 0
997
997
///
998
998
/// In this type, there are two binders (the outer fn and the inner
999
999
/// fn). We need to be able to determine, for any given region, which
@@ -1005,9 +1005,9 @@ impl<'a, 'gcx, 'tcx> ParamTy {
1005
1005
///
1006
1006
/// Let's start with the reference type `&'b isize` that is the first
1007
1007
/// argument to the inner function. This region `'b` is assigned a De
1008
- /// Bruijn index of 1 , meaning "the innermost binder" (in this case, a
1008
+ /// Bruijn index of 0 , meaning "the innermost binder" (in this case, a
1009
1009
/// fn). The region `'a` that appears in the second argument type (`&'a
1010
- /// isize`) would then be assigned a De Bruijn index of 2 , meaning "the
1010
+ /// isize`) would then be assigned a De Bruijn index of 1 , meaning "the
1011
1011
/// second-innermost binder". (These indices are written on the arrays
1012
1012
/// in the diagram).
1013
1013
///
@@ -1017,15 +1017,15 @@ impl<'a, 'gcx, 'tcx> ParamTy {
1017
1017
/// the outermost fn. But this time, this reference is not nested within
1018
1018
/// any other binders (i.e., it is not an argument to the inner fn, but
1019
1019
/// rather the outer one). Therefore, in this case, it is assigned a
1020
- /// De Bruijn index of 1 , because the innermost binder in that location
1020
+ /// De Bruijn index of 0 , because the innermost binder in that location
1021
1021
/// is the outer fn.
1022
1022
///
1023
1023
/// [dbi]: http://en.wikipedia.org/wiki/De_Bruijn_index
1024
1024
#[ derive( Clone , PartialEq , Eq , Hash , RustcEncodable , RustcDecodable , Debug , Copy , PartialOrd , Ord ) ]
1025
1025
pub struct DebruijnIndex {
1026
1026
/// We maintain the invariant that this is never 0. So 1 indicates
1027
1027
/// the innermost binder.
1028
- depth : u32 ,
1028
+ index : u32 ,
1029
1029
}
1030
1030
1031
1031
pub type Region < ' tcx > = & ' tcx RegionKind ;
@@ -1259,7 +1259,7 @@ impl<'a, 'tcx, 'gcx> PolyExistentialProjection<'tcx> {
1259
1259
}
1260
1260
1261
1261
impl DebruijnIndex {
1262
- pub const INNERMOST : DebruijnIndex = DebruijnIndex { depth : 1 } ;
1262
+ pub const INNERMOST : DebruijnIndex = DebruijnIndex { index : 0 } ;
1263
1263
1264
1264
/// Returns the resulting index when this value is moved into
1265
1265
/// `amount` number of new binders. So e.g. if you had
@@ -1273,7 +1273,7 @@ impl DebruijnIndex {
1273
1273
/// you would need to shift the index for `'a` into 1 new binder.
1274
1274
#[ must_use]
1275
1275
pub const fn shifted_in ( self , amount : u32 ) -> DebruijnIndex {
1276
- DebruijnIndex { depth : self . depth + amount }
1276
+ DebruijnIndex { index : self . index + amount }
1277
1277
}
1278
1278
1279
1279
/// Update this index in place by shifting it "in" through
@@ -1286,7 +1286,7 @@ impl DebruijnIndex {
1286
1286
/// `amount` number of new binders.
1287
1287
#[ must_use]
1288
1288
pub const fn shifted_out ( self , amount : u32 ) -> DebruijnIndex {
1289
- DebruijnIndex { depth : self . depth - amount }
1289
+ DebruijnIndex { index : self . index - amount }
1290
1290
}
1291
1291
1292
1292
/// Update in place by shifting out from `amount` binders.
@@ -1315,12 +1315,12 @@ impl DebruijnIndex {
1315
1315
/// bound by one of the binders we are shifting out of, that is an
1316
1316
/// error (and should fail an assertion failure).
1317
1317
pub fn shifted_out_to_binder ( self , to_binder : DebruijnIndex ) -> Self {
1318
- self . shifted_out ( to_binder. depth - Self :: INNERMOST . depth )
1318
+ self . shifted_out ( to_binder. index - Self :: INNERMOST . index )
1319
1319
}
1320
1320
}
1321
1321
1322
1322
impl_stable_hash_for ! ( struct DebruijnIndex {
1323
- depth
1323
+ index
1324
1324
} ) ;
1325
1325
1326
1326
/// Region utilities
0 commit comments