@@ -5,7 +5,7 @@ use crate::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
55use crate :: middle:: cstore:: { ExternCrate , ExternCrateSource } ;
66use crate :: middle:: region;
77use crate :: ty:: { self , DefIdTree , ParamConst , Ty , TyCtxt , TypeFoldable } ;
8- use crate :: ty:: subst:: { Kind , Subst , SubstsRef , UnpackedKind } ;
8+ use crate :: ty:: subst:: { Kind , Subst , UnpackedKind } ;
99use crate :: mir:: interpret:: ConstValue ;
1010use syntax:: symbol:: { keywords, Symbol } ;
1111
@@ -178,7 +178,7 @@ pub trait PrettyPrinter<'gcx: 'tcx, 'tcx>:
178178 fn print_value_path (
179179 self ,
180180 def_id : DefId ,
181- substs : Option < SubstsRef < ' tcx > > ,
181+ substs : & ' tcx [ Kind < ' tcx > ] ,
182182 ) -> Result < Self :: Path , Self :: Error > {
183183 self . print_def_path ( def_id, substs)
184184 }
@@ -264,7 +264,7 @@ pub trait PrettyPrinter<'gcx: 'tcx, 'tcx>:
264264 } ) => {
265265 debug ! ( "try_print_visible_def_path: def_id={:?}" , def_id) ;
266266 return Ok ( ( if !span. is_dummy ( ) {
267- self . print_def_path ( def_id, None ) ?
267+ self . print_def_path ( def_id, & [ ] ) ?
268268 } else {
269269 self . path_crate ( cnum) ?
270270 } , true ) ) ;
@@ -469,8 +469,7 @@ pub trait PrettyPrinter<'gcx: 'tcx, 'tcx>:
469469 }
470470 ty:: FnDef ( def_id, substs) => {
471471 let sig = self . tcx ( ) . fn_sig ( def_id) . subst ( self . tcx ( ) , substs) ;
472- p ! ( print( sig) ,
473- write( " {{" ) , print_value_path( def_id, Some ( substs) ) , write( "}}" ) ) ;
472+ p ! ( print( sig) , write( " {{" ) , print_value_path( def_id, substs) , write( "}}" ) ) ;
474473 }
475474 ty:: FnPtr ( ref bare_fn) => {
476475 p ! ( print( bare_fn) )
@@ -492,7 +491,7 @@ pub trait PrettyPrinter<'gcx: 'tcx, 'tcx>:
492491 }
493492 }
494493 ty:: Adt ( def, substs) => {
495- p ! ( print_def_path( def. did, Some ( substs) ) ) ;
494+ p ! ( print_def_path( def. did, substs) ) ;
496495 }
497496 ty:: Dynamic ( data, r) => {
498497 let print_r = self . region_should_not_be_omitted ( r) ;
@@ -505,7 +504,7 @@ pub trait PrettyPrinter<'gcx: 'tcx, 'tcx>:
505504 }
506505 }
507506 ty:: Foreign ( def_id) => {
508- p ! ( print_def_path( def_id, None ) ) ;
507+ p ! ( print_def_path( def_id, & [ ] ) ) ;
509508 }
510509 ty:: Projection ( ref data) => p ! ( print( data) ) ,
511510 ty:: UnnormalizedProjection ( ref data) => {
@@ -691,7 +690,7 @@ pub trait PrettyPrinter<'gcx: 'tcx, 'tcx>:
691690 let mut first = true ;
692691
693692 if let Some ( principal) = predicates. principal ( ) {
694- p ! ( print_def_path( principal. def_id, None ) ) ;
693+ p ! ( print_def_path( principal. def_id, & [ ] ) ) ;
695694
696695 let mut resugared = false ;
697696
@@ -774,7 +773,7 @@ pub trait PrettyPrinter<'gcx: 'tcx, 'tcx>:
774773 }
775774 first = false ;
776775
777- p ! ( print_def_path( def_id, None ) ) ;
776+ p ! ( print_def_path( def_id, & [ ] ) ) ;
778777 }
779778
780779 Ok ( self )
@@ -879,7 +878,7 @@ impl TyCtxt<'_, '_, '_> {
879878 debug ! ( "def_path_str: def_id={:?}, ns={:?}" , def_id, ns) ;
880879 let mut s = String :: new ( ) ;
881880 let _ = FmtPrinter :: new ( self , & mut s, ns)
882- . print_def_path ( def_id, None ) ;
881+ . print_def_path ( def_id, & [ ] ) ;
883882 s
884883 }
885884}
@@ -905,21 +904,13 @@ impl<F: fmt::Write> Printer<'gcx, 'tcx> for FmtPrinter<'_, 'gcx, 'tcx, F> {
905904 fn print_def_path (
906905 mut self ,
907906 def_id : DefId ,
908- substs : Option < SubstsRef < ' tcx > > ,
907+ substs : & ' tcx [ Kind < ' tcx > ] ,
909908 ) -> Result < Self :: Path , Self :: Error > {
910909 define_scoped_cx ! ( self ) ;
911910
912- // FIXME(eddyb) avoid querying `tcx.generics_of` and `tcx.def_key`
913- // both here and in `default_print_def_path`.
914- let generics = substs. map ( |_| self . tcx . generics_of ( def_id) ) ;
915- if generics. as_ref ( ) . and_then ( |g| g. parent ) . is_none ( ) {
911+ if substs. is_empty ( ) {
916912 match self . try_print_visible_def_path ( def_id) ? {
917- ( cx, true ) => return if let ( Some ( generics) , Some ( substs) ) = ( generics, substs) {
918- let args = cx. generic_args_to_print ( generics, substs) ;
919- cx. path_generic_args ( Ok , args)
920- } else {
921- Ok ( cx)
922- } ,
913+ ( cx, true ) => return Ok ( cx) ,
923914 ( cx, false ) => self = cx,
924915 }
925916 }
@@ -942,7 +933,7 @@ impl<F: fmt::Write> Printer<'gcx, 'tcx> for FmtPrinter<'_, 'gcx, 'tcx, F> {
942933 let parent_def_id = DefId { index : key. parent . unwrap ( ) , ..def_id } ;
943934 let span = self . tcx . def_span ( def_id) ;
944935 return self . path_append (
945- |cx| cx. print_def_path ( parent_def_id, None ) ,
936+ |cx| cx. print_def_path ( parent_def_id, & [ ] ) ,
946937 & format ! ( "<impl at {:?}>" , span) ,
947938 ) ;
948939 }
@@ -1073,7 +1064,7 @@ impl<F: fmt::Write> PrettyPrinter<'gcx, 'tcx> for FmtPrinter<'_, 'gcx, 'tcx, F>
10731064 fn print_value_path (
10741065 mut self ,
10751066 def_id : DefId ,
1076- substs : Option < SubstsRef < ' tcx > > ,
1067+ substs : & ' tcx [ Kind < ' tcx > ] ,
10771068 ) -> Result < Self :: Path , Self :: Error > {
10781069 let was_in_value = std:: mem:: replace ( & mut self . in_value , true ) ;
10791070 self = self . print_def_path ( def_id, substs) ?;
@@ -1476,7 +1467,7 @@ define_print_and_forward_display! {
14761467 ty:: ExistentialPredicate :: Trait ( x) => p!( print( x) ) ,
14771468 ty:: ExistentialPredicate :: Projection ( x) => p!( print( x) ) ,
14781469 ty:: ExistentialPredicate :: AutoTrait ( def_id) => {
1479- p!( print_def_path( def_id, None ) ) ;
1470+ p!( print_def_path( def_id, & [ ] ) ) ;
14801471 }
14811472 }
14821473 }
@@ -1509,7 +1500,7 @@ define_print_and_forward_display! {
15091500 }
15101501
15111502 ty:: TraitRef <' tcx> {
1512- p!( print_def_path( self . def_id, Some ( self . substs) ) ) ;
1503+ p!( print_def_path( self . def_id, self . substs) ) ;
15131504 }
15141505
15151506 ConstValue <' tcx> {
@@ -1553,7 +1544,7 @@ define_print_and_forward_display! {
15531544 }
15541545
15551546 ty:: ProjectionTy <' tcx> {
1556- p!( print_def_path( self . item_def_id, Some ( self . substs) ) ) ;
1547+ p!( print_def_path( self . item_def_id, self . substs) ) ;
15571548 }
15581549
15591550 ty:: ClosureKind {
@@ -1574,17 +1565,17 @@ define_print_and_forward_display! {
15741565 ty:: Predicate :: WellFormed ( ty) => p!( print( ty) , write( " well-formed" ) ) ,
15751566 ty:: Predicate :: ObjectSafe ( trait_def_id) => {
15761567 p!( write( "the trait `" ) ,
1577- print_def_path( trait_def_id, None ) ,
1568+ print_def_path( trait_def_id, & [ ] ) ,
15781569 write( "` is object-safe" ) )
15791570 }
15801571 ty:: Predicate :: ClosureKind ( closure_def_id, _closure_substs, kind) => {
15811572 p!( write( "the closure `" ) ,
1582- print_value_path( closure_def_id, None ) ,
1573+ print_value_path( closure_def_id, & [ ] ) ,
15831574 write( "` implements the trait `{}`" , kind) )
15841575 }
15851576 ty:: Predicate :: ConstEvaluatable ( def_id, substs) => {
15861577 p!( write( "the constant `" ) ,
1587- print_value_path( def_id, Some ( substs) ) ,
1578+ print_value_path( def_id, substs) ,
15881579 write( "` can be evaluated" ) )
15891580 }
15901581 }
0 commit comments