Address nits

This commit is contained in:
Masood Malekghassemi 2016-04-04 12:41:05 -07:00
parent dcdf3d62c1
commit 86071aca3d
13 changed files with 49 additions and 48 deletions

View File

@ -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())
})
}

View File

@ -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()))
},

View File

@ -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) => {

View File

@ -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<T>: Unsize<Field<U>> 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(|_| ())
}

View File

@ -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);

View File

@ -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()))
}

View File

@ -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
})

View File

@ -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
})

View File

@ -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) => {

View File

@ -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) => {

View File

@ -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()))
}

View File

@ -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
}))

View File

@ -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)
}