@@ -19,7 +19,6 @@ use rustc_hir::LangItem;
1919use rustc_session:: config:: TrimmedDefPaths ;
2020use rustc_session:: cstore:: { ExternCrate , ExternCrateSource } ;
2121use rustc_session:: Limit ;
22- use rustc_span:: sym;
2322use rustc_span:: symbol:: { kw, Ident , Symbol } ;
2423use rustc_span:: FileNameDisplayPreference ;
2524use rustc_target:: abi:: Size ;
@@ -967,7 +966,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
967966 define_scoped_cx ! ( cx) ;
968967 // Get the (single) generic ty (the args) of this FnOnce trait ref.
969968 let generics = tcx. generics_of ( trait_ref. def_id ) ;
970- let own_args = generics. own_args_no_defaults ( tcx, trait_ref. args ) ;
969+ let ( own_args, _ ) = generics. own_args_no_defaults ( tcx, trait_ref. args ) ;
971970
972971 match ( entry. return_ty , own_args[ 0 ] . expect_ty ( ) ) {
973972 // We can only print `impl Fn() -> ()` if we have a tuple of args and we recorded
@@ -1033,7 +1032,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
10331032 p ! ( print( trait_ref. print_only_trait_name( ) ) ) ;
10341033
10351034 let generics = tcx. generics_of ( trait_ref. def_id ) ;
1036- let own_args = generics. own_args_no_defaults ( tcx, trait_ref. args ) ;
1035+ let ( own_args, _ ) = generics. own_args_no_defaults ( tcx, trait_ref. args ) ;
10371036
10381037 if !own_args. is_empty ( ) || !assoc_items. is_empty ( ) {
10391038 let mut first = true ;
@@ -1185,6 +1184,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
11851184 )
11861185 } ,
11871186 & alias_ty. args [ 1 ..] ,
1187+ & self . tcx ( ) . generics_of ( alias_ty. def_id ) . params ,
11881188 )
11891189 }
11901190
@@ -1233,7 +1233,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
12331233 let dummy_cx = Ty :: new_fresh ( cx. tcx ( ) , 0 ) ;
12341234 let principal = principal. with_self_ty ( cx. tcx ( ) , dummy_cx) ;
12351235
1236- let args = cx
1236+ let ( args, _ ) = cx
12371237 . tcx ( )
12381238 . generics_of ( principal. def_id )
12391239 . own_args_no_defaults ( cx. tcx ( ) , principal. args ) ;
@@ -2031,40 +2031,26 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> {
20312031 & mut self ,
20322032 print_prefix : impl FnOnce ( & mut Self ) -> Result < ( ) , PrintError > ,
20332033 args : & [ GenericArg < ' tcx > ] ,
2034+ params : & [ ty:: GenericParamDef ] ,
20342035 ) -> Result < ( ) , PrintError > {
20352036 print_prefix ( self ) ?;
20362037
20372038 let tcx = self . tcx ;
2038-
2039- let args = args. iter ( ) . copied ( ) ;
2040-
2041- let args: Vec < _ > = if !tcx. sess . verbose ( ) {
2042- // skip host param as those are printed as `~const`
2043- args. filter ( |arg| match arg. unpack ( ) {
2044- // FIXME(effects) there should be a better way than just matching the name
2045- GenericArgKind :: Const ( c)
2046- if tcx. features ( ) . effects
2047- && matches ! (
2048- c. kind( ) ,
2049- ty:: ConstKind :: Param ( ty:: ParamConst { name: sym:: host, .. } )
2050- ) =>
2051- {
2052- false
2053- }
2054- _ => true ,
2055- } )
2056- . collect ( )
2057- } else {
2039+ let verbose = tcx. sess . verbose ( ) ;
2040+ let mut args = args
2041+ . iter ( )
2042+ . copied ( )
2043+ . zip ( params)
20582044 // If -Zverbose is passed, we should print the host parameter instead
20592045 // of eating it.
2060- args . collect ( )
2061- } ;
2046+ . filter ( | ( _ , param ) | verbose || !param . is_host_effect ( ) )
2047+ . peekable ( ) ;
20622048
2063- if ! args. is_empty ( ) {
2049+ if args. peek ( ) . is_some ( ) {
20642050 if self . in_value {
20652051 write ! ( self , "::" ) ?;
20662052 }
2067- self . generic_delimiters ( |cx| cx. comma_sep ( args. into_iter ( ) ) )
2053+ self . generic_delimiters ( |cx| cx. comma_sep ( args. map ( | ( arg , _ ) | arg ) ) )
20682054 } else {
20692055 Ok ( ( ) )
20702056 }
@@ -2894,11 +2880,15 @@ define_print_and_forward_display! {
28942880 }
28952881
28962882 TraitPredPrintModifiersAndPath <' tcx> {
2897- // FIXME(effects) print `~const` here
2883+ if let Some ( idx) = cx. tcx( ) . generics_of( self . 0 . trait_ref. def_id) . host_effect_index
2884+ {
2885+ if self . 0 . trait_ref. args. const_at( idx) != cx. tcx( ) . consts. true_ {
2886+ p!( "~const " ) ;
2887+ }
2888+ }
28982889 if let ty:: ImplPolarity :: Negative = self . 0 . polarity {
28992890 p!( "!" )
29002891 }
2901-
29022892 p!( print( self . 0 . trait_ref. print_only_trait_path( ) ) ) ;
29032893 }
29042894
@@ -2933,7 +2923,6 @@ define_print_and_forward_display! {
29332923 p!( "~const " ) ;
29342924 }
29352925 }
2936- // FIXME(effects) print `~const` here
29372926 if let ty:: ImplPolarity :: Negative = self . polarity {
29382927 p!( "!" ) ;
29392928 }
0 commit comments