@@ -16,7 +16,7 @@ use tracing::{debug, instrument};
16
16
use crate :: error;
17
17
use crate :: middle:: codegen_fn_attrs:: CodegenFnAttrFlags ;
18
18
use crate :: ty:: normalize_erasing_regions:: NormalizationError ;
19
- use crate :: ty:: print:: { FmtPrinter , Printer } ;
19
+ use crate :: ty:: print:: { FmtPrinter , Print } ;
20
20
use crate :: ty:: {
21
21
self , EarlyBinder , GenericArgs , GenericArgsRef , Ty , TyCtxt , TypeFoldable , TypeSuperVisitable ,
22
22
TypeVisitable , TypeVisitableExt , TypeVisitor ,
@@ -388,51 +388,15 @@ fn type_length<'tcx>(item: impl TypeVisitable<TyCtxt<'tcx>>) -> usize {
388
388
visitor. type_length
389
389
}
390
390
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
-
433
391
impl < ' tcx > fmt:: Display for Instance < ' tcx > {
434
392
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
+ } )
436
400
}
437
401
}
438
402
0 commit comments