@@ -586,17 +586,12 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
586
586
// for the former and let type inference do the rest.
587
587
let coerce_target = self . next_ty_var ( self . cause . span ) ;
588
588
589
- let mut coercion = match reborrow {
590
- None => {
591
- self . unify_and ( coerce_target, target, [ ] , Adjust :: Pointer ( PointerCoercion :: Unsize ) ) ?
592
- }
593
- Some ( ( ref deref, ref autoref) ) => self . unify_and (
594
- coerce_target,
595
- target,
596
- [ deref. clone ( ) , autoref. clone ( ) ] ,
597
- Adjust :: Pointer ( PointerCoercion :: Unsize ) ,
598
- ) ?,
599
- } ;
589
+ let mut coercion = self . unify_and (
590
+ coerce_target,
591
+ target,
592
+ reborrow. into_iter ( ) . flat_map ( |( deref, autoref) | [ deref, autoref] ) ,
593
+ Adjust :: Pointer ( PointerCoercion :: Unsize ) ,
594
+ ) ?;
600
595
601
596
let mut selcx = traits:: SelectionContext :: new ( self ) ;
602
597
@@ -836,20 +831,13 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
836
831
&& hdr_b. safety . is_unsafe ( )
837
832
{
838
833
let unsafe_a = self . tcx . safe_to_unsafe_fn_ty ( fn_ty_a) ;
839
- match adjustment {
840
- Some ( kind) => self . unify_and (
841
- unsafe_a,
842
- b,
843
- [ Adjustment { kind, target : Ty :: new_fn_ptr ( self . tcx , fn_ty_a) } ] ,
844
- Adjust :: Pointer ( PointerCoercion :: UnsafeFnPointer ) ,
845
- ) ,
846
- None => self . unify_and (
847
- unsafe_a,
848
- b,
849
- [ ] ,
850
- Adjust :: Pointer ( PointerCoercion :: UnsafeFnPointer ) ,
851
- ) ,
852
- }
834
+ self . unify_and (
835
+ unsafe_a,
836
+ b,
837
+ adjustment
838
+ . map ( |kind| Adjustment { kind, target : Ty :: new_fn_ptr ( self . tcx , fn_ty_a) } ) ,
839
+ Adjust :: Pointer ( PointerCoercion :: UnsafeFnPointer ) ,
840
+ )
853
841
} else {
854
842
let a = Ty :: new_fn_ptr ( self . tcx , fn_ty_a) ;
855
843
match adjustment {
0 commit comments