@@ -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, did : 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, did : 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 . did . 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
@@ -1365,8 +1366,12 @@ pub(crate) fn clean_middle_assoc_item<'tcx>(
1365
1366
tcx. generics_of ( assoc_item. def_id ) ,
1366
1367
tcx. explicit_predicates_of ( assoc_item. def_id ) ,
1367
1368
) ;
1368
- // FIXME: This does not place parameters in source order (late-bound ones come last)
1369
1369
generics. params . extend ( clean_bound_vars ( sig. bound_vars ( ) ) ) ;
1370
+ // FIXME(fmease): Does this work in the presence of synthetic params (impl-Trait, host effect)?
1371
+ // FIXME(fmease): Optimization: Don't call def_ident_span on non-lifetime params!
1372
+ if !sig. bound_vars ( ) . is_empty ( ) {
1373
+ generics. params . sort_by_key ( |param| tcx. def_ident_span ( param. did ) . unwrap ( ) ) ;
1374
+ }
1370
1375
1371
1376
let mut decl = clean_fn_decl_from_did_and_sig ( cx, Some ( assoc_item. def_id ) , sig) ;
1372
1377
@@ -2192,10 +2197,10 @@ pub(crate) fn clean_middle_ty<'tcx>(
2192
2197
. iter ( )
2193
2198
. flat_map ( |pred| pred. bound_vars ( ) )
2194
2199
. filter_map ( |var| match var {
2195
- ty:: BoundVariableKind :: Region ( ty:: BrNamed ( _ , name) )
2200
+ ty:: BoundVariableKind :: Region ( ty:: BrNamed ( did , name) )
2196
2201
if name != kw:: UnderscoreLifetime =>
2197
2202
{
2198
- Some ( GenericParamDef :: lifetime ( name) )
2203
+ Some ( GenericParamDef :: lifetime ( did , name) )
2199
2204
}
2200
2205
_ => None ,
2201
2206
} )
@@ -3167,15 +3172,15 @@ fn clean_bound_vars<'tcx>(
3167
3172
bound_vars
3168
3173
. into_iter ( )
3169
3174
. filter_map ( |var| match var {
3170
- ty:: BoundVariableKind :: Region ( ty:: BrNamed ( _ , name) )
3175
+ ty:: BoundVariableKind :: Region ( ty:: BrNamed ( did , name) )
3171
3176
if name != kw:: UnderscoreLifetime =>
3172
3177
{
3173
- Some ( GenericParamDef :: lifetime ( name) )
3178
+ Some ( GenericParamDef :: lifetime ( did , name) )
3174
3179
}
3175
3180
ty:: BoundVariableKind :: Ty ( ty:: BoundTyKind :: Param ( did, name) ) => Some ( GenericParamDef {
3176
3181
name,
3182
+ did,
3177
3183
kind : GenericParamDefKind :: Type {
3178
- did,
3179
3184
bounds : ThinVec :: new ( ) ,
3180
3185
default : None ,
3181
3186
synthetic : false ,
0 commit comments