diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index 6e97cdef3d7..3bf618202e9 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -579,6 +579,12 @@ pub fn drain_fulfillment_cx<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, Ok(infcx.tcx.erase_regions(&result)) } +impl<'tcx, T> InferOk<'tcx, T> { + fn unit(self) -> InferOk<'tcx, ()> { + InferOk { value: (), obligations: self.obligations } + } +} + impl<'a, 'tcx> InferCtxt<'a, 'tcx> { pub fn projection_mode(&self) -> ProjectionMode { self.projection_mode @@ -851,8 +857,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { debug!("sub_types({:?} <: {:?})", a, b); self.commit_if_ok(|_| { let trace = TypeTrace::types(origin, a_is_expected, a, b); - self.sub(a_is_expected, trace, &a, &b) - .map(|InferOk { obligations, .. }| InferOk { value: (), obligations: obligations }) + self.sub(a_is_expected, trace, &a, &b).map(|ok| ok.unit()) }) } @@ -865,8 +870,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { { self.commit_if_ok(|_| { let trace = TypeTrace::types(origin, a_is_expected, a, b); - self.equate(a_is_expected, trace, &a, &b) - .map(|InferOk { obligations, .. }| InferOk { value: (), obligations: obligations }) + self.equate(a_is_expected, trace, &a, &b).map(|ok| ok.unit()) }) } @@ -885,8 +889,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { origin: origin, values: TraitRefs(expected_found(a_is_expected, a.clone(), b.clone())) }; - self.equate(a_is_expected, trace, &a, &b) - .map(|InferOk { obligations, .. }| InferOk { value: (), obligations: obligations }) + self.equate(a_is_expected, trace, &a, &b).map(|ok| ok.unit()) }) } @@ -905,8 +908,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { origin: origin, values: PolyTraitRefs(expected_found(a_is_expected, a.clone(), b.clone())) }; - self.sub(a_is_expected, trace, &a, &b) - .map(|InferOk { obligations, .. }| InferOk { value: (), obligations: obligations }) + self.sub(a_is_expected, trace, &a, &b).map(|ok| ok.unit()) }) } @@ -955,9 +957,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { let (ty::EquatePredicate(a, b), skol_map) = self.skolemize_late_bound_regions(predicate, snapshot); let origin = TypeOrigin::EquatePredicate(span); - let InferOk { obligations, .. } = mk_eqty(self, false, origin, a, b)?; - self.leak_check(&skol_map, snapshot) - .map(|_| InferOk { value: (), obligations: obligations }) + let eqty_ok = mk_eqty(self, false, origin, a, b)?; + self.leak_check(&skol_map, snapshot).map(|_| eqty_ok.unit()) }) } diff --git a/src/librustc/traits/fulfill.rs b/src/librustc/traits/fulfill.rs index 68173bc9ea5..46323cdf77e 100644 --- a/src/librustc/traits/fulfill.rs +++ b/src/librustc/traits/fulfill.rs @@ -527,7 +527,7 @@ fn process_predicate1<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>, ty::Predicate::Equate(ref binder) => { match selcx.infcx().equality_predicate(obligation.cause.span, binder) { Ok(InferOk { obligations, .. }) => { - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations assert!(obligations.is_empty()); Ok(Some(Vec::new())) }, diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index 85fe457c75e..71eb0a227b4 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -233,7 +233,7 @@ fn project_and_unify_type<'cx,'tcx>( let origin = TypeOrigin::RelateOutputImplTypes(obligation.cause.span); match infer::mk_eqty(infcx, true, origin, normalized_ty, obligation.predicate.ty) { Ok(InferOk { obligations: inferred_obligations, .. }) => { - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations assert!(inferred_obligations.is_empty()); Ok(Some(obligations)) }, @@ -283,7 +283,7 @@ fn consider_unification_despite_ambiguity<'cx,'tcx>(selcx: &mut SelectionContext let obligation_ty = obligation.predicate.ty; match infer::mk_eqty(infcx, true, origin, obligation_ty, ret_type) { Ok(InferOk { obligations, .. }) => { - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations assert!(obligations.is_empty()); } Err(_) => { /* ignore errors */ } @@ -837,7 +837,7 @@ fn assemble_candidates_from_predicates<'cx,'tcx,I>( origin, data_poly_trait_ref, obligation_poly_trait_ref) - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations .map(|InferOk { obligations, .. }| assert!(obligations.is_empty())) .is_ok() }); @@ -1093,7 +1093,7 @@ fn confirm_param_env_candidate<'cx,'tcx>( obligation.predicate.trait_ref.clone(), projection.projection_ty.trait_ref.clone()) { Ok(InferOk { obligations, .. }) => { - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations assert!(obligations.is_empty()); } Err(e) => { diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 013c75bf8d2..d18f8e9dc53 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -485,7 +485,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // does this code ever run? match self.infcx.equality_predicate(obligation.cause.span, p) { Ok(InferOk { obligations, .. }) => { - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations assert!(obligations.is_empty()); EvaluatedToOk }, @@ -1190,7 +1190,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { trait_bound.clone(), ty::Binder(skol_trait_ref.clone())) { Ok(InferOk { obligations, .. }) => { - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations assert!(obligations.is_empty()); } Err(_) => { return false; } @@ -2505,7 +2505,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { origin, expected_trait_ref.clone(), obligation_trait_ref.clone()) - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations .map(|InferOk { obligations, .. }| assert!(obligations.is_empty())) .map_err(|e| OutputTypeParameterMismatch(expected_trait_ref, obligation_trait_ref, e)) } @@ -2541,7 +2541,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let InferOk { obligations, .. } = self.infcx.sub_types(false, origin, new_trait, target) .map_err(|_| Unimplemented)?; - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations assert!(obligations.is_empty()); // Register one obligation for 'a: 'b. @@ -2608,7 +2608,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let InferOk { obligations, .. } = self.infcx.sub_types(false, origin, a, b) .map_err(|_| Unimplemented)?; - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations assert!(obligations.is_empty()); } @@ -2668,7 +2668,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let InferOk { obligations, .. } = self.infcx.sub_types(false, origin, new_struct, target) .map_err(|_| Unimplemented)?; - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations assert!(obligations.is_empty()); // Construct the nested Field: Unsize> predicate. @@ -2764,7 +2764,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { debug!("match_impl: failed eq_trait_refs due to `{}`", e); () })?; - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations assert!(obligations.is_empty()); if let Err(e) = self.infcx.leak_check(&skol_map, snapshot) { @@ -2832,7 +2832,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { origin, poly_trait_ref, obligation.predicate.to_poly_trait_ref()) - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations .map(|InferOk { obligations, .. }| assert!(obligations.is_empty())) .map_err(|_| ()) } diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 00569d50cbb..ce0d42203b9 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -375,7 +375,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { pub fn check_sub(&self, t1: Ty<'tcx>, t2: Ty<'tcx>) { match self.sub(&t1, &t2) { Ok(InferOk { obligations, .. }) => { - // FIXME once obligations are being propagated, assert the right thing. + // FIXME(#32730) once obligations are being propagated, assert the right thing. assert!(obligations.is_empty()); } Err(ref e) => { @@ -399,7 +399,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { pub fn check_lub(&self, t1: Ty<'tcx>, t2: Ty<'tcx>, t_lub: Ty<'tcx>) { match self.lub(&t1, &t2) { Ok(InferOk { obligations, value: t }) => { - // FIXME once obligations are being propagated, assert the right thing. + // FIXME(#32730) once obligations are being propagated, assert the right thing. assert!(obligations.is_empty()); self.assert_eq(t, t_lub); @@ -418,7 +418,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { panic!("unexpected error computing LUB: {:?}", e) } Ok(InferOk { obligations, value: t }) => { - // FIXME once obligations are being propagated, assert the right thing. + // FIXME(#32730) once obligations are being propagated, assert the right thing. assert!(obligations.is_empty()); self.assert_eq(t, t_glb); diff --git a/src/librustc_mir/transform/type_check.rs b/src/librustc_mir/transform/type_check.rs index 3f85a3e1d46..ce8ede7f4b9 100644 --- a/src/librustc_mir/transform/type_check.rs +++ b/src/librustc_mir/transform/type_check.rs @@ -338,7 +338,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { { infer::mk_subty(self.infcx, false, infer::TypeOrigin::Misc(span), sup, sub) - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations .map(|InferOk { obligations, .. }| assert!(obligations.is_empty())) } @@ -347,7 +347,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { { infer::mk_eqty(self.infcx, false, infer::TypeOrigin::Misc(span), a, b) - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations .map(|InferOk { obligations, .. }| assert!(obligations.is_empty())) } diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index dcbfa2bb79b..e359329ebcf 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -534,7 +534,7 @@ pub fn check_match<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, let result = if is_if_let_fallback { fcx.infcx().eq_types(true, origin, arm_ty, result_ty) .map(|InferOk { obligations, .. }| { - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations assert!(obligations.is_empty()); arm_ty }) diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index a4d8e2ae049..a9849e93578 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -119,14 +119,14 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { if self.use_lub { infcx.lub(false, trace, &a, &b) .map(|InferOk { value, obligations }| { - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations assert!(obligations.is_empty()); value }) } else { infcx.sub(false, trace, &a, &b) .map(|InferOk { value, obligations }| { - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations assert!(obligations.is_empty()); value }) @@ -668,7 +668,7 @@ pub fn try_find_lub<'a, 'b, 'tcx, E, I>(fcx: &FnCtxt<'a, 'tcx>, // The signature must always match. let fty = fcx.infcx().lub(true, trace.clone(), a_fty, b_fty) .map(|InferOk { value, obligations }| { - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations assert!(obligations.is_empty()); value })?; @@ -678,7 +678,7 @@ pub fn try_find_lub<'a, 'b, 'tcx, E, I>(fcx: &FnCtxt<'a, 'tcx>, let substs = fcx.infcx().commit_if_ok(|_| { fcx.infcx().lub(true, trace.clone(), a_substs, b_substs) .map(|InferOk { value, obligations }| { - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations assert!(obligations.is_empty()); value }) @@ -746,7 +746,7 @@ pub fn try_find_lub<'a, 'b, 'tcx, E, I>(fcx: &FnCtxt<'a, 'tcx>, return fcx.infcx().commit_if_ok(|_| { fcx.infcx().lub(true, trace.clone(), &prev_ty, &new_ty) .map(|InferOk { value, obligations }| { - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations assert!(obligations.is_empty()); value }) @@ -763,7 +763,7 @@ pub fn try_find_lub<'a, 'b, 'tcx, E, I>(fcx: &FnCtxt<'a, 'tcx>, fcx.infcx().commit_if_ok(|_| { fcx.infcx().lub(true, trace, &prev_ty, &new_ty) .map(|InferOk { value, obligations }| { - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations assert!(obligations.is_empty()); value }) diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 5f49b0335d9..3c12ab8d598 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -476,7 +476,7 @@ pub fn compare_const_impl<'tcx>(tcx: &TyCtxt<'tcx>, match err { Ok(InferOk { obligations, .. }) => { - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations assert!(obligations.is_empty()) } Err(terr) => { diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 75f6b11a229..bc2ef9aafee 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -23,7 +23,7 @@ pub fn suptype<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, sp: Span, let origin = TypeOrigin::Misc(sp); match fcx.infcx().sub_types(false, origin, actual, expected) { Ok(InferOk { obligations, .. }) => { - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations assert!(obligations.is_empty()); }, Err(e) => { @@ -37,7 +37,7 @@ pub fn eqtype<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, sp: Span, let origin = TypeOrigin::Misc(sp); match fcx.infcx().eq_types(false, origin, actual, expected) { Ok(InferOk { obligations, .. }) => { - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations assert!(obligations.is_empty()); }, Err(e) => { diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 44dbcd051e2..7e487c1f717 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -1134,7 +1134,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { fn make_sub_ty(&self, sub: Ty<'tcx>, sup: Ty<'tcx>) -> infer::UnitResult<'tcx> { self.infcx().sub_types(false, TypeOrigin::Misc(DUMMY_SP), sub, sup) - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations .map(|InferOk { obligations, .. }| assert!(obligations.is_empty())) } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 625e59c6e3c..da93180c600 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1628,7 +1628,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { sup: Ty<'tcx>) -> Result<(), TypeError<'tcx>> { infer::mk_subty(self.infcx(), a_is_expected, origin, sub, sup) - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations .map(|InferOk { obligations, .. }| assert!(obligations.is_empty())) } @@ -1639,7 +1639,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { sup: Ty<'tcx>) -> Result<(), TypeError<'tcx>> { infer::mk_eqty(self.infcx(), a_is_expected, origin, sub, sup) - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations .map(|InferOk { obligations, .. }| assert!(obligations.is_empty())) } @@ -1920,7 +1920,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { TypeOrigin::Misc(default.origin_span), ty, default.ty) { Ok(InferOk { obligations, .. }) => { - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations assert!(obligations.is_empty()) }, Err(_) => { @@ -2015,7 +2015,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { match infer::mk_eqty(self.infcx(), false, TypeOrigin::Misc(default.origin_span), ty, default.ty) { - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations Ok(InferOk { obligations, .. }) => assert!(obligations.is_empty()), Err(_) => { result = Some(default); @@ -2784,7 +2784,7 @@ fn expected_types_for_fn_args<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, // FIXME(#15760) can't use try! here, FromError doesn't default // to identity so the resulting type is not constrained. match ures { - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations Ok(InferOk { obligations, .. }) => assert!(obligations.is_empty()), Err(e) => return Err(e), } @@ -2915,7 +2915,7 @@ fn check_expr_with_expectation_and_lvalue_pref<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, let trace = TypeTrace::types(origin, true, then_ty, else_ty); fcx.infcx().lub(true, trace, &then_ty, &else_ty) .map(|InferOk { value, obligations }| { - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations assert!(obligations.is_empty()); value }) @@ -2927,7 +2927,7 @@ fn check_expr_with_expectation_and_lvalue_pref<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, (origin, unit, then_ty, fcx.infcx().eq_types(true, origin, unit, then_ty) .map(|InferOk { obligations, .. }| { - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations assert!(obligations.is_empty()); unit })) diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 515a898699e..dae14c33296 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -1847,7 +1847,7 @@ fn declared_projection_bounds_from_trait<'a,'tcx>(rcx: &Rcx<'a, 'tcx>, // check whether this predicate applies to our current projection match infer::mk_eqty(infcx, false, TypeOrigin::Misc(span), ty, outlives.0) { Ok(InferOk { obligations, .. }) => { - // FIXME(#????) propagate obligations + // FIXME(#32730) propagate obligations assert!(obligations.is_empty()); Ok(outlives.1) }