@@ -112,7 +112,6 @@ pub(crate) fn clean_middle_generic_args<'tcx>(
112
112
return None ;
113
113
}
114
114
115
- // Elide internal host effect args.
116
115
let param = generics. param_at ( index, cx. tcx ) ;
117
116
let arg = ty:: Binder :: bind_with_vars ( arg, bound_vars) ;
118
117
@@ -201,35 +200,30 @@ fn clean_middle_generic_args_with_constraints<'tcx>(
201
200
cx : & mut DocContext < ' tcx > ,
202
201
did : DefId ,
203
202
has_self : bool ,
204
- constraints : ThinVec < AssocItemConstraint > ,
205
- ty_args : ty:: Binder < ' tcx , GenericArgsRef < ' tcx > > ,
203
+ mut constraints : ThinVec < AssocItemConstraint > ,
204
+ args : ty:: Binder < ' tcx , GenericArgsRef < ' tcx > > ,
206
205
) -> GenericArgs {
207
- let args = clean_middle_generic_args ( cx, ty_args. map_bound ( |args| & args[ ..] ) , has_self, did) ;
208
-
209
- if cx. tcx . is_trait ( did) && cx. tcx . trait_def ( did) . paren_sugar {
210
- let ty = ty_args
206
+ if cx. tcx . is_trait ( did)
207
+ && cx. tcx . trait_def ( did) . paren_sugar
208
+ && let ty:: Tuple ( tys) = args. skip_binder ( ) . type_at ( has_self as usize ) . kind ( )
209
+ {
210
+ let inputs = tys
211
211
. iter ( )
212
- . nth ( if has_self { 1 } else { 0 } )
213
- . unwrap ( )
214
- . map_bound ( |arg| arg. expect_ty ( ) ) ;
215
- let inputs =
216
- // The trait's first substitution is the one after self, if there is one.
217
- match ty. skip_binder ( ) . kind ( ) {
218
- ty:: Tuple ( tys) => tys. iter ( ) . map ( |t| clean_middle_ty ( ty. rebind ( t) , cx, None , None ) ) . collect :: < Vec < _ > > ( ) . into ( ) ,
219
- _ => return GenericArgs :: AngleBracketed { args : args. into ( ) , constraints } ,
220
- } ;
221
- let output = constraints. into_iter ( ) . next ( ) . and_then ( |binding| match binding. kind {
222
- AssocItemConstraintKind :: Equality { term : Term :: Type ( ty) }
223
- if ty != Type :: Tuple ( Vec :: new ( ) ) =>
224
- {
212
+ . map ( |ty| clean_middle_ty ( args. rebind ( ty) , cx, None , None ) )
213
+ . collect :: < Vec < _ > > ( )
214
+ . into ( ) ;
215
+ let output = constraints. pop ( ) . and_then ( |constraint| match constraint. kind {
216
+ AssocItemConstraintKind :: Equality { term : Term :: Type ( ty) } if !ty. is_unit ( ) => {
225
217
Some ( Box :: new ( ty) )
226
218
}
227
219
_ => None ,
228
220
} ) ;
229
- GenericArgs :: Parenthesized { inputs, output }
230
- } else {
231
- GenericArgs :: AngleBracketed { args : args. into ( ) , constraints }
221
+ return GenericArgs :: Parenthesized { inputs, output } ;
232
222
}
223
+
224
+ let args = clean_middle_generic_args ( cx, args. map_bound ( |args| & args[ ..] ) , has_self, did) ;
225
+
226
+ GenericArgs :: AngleBracketed { args : args. into ( ) , constraints }
233
227
}
234
228
235
229
pub ( super ) fn clean_middle_path < ' tcx > (
0 commit comments