@@ -144,8 +144,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> {
144
144
fn unify ( & self , a : Ty < ' tcx > , b : Ty < ' tcx > ) -> InferResult < ' tcx , Ty < ' tcx > > {
145
145
self . commit_if_ok ( |_| {
146
146
if self . use_lub {
147
- self . at ( & self . cause , self . fcx . param_env )
148
- . lub ( b, a)
147
+ self . at ( & self . cause , self . fcx . param_env ) . lub ( b, a)
149
148
} else {
150
149
self . at ( & self . cause , self . fcx . param_env )
151
150
. sup ( b, a)
@@ -256,8 +255,8 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> {
256
255
b : Ty < ' tcx > ,
257
256
r_b : ty:: Region < ' tcx > ,
258
257
mt_b : TypeAndMut < ' tcx > )
259
- -> CoerceResult < ' tcx > {
260
-
258
+ -> CoerceResult < ' tcx >
259
+ {
261
260
debug ! ( "coerce_borrowed_pointer(a={:?}, b={:?})" , a, b) ;
262
261
263
262
// If we have a parameter of type `&M T_a` and the value
@@ -591,9 +590,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> {
591
590
}
592
591
593
592
Ok ( Some ( vtable) ) => {
594
- for obligation in vtable. nested_obligations ( ) {
595
- queue. push_back ( obligation) ;
596
- }
593
+ queue. extend ( vtable. nested_obligations ( ) )
597
594
}
598
595
}
599
596
}
@@ -620,12 +617,11 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> {
620
617
G : FnOnce ( Ty < ' tcx > ) -> Vec < Adjustment < ' tcx > >
621
618
{
622
619
if let ty:: FnPtr ( fn_ty_b) = b. sty {
623
- match ( fn_ty_a. unsafety ( ) , fn_ty_b. unsafety ( ) ) {
624
- ( hir:: Unsafety :: Normal , hir:: Unsafety :: Unsafe ) => {
625
- let unsafe_a = self . tcx . safe_to_unsafe_fn_ty ( fn_ty_a) ;
626
- return self . unify_and ( unsafe_a, b, to_unsafe) ;
627
- }
628
- _ => { }
620
+ if let ( hir:: Unsafety :: Normal , hir:: Unsafety :: Unsafe )
621
+ = ( fn_ty_a. unsafety ( ) , fn_ty_b. unsafety ( ) )
622
+ {
623
+ let unsafe_a = self . tcx . safe_to_unsafe_fn_ty ( fn_ty_a) ;
624
+ return self . unify_and ( unsafe_a, b, to_unsafe) ;
629
625
}
630
626
}
631
627
self . unify_and ( a, b, normal)
@@ -653,7 +649,6 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> {
653
649
-> CoerceResult < ' tcx > {
654
650
//! Attempts to coerce from the type of a Rust function item
655
651
//! into a closure or a `proc`.
656
- //!
657
652
658
653
let b = self . shallow_resolve ( b) ;
659
654
debug ! ( "coerce_from_fn_item(a={:?}, b={:?})" , a, b) ;
@@ -724,9 +719,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> {
724
719
let ( is_ref, mt_a) = match a. sty {
725
720
ty:: Ref ( _, ty, mutbl) => ( true , ty:: TypeAndMut { ty, mutbl } ) ,
726
721
ty:: RawPtr ( mt) => ( false , mt) ,
727
- _ => {
728
- return self . unify_and ( a, b, identity) ;
729
- }
722
+ _ => return self . unify_and ( a, b, identity)
730
723
} ;
731
724
732
725
// Check that the types which they point at are compatible.
@@ -896,10 +889,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
896
889
} ;
897
890
898
891
if !noop {
899
- return self . commit_if_ok ( |_| {
892
+ return self . commit_if_ok ( |_|
900
893
self . at ( cause, self . param_env )
901
894
. lub ( prev_ty, new_ty)
902
- } ) . map ( |ok| self . register_infer_ok_obligations ( ok) ) ;
895
+ ) . map ( |ok| self . register_infer_ok_obligations ( ok) ) ;
903
896
}
904
897
}
905
898
@@ -909,10 +902,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
909
902
if let Some ( e) = first_error {
910
903
Err ( e)
911
904
} else {
912
- self . commit_if_ok ( |_| {
905
+ self . commit_if_ok ( |_|
913
906
self . at ( cause, self . param_env )
914
907
. lub ( prev_ty, new_ty)
915
- } ) . map ( |ok| self . register_infer_ok_obligations ( ok) )
908
+ ) . map ( |ok| self . register_infer_ok_obligations ( ok) )
916
909
}
917
910
}
918
911
Ok ( ok) => {
@@ -1005,7 +998,7 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E>
1005
998
/// needlessly cloning the slice.
1006
999
pub fn with_coercion_sites ( expected_ty : Ty < ' tcx > ,
1007
1000
coercion_sites : & ' exprs [ E ] )
1008
- -> Self {
1001
+ -> Self {
1009
1002
Self :: make ( expected_ty, Expressions :: UpFront ( coercion_sites) )
1010
1003
}
1011
1004
0 commit comments