Skip to content

Commit

Permalink
Propagate obligations through projection
Browse files Browse the repository at this point in the history
  • Loading branch information
soltanmm-google committed May 23, 2016
1 parent e24d621 commit 808e431
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/librustc/traits/project.rs
Expand Up @@ -207,7 +207,7 @@ fn project_and_unify_type<'cx, 'gcx, 'tcx>(
debug!("project_and_unify_type(obligation={:?})",
obligation);

let Normalized { value: normalized_ty, obligations } =
let Normalized { value: normalized_ty, mut obligations } =
match opt_normalize_projection_type(selcx,
obligation.predicate.projection_ty.clone(),
obligation.cause.clone(),
Expand All @@ -224,8 +224,9 @@ fn project_and_unify_type<'cx, 'gcx, 'tcx>(
let origin = TypeOrigin::RelateOutputImplTypes(obligation.cause.span);
match infcx.eq_types(true, origin, normalized_ty, obligation.predicate.ty) {
Ok(InferOk { obligations: inferred_obligations, .. }) => {
// FIXME(#32730) propagate obligations
// FIXME(#32730) once obligations are generated in inference, drop this assertion
assert!(inferred_obligations.is_empty());
obligations.extend(inferred_obligations);
Ok(Some(obligations))
},
Err(err) => Err(MismatchedProjectionTypes { err: err }),
Expand Down Expand Up @@ -710,7 +711,8 @@ fn assemble_candidates_from_predicates<'cx, 'gcx, 'tcx, I>(
origin,
data_poly_trait_ref,
obligation_poly_trait_ref)
// FIXME(#32730) propagate obligations
// FIXME(#32730) once obligations are propagated from unification in
// inference, drop this assertion
.map(|InferOk { obligations, .. }| assert!(obligations.is_empty()))
.is_ok()
});
Expand Down Expand Up @@ -1047,8 +1049,8 @@ fn confirm_fn_pointer_candidate<'cx, 'gcx, 'tcx>(
fn_pointer_vtable: VtableFnPointerData<'tcx, PredicateObligation<'tcx>>)
-> (Ty<'tcx>, Vec<PredicateObligation<'tcx>>)
{
// FIXME(#32730) propagate obligations (fn pointer vtable nested obligations ONLY come from
// unification in inference)
// FIXME(#32730) drop this assertion once obligations are propagated from inference (fn pointer
// vtable nested obligations ONLY come from unification in inference)
assert!(fn_pointer_vtable.nested.is_empty());
let fn_type = selcx.infcx().shallow_resolve(fn_pointer_vtable.fn_ty);
let sig = fn_type.fn_sig();
Expand Down Expand Up @@ -1130,13 +1132,14 @@ fn confirm_param_env_candidate<'cx, 'gcx, 'tcx>(
obligation.predicate.item_name);

let origin = TypeOrigin::RelateOutputImplTypes(obligation.cause.span);
match infcx.eq_trait_refs(false,
origin,
obligation.predicate.trait_ref.clone(),
projection.projection_ty.trait_ref.clone()) {
let obligations = match infcx.eq_trait_refs(false,
origin,
obligation.predicate.trait_ref.clone(),
projection.projection_ty.trait_ref.clone()) {
Ok(InferOk { obligations, .. }) => {
// FIXME(#32730) propagate obligations
// FIXME(#32730) once obligations are generated in inference, remove this assertion
assert!(obligations.is_empty());
obligations
}
Err(e) => {
span_bug!(
Expand All @@ -1146,9 +1149,9 @@ fn confirm_param_env_candidate<'cx, 'gcx, 'tcx>(
projection,
e);
}
}
};

(projection.ty, vec!())
(projection.ty, obligations)
}

fn confirm_impl_candidate<'cx, 'gcx, 'tcx>(
Expand Down

0 comments on commit 808e431

Please sign in to comment.