File tree 2 files changed +25
-1
lines changed
rustc_middle/src/ty/print
2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -738,7 +738,9 @@ pub trait PrettyPrinter<'tcx>:
738
738
}
739
739
}
740
740
ty:: Placeholder ( placeholder) => match placeholder. bound . kind {
741
- ty:: BoundTyKind :: Anon => p ! ( write( "Placeholder({:?})" , placeholder) ) ,
741
+ ty:: BoundTyKind :: Anon => {
742
+ self . pretty_print_placeholder_var ( placeholder. universe , placeholder. bound . var ) ?
743
+ }
742
744
ty:: BoundTyKind :: Param ( _, name) => p ! ( write( "{}" , name) ) ,
743
745
} ,
744
746
ty:: Alias ( ty:: Opaque , ty:: AliasTy { def_id, substs, .. } ) => {
@@ -1172,6 +1174,18 @@ pub trait PrettyPrinter<'tcx>:
1172
1174
}
1173
1175
}
1174
1176
1177
+ fn pretty_print_placeholder_var (
1178
+ & mut self ,
1179
+ ui : ty:: UniverseIndex ,
1180
+ var : ty:: BoundVar ,
1181
+ ) -> Result < ( ) , Self :: Error > {
1182
+ if ui == ty:: UniverseIndex :: ROOT {
1183
+ write ! ( self , "!{}" , var. index( ) )
1184
+ } else {
1185
+ write ! ( self , "!{}_{}" , ui. index( ) , var. index( ) )
1186
+ }
1187
+ }
1188
+
1175
1189
fn ty_infer_name ( & self , _: ty:: TyVid ) -> Option < Symbol > {
1176
1190
None
1177
1191
}
Original file line number Diff line number Diff line change @@ -203,6 +203,10 @@ pub enum TyKind<I: Interner> {
203
203
/// `for<'a, T> &'a (): Trait<T>` and then convert the introduced bound variables
204
204
/// back to inference variables in a new inference context when inside of the query.
205
205
///
206
+ /// It is conventional to render anonymous bound types like `^N` or `^D_N`,
207
+ /// where `N` is the bound variable's anonymous index into the binder, and
208
+ /// `D` is the debruijn index, or totally omitted if the debruijn index is zero.
209
+ ///
206
210
/// See the `rustc-dev-guide` for more details about
207
211
/// [higher-ranked trait bounds][1] and [canonical queries][2].
208
212
///
@@ -212,6 +216,12 @@ pub enum TyKind<I: Interner> {
212
216
213
217
/// A placeholder type, used during higher ranked subtyping to instantiate
214
218
/// bound variables.
219
+ ///
220
+ /// It is conventional to render anonymous placeholer types like `!N` or `!U_N`,
221
+ /// where `N` is the placeholder variable's anonymous index (which corresponds
222
+ /// to the bound variable's index from the binder from which it was instantiated),
223
+ /// and `U` is the universe index in which it is instantiated, or totally omitted
224
+ /// if the universe index is zero.
215
225
Placeholder ( I :: PlaceholderType ) ,
216
226
217
227
/// A type variable used during type checking.
You can’t perform that action at this time.
0 commit comments