@@ -19,6 +19,7 @@ use rustc_hir::LangItem;
19
19
use rustc_session:: config:: TrimmedDefPaths ;
20
20
use rustc_session:: cstore:: { ExternCrate , ExternCrateSource } ;
21
21
use rustc_session:: Limit ;
22
+ use rustc_span:: sym;
22
23
use rustc_span:: symbol:: { kw, Ident , Symbol } ;
23
24
use rustc_span:: FileNameDisplayPreference ;
24
25
use rustc_target:: abi:: Size ;
@@ -966,7 +967,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
966
967
define_scoped_cx ! ( cx) ;
967
968
// Get the (single) generic ty (the args) of this FnOnce trait ref.
968
969
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 ) ;
970
971
971
972
match ( entry. return_ty , own_args[ 0 ] . expect_ty ( ) ) {
972
973
// 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 {
1032
1033
p ! ( print( trait_ref. print_only_trait_name( ) ) ) ;
1033
1034
1034
1035
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 ) ;
1036
1037
1037
1038
if !own_args. is_empty ( ) || !assoc_items. is_empty ( ) {
1038
1039
let mut first = true ;
@@ -1184,7 +1185,6 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
1184
1185
)
1185
1186
} ,
1186
1187
& alias_ty. args [ 1 ..] ,
1187
- & self . tcx ( ) . generics_of ( alias_ty. def_id ) . params ,
1188
1188
)
1189
1189
}
1190
1190
@@ -1233,7 +1233,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
1233
1233
let dummy_cx = Ty :: new_fresh ( cx. tcx ( ) , 0 ) ;
1234
1234
let principal = principal. with_self_ty ( cx. tcx ( ) , dummy_cx) ;
1235
1235
1236
- let ( args, _ ) = cx
1236
+ let args = cx
1237
1237
. tcx ( )
1238
1238
. generics_of ( principal. def_id )
1239
1239
. own_args_no_defaults ( cx. tcx ( ) , principal. args ) ;
@@ -2031,26 +2031,40 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> {
2031
2031
& mut self ,
2032
2032
print_prefix : impl FnOnce ( & mut Self ) -> Result < ( ) , PrintError > ,
2033
2033
args : & [ GenericArg < ' tcx > ] ,
2034
- params : & [ ty:: GenericParamDef ] ,
2035
2034
) -> Result < ( ) , PrintError > {
2036
2035
print_prefix ( self ) ?;
2037
2036
2038
2037
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 {
2044
2058
// If -Zverbose is passed, we should print the host parameter instead
2045
2059
// of eating it.
2046
- . filter ( | ( _ , param ) | verbose || !param . is_host_effect ( ) )
2047
- . peekable ( ) ;
2060
+ args . collect ( )
2061
+ } ;
2048
2062
2049
- if args. peek ( ) . is_some ( ) {
2063
+ if ! args. is_empty ( ) {
2050
2064
if self . in_value {
2051
2065
write ! ( self , "::" ) ?;
2052
2066
}
2053
- self . generic_delimiters ( |cx| cx. comma_sep ( args. map ( | ( arg , _ ) | arg ) ) )
2067
+ self . generic_delimiters ( |cx| cx. comma_sep ( args. into_iter ( ) ) )
2054
2068
} else {
2055
2069
Ok ( ( ) )
2056
2070
}
0 commit comments