@@ -348,15 +348,13 @@ where
348
348
fn make_final_bounds (
349
349
& self ,
350
350
ty_to_bounds : FxHashMap < Type , FxHashSet < GenericBound > > ,
351
- ty_to_fn : FxHashMap < Type , ( Option < PolyTrait > , Option < Type > ) > ,
351
+ ty_to_fn : FxHashMap < Type , ( PolyTrait , Option < Type > ) > ,
352
352
lifetime_to_bounds : FxHashMap < Lifetime , FxHashSet < GenericBound > > ,
353
353
) -> Vec < WherePredicate > {
354
354
ty_to_bounds
355
355
. into_iter ( )
356
356
. flat_map ( |( ty, mut bounds) | {
357
- if let Some ( data) = ty_to_fn. get ( & ty) {
358
- let ( poly_trait, output) =
359
- ( data. 0 . as_ref ( ) . unwrap ( ) . clone ( ) , data. 1 . as_ref ( ) . cloned ( ) . map ( Box :: new) ) ;
357
+ if let Some ( ( ref poly_trait, ref output) ) = ty_to_fn. get ( & ty) {
360
358
let mut new_path = poly_trait. trait_ . clone ( ) ;
361
359
let last_segment = new_path. segments . pop ( ) . expect ( "segments were empty" ) ;
362
360
@@ -374,8 +372,9 @@ where
374
372
GenericArgs :: Parenthesized { inputs, output } => ( inputs, output) ,
375
373
} ;
376
374
375
+ let output = output. as_ref ( ) . cloned ( ) . map ( Box :: new) ;
377
376
if old_output. is_some ( ) && old_output != output {
378
- panic ! ( "Output mismatch for {:?} {:?} {:?}" , ty, old_output, data . 1 ) ;
377
+ panic ! ( "Output mismatch for {:?} {:?} {:?}" , ty, old_output, output ) ;
379
378
}
380
379
381
380
let new_params = GenericArgs :: Parenthesized { inputs : old_input, output } ;
@@ -385,7 +384,10 @@ where
385
384
. push ( PathSegment { name : last_segment. name , args : new_params } ) ;
386
385
387
386
bounds. insert ( GenericBound :: TraitBound (
388
- PolyTrait { trait_ : new_path, generic_params : poly_trait. generic_params } ,
387
+ PolyTrait {
388
+ trait_ : new_path,
389
+ generic_params : poly_trait. generic_params . clone ( ) ,
390
+ } ,
389
391
hir:: TraitBoundModifier :: None ,
390
392
) ) ;
391
393
}
@@ -471,7 +473,7 @@ where
471
473
let mut lifetime_to_bounds: FxHashMap < _ , FxHashSet < _ > > = Default :: default ( ) ;
472
474
let mut ty_to_traits: FxHashMap < Type , FxHashSet < Path > > = Default :: default ( ) ;
473
475
474
- let mut ty_to_fn: FxHashMap < Type , ( Option < PolyTrait > , Option < Type > ) > = Default :: default ( ) ;
476
+ let mut ty_to_fn: FxHashMap < Type , ( PolyTrait , Option < Type > ) > = Default :: default ( ) ;
475
477
476
478
for p in clean_where_predicates {
477
479
let ( orig_p, p) = ( p, p. clean ( self . cx ) ) ;
@@ -535,8 +537,8 @@ where
535
537
if is_fn {
536
538
ty_to_fn
537
539
. entry ( ty. clone ( ) )
538
- . and_modify ( |e| * e = ( Some ( poly_trait. clone ( ) ) , e. 1 . clone ( ) ) )
539
- . or_insert ( ( ( Some ( poly_trait. clone ( ) ) ) , None ) ) ;
540
+ . and_modify ( |e| * e = ( poly_trait. clone ( ) , e. 1 . clone ( ) ) )
541
+ . or_insert ( ( ( poly_trait. clone ( ) ) , None ) ) ;
540
542
541
543
ty_to_bounds. entry ( ty. clone ( ) ) . or_default ( ) ;
542
544
} else {
@@ -559,7 +561,13 @@ where
559
561
. and_modify ( |e| {
560
562
* e = ( e. 0 . clone ( ) , Some ( rhs. ty ( ) . unwrap ( ) . clone ( ) ) )
561
563
} )
562
- . or_insert ( ( None , Some ( rhs. ty ( ) . unwrap ( ) . clone ( ) ) ) ) ;
564
+ . or_insert ( (
565
+ PolyTrait {
566
+ trait_ : trait_. clone ( ) ,
567
+ generic_params : Vec :: new ( ) ,
568
+ } ,
569
+ Some ( rhs. ty ( ) . unwrap ( ) . clone ( ) ) ,
570
+ ) ) ;
563
571
continue ;
564
572
}
565
573
0 commit comments