@@ -65,8 +65,8 @@ use check::{Diverges, FnCtxt};
65
65
use rustc:: hir;
66
66
use rustc:: hir:: def_id:: DefId ;
67
67
use rustc:: infer:: { Coercion , InferResult , InferOk , TypeTrace } ;
68
- use rustc:: infer:: type_variable:: { TypeVariableOrigin } ;
69
- use rustc:: traits:: { self , /*FulfillmentContext,*/ ObligationCause , ObligationCauseCode } ;
68
+ use rustc:: infer:: type_variable:: TypeVariableOrigin ;
69
+ use rustc:: traits:: { self , ObligationCause , ObligationCauseCode } ;
70
70
use rustc:: ty:: adjustment:: { Adjustment , Adjust , AutoBorrow } ;
71
71
use rustc:: ty:: { self , LvaluePreference , TypeAndMut ,
72
72
Ty , ClosureSubsts } ;
@@ -724,28 +724,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
724
724
}
725
725
726
726
/// Same as `try_coerce()`, but without side-effects.
727
- pub fn can_coerce ( & self ,
728
- expr_ty : Ty < ' tcx > ,
729
- target : Ty < ' tcx > )
730
- -> bool {
731
- // FIXME: This is a hack, but coercion wasn't made to be run
732
- // in a probe. It leaks obligations and bounds and things out
733
- // into the environment. For now we just save-and-restore the
734
- // fulfillment context.
735
- /*let saved_fulfillment_cx =
736
- mem::replace(
737
- &mut *self.inh.fulfillment_cx.borrow_mut(),
738
- FulfillmentContext::new());*/
727
+ pub fn can_coerce ( & self , expr_ty : Ty < ' tcx > , target : Ty < ' tcx > ) -> bool {
739
728
let source = self . resolve_type_vars_with_obligations ( expr_ty) ;
740
729
debug ! ( "coercion::can({:?} -> {:?})" , source, target) ;
741
730
742
731
let cause = self . cause ( syntax_pos:: DUMMY_SP , ObligationCauseCode :: ExprAssignable ) ;
743
732
let coerce = Coerce :: new ( self , cause) ;
744
- let result = self . probe ( |_| coerce. coerce :: < hir:: Expr > ( & [ ] , source, target) ) . is_ok ( ) ;
745
-
746
- //*self.inh.fulfillment_cx.borrow_mut() = saved_fulfillment_cx;
747
-
748
- result
733
+ self . probe ( |_| coerce. coerce :: < hir:: Expr > ( & [ ] , source, target) ) . is_ok ( )
749
734
}
750
735
751
736
/// Given some expressions, their known unified type and another expression,
0 commit comments