@@ -523,7 +523,6 @@ fn clean_generic_param_def<'tcx>(
523
523
(
524
524
def. name ,
525
525
GenericParamDefKind :: Type {
526
- did : def. def_id ,
527
526
bounds : ThinVec :: new ( ) , // These are filled in from the where-clauses.
528
527
default : default. map ( Box :: new) ,
529
528
synthetic,
@@ -555,7 +554,7 @@ fn clean_generic_param_def<'tcx>(
555
554
) ,
556
555
} ;
557
556
558
- GenericParamDef { name, kind }
557
+ GenericParamDef { name, did : def . def_id , kind }
559
558
}
560
559
561
560
fn clean_generic_param < ' tcx > (
@@ -594,7 +593,6 @@ fn clean_generic_param<'tcx>(
594
593
(
595
594
param. name . ident ( ) . name ,
596
595
GenericParamDefKind :: Type {
597
- did : param. def_id . to_def_id ( ) ,
598
596
bounds,
599
597
default : default. map ( |t| clean_ty ( t, cx) ) . map ( Box :: new) ,
600
598
synthetic,
@@ -612,7 +610,7 @@ fn clean_generic_param<'tcx>(
612
610
) ,
613
611
} ;
614
612
615
- GenericParamDef { name, kind }
613
+ GenericParamDef { name, did : param . def_id . to_def_id ( ) , kind }
616
614
}
617
615
618
616
/// Synthetic type-parameters are inserted after normal ones.
@@ -644,8 +642,8 @@ pub(crate) fn clean_generics<'tcx>(
644
642
let param = clean_generic_param ( cx, Some ( gens) , param) ;
645
643
match param. kind {
646
644
GenericParamDefKind :: Lifetime { .. } => unreachable ! ( ) ,
647
- GenericParamDefKind :: Type { did , ref bounds, .. } => {
648
- cx. impl_trait_bounds . insert ( did. into ( ) , bounds. to_vec ( ) ) ;
645
+ GenericParamDefKind :: Type { ref bounds, .. } => {
646
+ cx. impl_trait_bounds . insert ( param . did . into ( ) , bounds. to_vec ( ) ) ;
649
647
}
650
648
GenericParamDefKind :: Const { .. } => unreachable ! ( ) ,
651
649
}
@@ -1062,8 +1060,11 @@ fn clean_fn_decl_legacy_const_generics(func: &mut Function, attrs: &[ast::Attrib
1062
1060
match literal. kind {
1063
1061
ast:: LitKind :: Int ( a, _) => {
1064
1062
let gen = func. generics . params . remove ( 0 ) ;
1065
- if let GenericParamDef { name, kind : GenericParamDefKind :: Const { ty, .. } } =
1066
- gen
1063
+ if let GenericParamDef {
1064
+ name,
1065
+ kind : GenericParamDefKind :: Const { ty, .. } ,
1066
+ ..
1067
+ } = gen
1067
1068
{
1068
1069
func. decl
1069
1070
. inputs
@@ -1167,7 +1168,7 @@ fn clean_fn_decl_with_args<'tcx>(
1167
1168
FnDecl { inputs : args, output, c_variadic : decl. c_variadic }
1168
1169
}
1169
1170
1170
- fn clean_fn_decl_from_did_and_sig < ' tcx > (
1171
+ fn clean_poly_fn_sig < ' tcx > (
1171
1172
cx : & mut DocContext < ' tcx > ,
1172
1173
did : Option < DefId > ,
1173
1174
sig : ty:: PolyFnSig < ' tcx > ,
@@ -1357,16 +1358,7 @@ pub(crate) fn clean_middle_assoc_item<'tcx>(
1357
1358
}
1358
1359
}
1359
1360
ty:: AssocKind :: Fn => {
1360
- let sig = tcx. fn_sig ( assoc_item. def_id ) . instantiate_identity ( ) ;
1361
- let mut generics = clean_ty_generics (
1362
- cx,
1363
- tcx. generics_of ( assoc_item. def_id ) ,
1364
- tcx. explicit_predicates_of ( assoc_item. def_id ) ,
1365
- ) ;
1366
- // FIXME: This does not place parameters in source order (late-bound ones come last)
1367
- generics. params . extend ( clean_bound_vars ( sig. bound_vars ( ) ) ) ;
1368
-
1369
- let mut decl = clean_fn_decl_from_did_and_sig ( cx, Some ( assoc_item. def_id ) , sig) ;
1361
+ let mut item = inline:: build_function ( cx, assoc_item. def_id ) ;
1370
1362
1371
1363
if assoc_item. fn_has_self_parameter {
1372
1364
let self_ty = match assoc_item. container {
@@ -1375,12 +1367,13 @@ pub(crate) fn clean_middle_assoc_item<'tcx>(
1375
1367
}
1376
1368
ty:: TraitContainer => tcx. types . self_param ,
1377
1369
} ;
1378
- let self_arg_ty = sig. input ( 0 ) . skip_binder ( ) ;
1370
+ let self_arg_ty =
1371
+ tcx. fn_sig ( assoc_item. def_id ) . instantiate_identity ( ) . input ( 0 ) . skip_binder ( ) ;
1379
1372
if self_arg_ty == self_ty {
1380
- decl. inputs . values [ 0 ] . type_ = Generic ( kw:: SelfUpper ) ;
1373
+ item . decl . inputs . values [ 0 ] . type_ = Generic ( kw:: SelfUpper ) ;
1381
1374
} else if let ty:: Ref ( _, ty, _) = * self_arg_ty. kind ( ) {
1382
1375
if ty == self_ty {
1383
- match decl. inputs . values [ 0 ] . type_ {
1376
+ match item . decl . inputs . values [ 0 ] . type_ {
1384
1377
BorrowedRef { ref mut type_, .. } => * * type_ = Generic ( kw:: SelfUpper ) ,
1385
1378
_ => unreachable ! ( ) ,
1386
1379
}
@@ -1397,9 +1390,9 @@ pub(crate) fn clean_middle_assoc_item<'tcx>(
1397
1390
ty:: ImplContainer => Some ( assoc_item. defaultness ( tcx) ) ,
1398
1391
ty:: TraitContainer => None ,
1399
1392
} ;
1400
- MethodItem ( Box :: new ( Function { generics , decl } ) , defaultness)
1393
+ MethodItem ( item , defaultness)
1401
1394
} else {
1402
- TyMethodItem ( Box :: new ( Function { generics , decl } ) )
1395
+ TyMethodItem ( item )
1403
1396
}
1404
1397
}
1405
1398
ty:: AssocKind :: Type => {
@@ -2083,7 +2076,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
2083
2076
ty:: FnDef ( ..) | ty:: FnPtr ( _) => {
2084
2077
// FIXME: should we merge the outer and inner binders somehow?
2085
2078
let sig = bound_ty. skip_binder ( ) . fn_sig ( cx. tcx ) ;
2086
- let decl = clean_fn_decl_from_did_and_sig ( cx, None , sig) ;
2079
+ let decl = clean_poly_fn_sig ( cx, None , sig) ;
2087
2080
let generic_params = clean_bound_vars ( sig. bound_vars ( ) ) ;
2088
2081
2089
2082
BareFunction ( Box :: new ( BareFunctionDecl {
@@ -2166,10 +2159,10 @@ pub(crate) fn clean_middle_ty<'tcx>(
2166
2159
. iter ( )
2167
2160
. flat_map ( |pred| pred. bound_vars ( ) )
2168
2161
. filter_map ( |var| match var {
2169
- ty:: BoundVariableKind :: Region ( ty:: BrNamed ( _ , name) )
2162
+ ty:: BoundVariableKind :: Region ( ty:: BrNamed ( did , name) )
2170
2163
if name != kw:: UnderscoreLifetime =>
2171
2164
{
2172
- Some ( GenericParamDef :: lifetime ( name) )
2165
+ Some ( GenericParamDef :: lifetime ( did , name) )
2173
2166
}
2174
2167
_ => None ,
2175
2168
} )
@@ -3141,15 +3134,15 @@ fn clean_bound_vars<'tcx>(
3141
3134
bound_vars
3142
3135
. into_iter ( )
3143
3136
. filter_map ( |var| match var {
3144
- ty:: BoundVariableKind :: Region ( ty:: BrNamed ( _ , name) )
3137
+ ty:: BoundVariableKind :: Region ( ty:: BrNamed ( did , name) )
3145
3138
if name != kw:: UnderscoreLifetime =>
3146
3139
{
3147
- Some ( GenericParamDef :: lifetime ( name) )
3140
+ Some ( GenericParamDef :: lifetime ( did , name) )
3148
3141
}
3149
3142
ty:: BoundVariableKind :: Ty ( ty:: BoundTyKind :: Param ( did, name) ) => Some ( GenericParamDef {
3150
3143
name,
3144
+ did,
3151
3145
kind : GenericParamDefKind :: Type {
3152
- did,
3153
3146
bounds : ThinVec :: new ( ) ,
3154
3147
default : None ,
3155
3148
synthetic : false ,
0 commit comments