@@ -16,7 +16,7 @@ use tracing::{debug, instrument};
1616use crate :: error;
1717use crate :: middle:: codegen_fn_attrs:: CodegenFnAttrFlags ;
1818use crate :: ty:: normalize_erasing_regions:: NormalizationError ;
19- use crate :: ty:: print:: { FmtPrinter , Printer } ;
19+ use crate :: ty:: print:: { FmtPrinter , Print } ;
2020use crate :: ty:: {
2121 self , EarlyBinder , GenericArgs , GenericArgsRef , Ty , TyCtxt , TypeFoldable , TypeSuperVisitable ,
2222 TypeVisitable , TypeVisitableExt , TypeVisitor ,
@@ -388,51 +388,15 @@ fn type_length<'tcx>(item: impl TypeVisitable<TyCtxt<'tcx>>) -> usize {
388388 visitor. type_length
389389}
390390
391- pub fn fmt_instance (
392- f : & mut fmt:: Formatter < ' _ > ,
393- instance : Instance < ' _ > ,
394- type_length : Option < rustc_session:: Limit > ,
395- ) -> fmt:: Result {
396- ty:: tls:: with ( |tcx| {
397- let args = tcx. lift ( instance. args ) . expect ( "could not lift for printing" ) ;
398-
399- let mut cx = if let Some ( type_length) = type_length {
400- FmtPrinter :: new_with_limit ( tcx, Namespace :: ValueNS , type_length)
401- } else {
402- FmtPrinter :: new ( tcx, Namespace :: ValueNS )
403- } ;
404- cx. print_def_path ( instance. def_id ( ) , args) ?;
405- let s = cx. into_buffer ( ) ;
406- f. write_str ( & s)
407- } ) ?;
408-
409- match instance. def {
410- InstanceKind :: Item ( _) => Ok ( ( ) ) ,
411- InstanceKind :: VTableShim ( _) => write ! ( f, " - shim(vtable)" ) ,
412- InstanceKind :: ReifyShim ( _, None ) => write ! ( f, " - shim(reify)" ) ,
413- InstanceKind :: ReifyShim ( _, Some ( ReifyReason :: FnPtr ) ) => write ! ( f, " - shim(reify-fnptr)" ) ,
414- InstanceKind :: ReifyShim ( _, Some ( ReifyReason :: Vtable ) ) => write ! ( f, " - shim(reify-vtable)" ) ,
415- InstanceKind :: ThreadLocalShim ( _) => write ! ( f, " - shim(tls)" ) ,
416- InstanceKind :: Intrinsic ( _) => write ! ( f, " - intrinsic" ) ,
417- InstanceKind :: Virtual ( _, num) => write ! ( f, " - virtual#{num}" ) ,
418- InstanceKind :: FnPtrShim ( _, ty) => write ! ( f, " - shim({ty})" ) ,
419- InstanceKind :: ClosureOnceShim { .. } => write ! ( f, " - shim" ) ,
420- InstanceKind :: ConstructCoroutineInClosureShim { .. } => write ! ( f, " - shim" ) ,
421- InstanceKind :: DropGlue ( _, None ) => write ! ( f, " - shim(None)" ) ,
422- InstanceKind :: DropGlue ( _, Some ( ty) ) => write ! ( f, " - shim(Some({ty}))" ) ,
423- InstanceKind :: CloneShim ( _, ty) => write ! ( f, " - shim({ty})" ) ,
424- InstanceKind :: FnPtrAddrShim ( _, ty) => write ! ( f, " - shim({ty})" ) ,
425- InstanceKind :: FutureDropPollShim ( _, proxy_ty, impl_ty) => {
426- write ! ( f, " - dropshim({proxy_ty}-{impl_ty})" )
427- }
428- InstanceKind :: AsyncDropGlue ( _, ty) => write ! ( f, " - shim({ty})" ) ,
429- InstanceKind :: AsyncDropGlueCtorShim ( _, ty) => write ! ( f, " - shim(Some({ty}))" ) ,
430- }
431- }
432-
433391impl < ' tcx > fmt:: Display for Instance < ' tcx > {
434392 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
435- fmt_instance ( f, * self , None )
393+ ty:: tls:: with ( |tcx| {
394+ let mut cx = FmtPrinter :: new ( tcx, Namespace :: ValueNS ) ;
395+ let instance = tcx. lift ( * self ) . expect ( "could not lift for printing" ) ;
396+ instance. print ( & mut cx) ?;
397+ let s = cx. into_buffer ( ) ;
398+ f. write_str ( & s)
399+ } )
436400 }
437401}
438402
0 commit comments