@@ -19,6 +19,7 @@ use rustc_hir::LangItem;
1919use rustc_session:: config:: TrimmedDefPaths ;
2020use rustc_session:: cstore:: { ExternCrate , ExternCrateSource } ;
2121use rustc_session:: Limit ;
22+ use rustc_span:: sym;
2223use rustc_span:: symbol:: { kw, Ident , Symbol } ;
2324use rustc_span:: FileNameDisplayPreference ;
2425use rustc_target:: abi:: Size ;
@@ -966,7 +967,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
966967 define_scoped_cx ! ( cx) ;
967968 // Get the (single) generic ty (the args) of this FnOnce trait ref.
968969 let generics = tcx. generics_of ( trait_ref. def_id ) ;
969- let ( own_args, _ ) = generics. own_args_no_defaults ( tcx, trait_ref. args ) ;
970+ let own_args = generics. own_args_no_defaults ( tcx, trait_ref. args ) ;
970971
971972 match ( entry. return_ty , own_args[ 0 ] . expect_ty ( ) ) {
972973 // We can only print `impl Fn() -> ()` if we have a tuple of args and we recorded
@@ -1032,7 +1033,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
10321033 p ! ( print( trait_ref. print_only_trait_name( ) ) ) ;
10331034
10341035 let generics = tcx. generics_of ( trait_ref. def_id ) ;
1035- let ( own_args, _ ) = generics. own_args_no_defaults ( tcx, trait_ref. args ) ;
1036+ let own_args = generics. own_args_no_defaults ( tcx, trait_ref. args ) ;
10361037
10371038 if !own_args. is_empty ( ) || !assoc_items. is_empty ( ) {
10381039 let mut first = true ;
@@ -1184,7 +1185,6 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
11841185 )
11851186 } ,
11861187 & 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,26 +2031,40 @@ 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 ] ,
20352034 ) -> Result < ( ) , PrintError > {
20362035 print_prefix ( self ) ?;
20372036
20382037 let tcx = self . tcx ;
2039- let verbose = tcx. sess . verbose ( ) ;
2040- let mut args = args
2041- . iter ( )
2042- . copied ( )
2043- . zip ( params)
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 {
20442058 // If -Zverbose is passed, we should print the host parameter instead
20452059 // of eating it.
2046- . filter ( | ( _ , param ) | verbose || !param . is_host_effect ( ) )
2047- . peekable ( ) ;
2060+ args . collect ( )
2061+ } ;
20482062
2049- if args. peek ( ) . is_some ( ) {
2063+ if ! args. is_empty ( ) {
20502064 if self . in_value {
20512065 write ! ( self , "::" ) ?;
20522066 }
2053- self . generic_delimiters ( |cx| cx. comma_sep ( args. map ( | ( arg , _ ) | arg ) ) )
2067+ self . generic_delimiters ( |cx| cx. comma_sep ( args. into_iter ( ) ) )
20542068 } else {
20552069 Ok ( ( ) )
20562070 }
0 commit comments