@@ -28,30 +28,30 @@ impl<'i, I: Interner> Folder<'i, I> for Subst<'_, 'i, I> {
28
28
self
29
29
}
30
30
31
+ /// We are eliminating one binder, but binders outside of that get preserved.
32
+ ///
33
+ /// So e.g. consider this:
34
+ ///
35
+ /// ```notrust
36
+ /// for<A, B> { for<C> { [A, C] } }
37
+ /// // ^ the binder we are substituing with `[u32]`
38
+ /// ```
39
+ ///
40
+ /// Here, `A` would be `^1.0` and `C` would be `^0.0`. We will replace `^0.0` with the
41
+ /// 0th index from the list (`u32`). We will convert `^1.0` (A) to `^0.0` -- i.e., shift
42
+ /// it **out** of one level of binder (the `for<C>` binder we are eliminating).
43
+ ///
44
+ /// This gives us as a result:
45
+ ///
46
+ /// ```notrust
47
+ /// for<A, B> { [A, u32] }
48
+ /// ^ represented as `^0.0`
49
+ /// ```
31
50
fn fold_free_var_ty (
32
51
& mut self ,
33
52
bound_var : BoundVar ,
34
53
outer_binder : DebruijnIndex ,
35
54
) -> Fallible < Ty < I > > {
36
- // We are eliminating one binder, but binders outside of that get preserved.
37
- //
38
- // So e.g. consider this:
39
- //
40
- // ```
41
- // for<A, B> { for<C> { [A, C] } }
42
- // // ^ the binder we are substituing with `[u32]`
43
- // ```
44
- //
45
- // Here, `A` would be `^1.0` and `C` would be `^0.0`. We will replace `^0.0` with the
46
- // 0th index from the list (`u32`). We will convert `^1.0` (A) to `^0.0` -- i.e., shift
47
- // it **out** of one level of binder (the `for<C>` binder we are eliminating).
48
- //
49
- // This gives us as a result:
50
- //
51
- // ```
52
- // for<A, B> { [A, u32] }
53
- // ^ represented as `^0.0`
54
- // ```
55
55
if let Some ( index) = bound_var. index_if_innermost ( ) {
56
56
match self . parameters [ index] . data ( self . interner ( ) ) {
57
57
ParameterKind :: Ty ( t) => Ok ( t. shifted_in_from ( self . interner ( ) , outer_binder) ) ,
@@ -66,13 +66,12 @@ impl<'i, I: Interner> Folder<'i, I> for Subst<'_, 'i, I> {
66
66
}
67
67
}
68
68
69
+ /// see `fold_free_var_ty`
69
70
fn fold_free_var_lifetime (
70
71
& mut self ,
71
72
bound_var : BoundVar ,
72
73
outer_binder : DebruijnIndex ,
73
74
) -> Fallible < Lifetime < I > > {
74
- // see comment in `fold_free_var_ty`
75
-
76
75
if let Some ( index) = bound_var. index_if_innermost ( ) {
77
76
match self . parameters [ index] . data ( self . interner ( ) ) {
78
77
ParameterKind :: Lifetime ( l) => Ok ( l. shifted_in_from ( self . interner ( ) , outer_binder) ) ,
@@ -87,13 +86,12 @@ impl<'i, I: Interner> Folder<'i, I> for Subst<'_, 'i, I> {
87
86
}
88
87
}
89
88
89
+ /// see `fold_free_var_ty`
90
90
fn fold_free_var_const (
91
91
& mut self ,
92
92
bound_var : BoundVar ,
93
93
outer_binder : DebruijnIndex ,
94
94
) -> Fallible < Const < I > > {
95
- // see comment in `fold_free_var_ty`
96
-
97
95
if let Some ( index) = bound_var. index_if_innermost ( ) {
98
96
match self . parameters [ index] . data ( self . interner ( ) ) {
99
97
ParameterKind :: Const ( c) => Ok ( c. shifted_in_from ( self . interner ( ) , outer_binder) ) ,
0 commit comments