@@ -1022,7 +1022,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
10221022 cause : & ObligationCause < ' tcx > ,
10231023 param_env : ty:: ParamEnv < ' tcx > ,
10241024 predicate : ty:: PolyCoercePredicate < ' tcx > ,
1025- ) -> Option < InferResult < ' tcx , ( ) > > {
1025+ ) -> Result < InferResult < ' tcx , ( ) > , ( TyVid , TyVid ) > {
10261026 let subtype_predicate = predicate. map_bound ( |p| ty:: SubtypePredicate {
10271027 a_is_expected : false , // when coercing from `a` to `b`, `b` is expected
10281028 a : p. a ,
@@ -1036,7 +1036,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
10361036 cause : & ObligationCause < ' tcx > ,
10371037 param_env : ty:: ParamEnv < ' tcx > ,
10381038 predicate : ty:: PolySubtypePredicate < ' tcx > ,
1039- ) -> Option < InferResult < ' tcx , ( ) > > {
1039+ ) -> Result < InferResult < ' tcx , ( ) > , ( TyVid , TyVid ) > {
10401040 // Check for two unresolved inference variables, in which case we can
10411041 // make no progress. This is partly a micro-optimization, but it's
10421042 // also an opportunity to "sub-unify" the variables. This isn't
@@ -1055,12 +1055,12 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
10551055 match ( r_a. kind ( ) , r_b. kind ( ) ) {
10561056 ( & ty:: Infer ( ty:: TyVar ( a_vid) ) , & ty:: Infer ( ty:: TyVar ( b_vid) ) ) => {
10571057 self . inner . borrow_mut ( ) . type_variables ( ) . sub ( a_vid, b_vid) ;
1058- return None ;
1058+ return Err ( ( a_vid , b_vid ) ) ;
10591059 }
10601060 _ => { }
10611061 }
10621062
1063- Some ( self . commit_if_ok ( |_snapshot| {
1063+ Ok ( self . commit_if_ok ( |_snapshot| {
10641064 let ty:: SubtypePredicate { a_is_expected, a, b } =
10651065 self . replace_bound_vars_with_placeholders ( predicate) ;
10661066
@@ -1848,7 +1848,7 @@ impl<'tcx> TyOrConstInferVar<'tcx> {
18481848
18491849 /// Tries to extract an inference variable from a type, returns `None`
18501850 /// for types other than `ty::Infer(_)` (or `InferTy::Fresh*`).
1851- pub fn maybe_from_ty ( ty : Ty < ' tcx > ) -> Option < Self > {
1851+ fn maybe_from_ty ( ty : Ty < ' tcx > ) -> Option < Self > {
18521852 match * ty. kind ( ) {
18531853 ty:: Infer ( ty:: TyVar ( v) ) => Some ( TyOrConstInferVar :: Ty ( v) ) ,
18541854 ty:: Infer ( ty:: IntVar ( v) ) => Some ( TyOrConstInferVar :: TyInt ( v) ) ,
@@ -1859,7 +1859,7 @@ impl<'tcx> TyOrConstInferVar<'tcx> {
18591859
18601860 /// Tries to extract an inference variable from a constant, returns `None`
18611861 /// for constants other than `ty::ConstKind::Infer(_)` (or `InferConst::Fresh`).
1862- pub fn maybe_from_const ( ct : ty:: Const < ' tcx > ) -> Option < Self > {
1862+ fn maybe_from_const ( ct : ty:: Const < ' tcx > ) -> Option < Self > {
18631863 match ct. kind ( ) {
18641864 ty:: ConstKind :: Infer ( InferConst :: Var ( v) ) => Some ( TyOrConstInferVar :: Const ( v) ) ,
18651865 _ => None ,
0 commit comments