File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
rustc_middle/src/ty/print Expand file tree Collapse file tree 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>:
738738 }
739739 }
740740 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+ }
742744 ty:: BoundTyKind :: Param ( _, name) => p ! ( write( "{}" , name) ) ,
743745 } ,
744746 ty:: Alias ( ty:: Opaque , ty:: AliasTy { def_id, substs, .. } ) => {
@@ -1172,6 +1174,18 @@ pub trait PrettyPrinter<'tcx>:
11721174 }
11731175 }
11741176
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+
11751189 fn ty_infer_name ( & self , _: ty:: TyVid ) -> Option < Symbol > {
11761190 None
11771191 }
Original file line number Diff line number Diff line change @@ -203,6 +203,10 @@ pub enum TyKind<I: Interner> {
203203 /// `for<'a, T> &'a (): Trait<T>` and then convert the introduced bound variables
204204 /// back to inference variables in a new inference context when inside of the query.
205205 ///
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+ ///
206210 /// See the `rustc-dev-guide` for more details about
207211 /// [higher-ranked trait bounds][1] and [canonical queries][2].
208212 ///
@@ -212,6 +216,12 @@ pub enum TyKind<I: Interner> {
212216
213217 /// A placeholder type, used during higher ranked subtyping to instantiate
214218 /// 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.
215225 Placeholder ( I :: PlaceholderType ) ,
216226
217227 /// A type variable used during type checking.
You can’t perform that action at this time.
0 commit comments