@@ -586,17 +586,12 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
586586 // for the former and let type inference do the rest.
587587 let coerce_target = self . next_ty_var ( self . cause . span ) ;
588588
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+ ) ?;
600595
601596 let mut selcx = traits:: SelectionContext :: new ( self ) ;
602597
@@ -836,20 +831,13 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
836831 && hdr_b. safety . is_unsafe ( )
837832 {
838833 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+ )
853841 } else {
854842 let a = Ty :: new_fn_ptr ( self . tcx , fn_ty_a) ;
855843 match adjustment {
0 commit comments