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
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())
})
}
{
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())
})
}
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())
})
}
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())
})
}
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())
})
}
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()))
},
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))
},
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 */ }
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()
});
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) => {
// 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
},
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; }
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))
}
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.
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());
}
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<T>: Unsize<Field<U>> predicate.
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) {
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(|_| ())
}
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) => {
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);
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);
{
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()))
}
{
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()))
}
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
})
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
})
// 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
})?;
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
})
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
})
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
})
match err {
Ok(InferOk { obligations, .. }) => {
- // FIXME(#????) propagate obligations
+ // FIXME(#32730) propagate obligations
assert!(obligations.is_empty())
}
Err(terr) => {
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) => {
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) => {
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()))
}
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()))
}
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()))
}
TypeOrigin::Misc(default.origin_span),
ty, default.ty) {
Ok(InferOk { obligations, .. }) => {
- // FIXME(#????) propagate obligations
+ // FIXME(#32730) propagate obligations
assert!(obligations.is_empty())
},
Err(_) => {
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);
// 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),
}
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
})
(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
}))
// 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)
}