@@ -525,7 +525,6 @@ fn clean_generic_param_def<'tcx>(
525
525
(
526
526
def. name ,
527
527
GenericParamDefKind :: Type {
528
- did : def. def_id ,
529
528
bounds : ThinVec :: new ( ) , // These are filled in from the where-clauses.
530
529
default : default. map ( Box :: new) ,
531
530
synthetic,
@@ -557,7 +556,7 @@ fn clean_generic_param_def<'tcx>(
557
556
) ,
558
557
} ;
559
558
560
- GenericParamDef { name, kind }
559
+ GenericParamDef { name, def_id : def . def_id , kind }
561
560
}
562
561
563
562
fn clean_generic_param < ' tcx > (
@@ -596,7 +595,6 @@ fn clean_generic_param<'tcx>(
596
595
(
597
596
param. name . ident ( ) . name ,
598
597
GenericParamDefKind :: Type {
599
- did : param. def_id . to_def_id ( ) ,
600
598
bounds,
601
599
default : default. map ( |t| clean_ty ( t, cx) ) . map ( Box :: new) ,
602
600
synthetic,
@@ -614,7 +612,7 @@ fn clean_generic_param<'tcx>(
614
612
) ,
615
613
} ;
616
614
617
- GenericParamDef { name, kind }
615
+ GenericParamDef { name, def_id : param . def_id . to_def_id ( ) , kind }
618
616
}
619
617
620
618
/// Synthetic type-parameters are inserted after normal ones.
@@ -646,8 +644,8 @@ pub(crate) fn clean_generics<'tcx>(
646
644
let param = clean_generic_param ( cx, Some ( gens) , param) ;
647
645
match param. kind {
648
646
GenericParamDefKind :: Lifetime { .. } => unreachable ! ( ) ,
649
- GenericParamDefKind :: Type { did , ref bounds, .. } => {
650
- cx. impl_trait_bounds . insert ( did . into ( ) , bounds. to_vec ( ) ) ;
647
+ GenericParamDefKind :: Type { ref bounds, .. } => {
648
+ cx. impl_trait_bounds . insert ( param . def_id . into ( ) , bounds. to_vec ( ) ) ;
651
649
}
652
650
GenericParamDefKind :: Const { .. } => unreachable ! ( ) ,
653
651
}
@@ -1064,8 +1062,11 @@ fn clean_fn_decl_legacy_const_generics(func: &mut Function, attrs: &[ast::Attrib
1064
1062
match literal. kind {
1065
1063
ast:: LitKind :: Int ( a, _) => {
1066
1064
let gen = func. generics . params . remove ( 0 ) ;
1067
- if let GenericParamDef { name, kind : GenericParamDefKind :: Const { ty, .. } } =
1068
- gen
1065
+ if let GenericParamDef {
1066
+ name,
1067
+ kind : GenericParamDefKind :: Const { ty, .. } ,
1068
+ ..
1069
+ } = gen
1069
1070
{
1070
1071
func. decl
1071
1072
. inputs
@@ -1169,7 +1170,7 @@ fn clean_fn_decl_with_args<'tcx>(
1169
1170
FnDecl { inputs : args, output, c_variadic : decl. c_variadic }
1170
1171
}
1171
1172
1172
- fn clean_fn_decl_from_did_and_sig < ' tcx > (
1173
+ fn clean_poly_fn_sig < ' tcx > (
1173
1174
cx : & mut DocContext < ' tcx > ,
1174
1175
did : Option < DefId > ,
1175
1176
sig : ty:: PolyFnSig < ' tcx > ,
@@ -1359,16 +1360,7 @@ pub(crate) fn clean_middle_assoc_item<'tcx>(
1359
1360
}
1360
1361
}
1361
1362
ty:: AssocKind :: Fn => {
1362
- let sig = tcx. fn_sig ( assoc_item. def_id ) . instantiate_identity ( ) ;
1363
- let mut generics = clean_ty_generics (
1364
- cx,
1365
- tcx. generics_of ( assoc_item. def_id ) ,
1366
- tcx. explicit_predicates_of ( assoc_item. def_id ) ,
1367
- ) ;
1368
- // FIXME: This does not place parameters in source order (late-bound ones come last)
1369
- generics. params . extend ( clean_bound_vars ( sig. bound_vars ( ) ) ) ;
1370
-
1371
- let mut decl = clean_fn_decl_from_did_and_sig ( cx, Some ( assoc_item. def_id ) , sig) ;
1363
+ let mut item = inline:: build_function ( cx, assoc_item. def_id ) ;
1372
1364
1373
1365
if assoc_item. fn_has_self_parameter {
1374
1366
let self_ty = match assoc_item. container {
@@ -1377,12 +1369,13 @@ pub(crate) fn clean_middle_assoc_item<'tcx>(
1377
1369
}
1378
1370
ty:: TraitContainer => tcx. types . self_param ,
1379
1371
} ;
1380
- let self_arg_ty = sig. input ( 0 ) . skip_binder ( ) ;
1372
+ let self_arg_ty =
1373
+ tcx. fn_sig ( assoc_item. def_id ) . instantiate_identity ( ) . input ( 0 ) . skip_binder ( ) ;
1381
1374
if self_arg_ty == self_ty {
1382
- decl. inputs . values [ 0 ] . type_ = Generic ( kw:: SelfUpper ) ;
1375
+ item . decl . inputs . values [ 0 ] . type_ = Generic ( kw:: SelfUpper ) ;
1383
1376
} else if let ty:: Ref ( _, ty, _) = * self_arg_ty. kind ( ) {
1384
1377
if ty == self_ty {
1385
- match decl. inputs . values [ 0 ] . type_ {
1378
+ match item . decl . inputs . values [ 0 ] . type_ {
1386
1379
BorrowedRef { ref mut type_, .. } => * * type_ = Generic ( kw:: SelfUpper ) ,
1387
1380
_ => unreachable ! ( ) ,
1388
1381
}
@@ -1399,9 +1392,9 @@ pub(crate) fn clean_middle_assoc_item<'tcx>(
1399
1392
ty:: ImplContainer => Some ( assoc_item. defaultness ( tcx) ) ,
1400
1393
ty:: TraitContainer => None ,
1401
1394
} ;
1402
- MethodItem ( Box :: new ( Function { generics , decl } ) , defaultness)
1395
+ MethodItem ( item , defaultness)
1403
1396
} else {
1404
- TyMethodItem ( Box :: new ( Function { generics , decl } ) )
1397
+ TyMethodItem ( item )
1405
1398
}
1406
1399
}
1407
1400
ty:: AssocKind :: Type => {
@@ -2109,7 +2102,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
2109
2102
ty:: FnDef ( ..) | ty:: FnPtr ( _) => {
2110
2103
// FIXME: should we merge the outer and inner binders somehow?
2111
2104
let sig = bound_ty. skip_binder ( ) . fn_sig ( cx. tcx ) ;
2112
- let decl = clean_fn_decl_from_did_and_sig ( cx, None , sig) ;
2105
+ let decl = clean_poly_fn_sig ( cx, None , sig) ;
2113
2106
let generic_params = clean_bound_vars ( sig. bound_vars ( ) ) ;
2114
2107
2115
2108
BareFunction ( Box :: new ( BareFunctionDecl {
@@ -2192,10 +2185,10 @@ pub(crate) fn clean_middle_ty<'tcx>(
2192
2185
. iter ( )
2193
2186
. flat_map ( |pred| pred. bound_vars ( ) )
2194
2187
. filter_map ( |var| match var {
2195
- ty:: BoundVariableKind :: Region ( ty:: BrNamed ( _ , name) )
2188
+ ty:: BoundVariableKind :: Region ( ty:: BrNamed ( def_id , name) )
2196
2189
if name != kw:: UnderscoreLifetime =>
2197
2190
{
2198
- Some ( GenericParamDef :: lifetime ( name) )
2191
+ Some ( GenericParamDef :: lifetime ( def_id , name) )
2199
2192
}
2200
2193
_ => None ,
2201
2194
} )
@@ -3167,20 +3160,22 @@ fn clean_bound_vars<'tcx>(
3167
3160
bound_vars
3168
3161
. into_iter ( )
3169
3162
. filter_map ( |var| match var {
3170
- ty:: BoundVariableKind :: Region ( ty:: BrNamed ( _ , name) )
3163
+ ty:: BoundVariableKind :: Region ( ty:: BrNamed ( def_id , name) )
3171
3164
if name != kw:: UnderscoreLifetime =>
3172
3165
{
3173
- Some ( GenericParamDef :: lifetime ( name) )
3166
+ Some ( GenericParamDef :: lifetime ( def_id, name) )
3167
+ }
3168
+ ty:: BoundVariableKind :: Ty ( ty:: BoundTyKind :: Param ( def_id, name) ) => {
3169
+ Some ( GenericParamDef {
3170
+ name,
3171
+ def_id,
3172
+ kind : GenericParamDefKind :: Type {
3173
+ bounds : ThinVec :: new ( ) ,
3174
+ default : None ,
3175
+ synthetic : false ,
3176
+ } ,
3177
+ } )
3174
3178
}
3175
- ty:: BoundVariableKind :: Ty ( ty:: BoundTyKind :: Param ( did, name) ) => Some ( GenericParamDef {
3176
- name,
3177
- kind : GenericParamDefKind :: Type {
3178
- did,
3179
- bounds : ThinVec :: new ( ) ,
3180
- default : None ,
3181
- synthetic : false ,
3182
- } ,
3183
- } ) ,
3184
3179
// FIXME(non_lifetime_binders): Support higher-ranked const parameters.
3185
3180
ty:: BoundVariableKind :: Const => None ,
3186
3181
_ => None ,
0 commit comments