@@ -65,8 +65,8 @@ use check::{Diverges, FnCtxt};
6565use rustc:: hir;
6666use rustc:: hir:: def_id:: DefId ;
6767use 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 } ;
7070use rustc:: ty:: adjustment:: { Adjustment , Adjust , AutoBorrow } ;
7171use rustc:: ty:: { self , LvaluePreference , TypeAndMut ,
7272 Ty , ClosureSubsts } ;
@@ -724,28 +724,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
724724 }
725725
726726 /// 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 {
739728 let source = self . resolve_type_vars_with_obligations ( expr_ty) ;
740729 debug ! ( "coercion::can({:?} -> {:?})" , source, target) ;
741730
742731 let cause = self . cause ( syntax_pos:: DUMMY_SP , ObligationCauseCode :: ExprAssignable ) ;
743732 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 ( )
749734 }
750735
751736 /// Given some expressions, their known unified type and another expression,
0 commit comments