@@ -75,13 +75,13 @@ pub(crate) fn krate(cx: &mut DocContext<'_>) -> Crate {
7575 Crate { module, external_traits : cx. external_traits . clone ( ) }
7676}
7777
78- pub ( crate ) fn ty_args_to_args < ' tcx > (
78+ pub ( crate ) fn clean_middle_generic_args < ' tcx > (
7979 cx : & mut DocContext < ' tcx > ,
80- ty_args : ty:: Binder < ' tcx , & ' tcx [ ty:: GenericArg < ' tcx > ] > ,
80+ args : ty:: Binder < ' tcx , & ' tcx [ ty:: GenericArg < ' tcx > ] > ,
8181 has_self : bool ,
8282 owner : DefId ,
8383) -> Vec < GenericArg > {
84- if ty_args . skip_binder ( ) . is_empty ( ) {
84+ if args . skip_binder ( ) . is_empty ( ) {
8585 // Fast path which avoids executing the query `generics_of`.
8686 return Vec :: new ( ) ;
8787 }
@@ -90,9 +90,9 @@ pub(crate) fn ty_args_to_args<'tcx>(
9090 let mut elision_has_failed_once_before = false ;
9191
9292 let offset = if has_self { 1 } else { 0 } ;
93- let mut args = Vec :: with_capacity ( ty_args . skip_binder ( ) . len ( ) . saturating_sub ( offset) ) ;
93+ let mut clean_args = Vec :: with_capacity ( args . skip_binder ( ) . len ( ) . saturating_sub ( offset) ) ;
9494
95- let ty_arg_to_arg = |( index, arg) : ( usize , & ty:: GenericArg < ' tcx > ) | match arg. unpack ( ) {
95+ let clean_arg = |( index, arg) : ( usize , & ty:: GenericArg < ' tcx > ) | match arg. unpack ( ) {
9696 GenericArgKind :: Lifetime ( lt) => {
9797 Some ( GenericArg :: Lifetime ( clean_middle_region ( lt) . unwrap_or ( Lifetime :: elided ( ) ) ) )
9898 }
@@ -101,26 +101,20 @@ pub(crate) fn ty_args_to_args<'tcx>(
101101 if !elision_has_failed_once_before
102102 && let Some ( default) = params[ index] . default_value ( cx. tcx )
103103 {
104- let default =
105- ty_args. map_bound ( |args| default. instantiate ( cx. tcx , args) . expect_ty ( ) ) ;
104+ let default = args. map_bound ( |args| default. instantiate ( cx. tcx , args) . expect_ty ( ) ) ;
106105
107- if can_elide_generic_arg ( ty_args . rebind ( ty) , default) {
106+ if can_elide_generic_arg ( args . rebind ( ty) , default) {
108107 return None ;
109108 }
110109
111110 elision_has_failed_once_before = true ;
112111 }
113112
114113 Some ( GenericArg :: Type ( clean_middle_ty (
115- ty_args . rebind ( ty) ,
114+ args . rebind ( ty) ,
116115 cx,
117116 None ,
118- Some ( crate :: clean:: ContainerTy :: Regular {
119- ty : owner,
120- args : ty_args,
121- has_self,
122- arg : index,
123- } ) ,
117+ Some ( crate :: clean:: ContainerTy :: Regular { ty : owner, args, has_self, arg : index } ) ,
124118 ) ) )
125119 }
126120 GenericArgKind :: Const ( ct) => {
@@ -133,22 +127,22 @@ pub(crate) fn ty_args_to_args<'tcx>(
133127 && let Some ( default) = params[ index] . default_value ( cx. tcx )
134128 {
135129 let default =
136- ty_args . map_bound ( |args| default. instantiate ( cx. tcx , args) . expect_const ( ) ) ;
130+ args . map_bound ( |args| default. instantiate ( cx. tcx , args) . expect_const ( ) ) ;
137131
138- if can_elide_generic_arg ( ty_args . rebind ( ct) , default) {
132+ if can_elide_generic_arg ( args . rebind ( ct) , default) {
139133 return None ;
140134 }
141135
142136 elision_has_failed_once_before = true ;
143137 }
144138
145- Some ( GenericArg :: Const ( Box :: new ( clean_middle_const ( ty_args . rebind ( ct) , cx) ) ) )
139+ Some ( GenericArg :: Const ( Box :: new ( clean_middle_const ( args . rebind ( ct) , cx) ) ) )
146140 }
147141 } ;
148142
149- args . extend ( ty_args . skip_binder ( ) . iter ( ) . enumerate ( ) . rev ( ) . filter_map ( ty_arg_to_arg ) ) ;
150- args . reverse ( ) ;
151- args
143+ clean_args . extend ( args . skip_binder ( ) . iter ( ) . enumerate ( ) . rev ( ) . filter_map ( clean_arg ) ) ;
144+ clean_args . reverse ( ) ;
145+ clean_args
152146}
153147
154148/// Check if the generic argument `actual` coincides with the `default` and can therefore be elided.
@@ -192,14 +186,14 @@ where
192186 actual. skip_binder ( ) == default. skip_binder ( )
193187}
194188
195- fn external_generic_args < ' tcx > (
189+ fn clean_middle_generic_args_with_bindings < ' tcx > (
196190 cx : & mut DocContext < ' tcx > ,
197191 did : DefId ,
198192 has_self : bool ,
199193 bindings : ThinVec < TypeBinding > ,
200194 ty_args : ty:: Binder < ' tcx , GenericArgsRef < ' tcx > > ,
201195) -> GenericArgs {
202- let args = ty_args_to_args ( cx, ty_args. map_bound ( |args| & args[ ..] ) , has_self, did) ;
196+ let args = clean_middle_generic_args ( cx, ty_args. map_bound ( |args| & args[ ..] ) , has_self, did) ;
203197
204198 if cx. tcx . fn_trait_kind_from_def_id ( did) . is_some ( ) {
205199 let ty = ty_args
@@ -225,7 +219,7 @@ fn external_generic_args<'tcx>(
225219 }
226220}
227221
228- pub ( super ) fn external_path < ' tcx > (
222+ pub ( super ) fn clean_middle_path < ' tcx > (
229223 cx : & mut DocContext < ' tcx > ,
230224 did : DefId ,
231225 has_self : bool ,
@@ -238,7 +232,7 @@ pub(super) fn external_path<'tcx>(
238232 res : Res :: Def ( def_kind, did) ,
239233 segments : thin_vec ! [ PathSegment {
240234 name,
241- args: external_generic_args ( cx, did, has_self, bindings, args) ,
235+ args: clean_middle_generic_args_with_bindings ( cx, did, has_self, bindings, args) ,
242236 } ] ,
243237 }
244238}
0 commit comments