Skip to content

Commit 808e431

Browse files
Propagate obligations through projection
1 parent e24d621 commit 808e431

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/librustc/traits/project.rs

+15-12
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ fn project_and_unify_type<'cx, 'gcx, 'tcx>(
207207
debug!("project_and_unify_type(obligation={:?})",
208208
obligation);
209209

210-
let Normalized { value: normalized_ty, obligations } =
210+
let Normalized { value: normalized_ty, mut obligations } =
211211
match opt_normalize_projection_type(selcx,
212212
obligation.predicate.projection_ty.clone(),
213213
obligation.cause.clone(),
@@ -224,8 +224,9 @@ fn project_and_unify_type<'cx, 'gcx, 'tcx>(
224224
let origin = TypeOrigin::RelateOutputImplTypes(obligation.cause.span);
225225
match infcx.eq_types(true, origin, normalized_ty, obligation.predicate.ty) {
226226
Ok(InferOk { obligations: inferred_obligations, .. }) => {
227-
// FIXME(#32730) propagate obligations
227+
// FIXME(#32730) once obligations are generated in inference, drop this assertion
228228
assert!(inferred_obligations.is_empty());
229+
obligations.extend(inferred_obligations);
229230
Ok(Some(obligations))
230231
},
231232
Err(err) => Err(MismatchedProjectionTypes { err: err }),
@@ -710,7 +711,8 @@ fn assemble_candidates_from_predicates<'cx, 'gcx, 'tcx, I>(
710711
origin,
711712
data_poly_trait_ref,
712713
obligation_poly_trait_ref)
713-
// FIXME(#32730) propagate obligations
714+
// FIXME(#32730) once obligations are propagated from unification in
715+
// inference, drop this assertion
714716
.map(|InferOk { obligations, .. }| assert!(obligations.is_empty()))
715717
.is_ok()
716718
});
@@ -1047,8 +1049,8 @@ fn confirm_fn_pointer_candidate<'cx, 'gcx, 'tcx>(
10471049
fn_pointer_vtable: VtableFnPointerData<'tcx, PredicateObligation<'tcx>>)
10481050
-> (Ty<'tcx>, Vec<PredicateObligation<'tcx>>)
10491051
{
1050-
// FIXME(#32730) propagate obligations (fn pointer vtable nested obligations ONLY come from
1051-
// unification in inference)
1052+
// FIXME(#32730) drop this assertion once obligations are propagated from inference (fn pointer
1053+
// vtable nested obligations ONLY come from unification in inference)
10521054
assert!(fn_pointer_vtable.nested.is_empty());
10531055
let fn_type = selcx.infcx().shallow_resolve(fn_pointer_vtable.fn_ty);
10541056
let sig = fn_type.fn_sig();
@@ -1130,13 +1132,14 @@ fn confirm_param_env_candidate<'cx, 'gcx, 'tcx>(
11301132
obligation.predicate.item_name);
11311133

11321134
let origin = TypeOrigin::RelateOutputImplTypes(obligation.cause.span);
1133-
match infcx.eq_trait_refs(false,
1134-
origin,
1135-
obligation.predicate.trait_ref.clone(),
1136-
projection.projection_ty.trait_ref.clone()) {
1135+
let obligations = match infcx.eq_trait_refs(false,
1136+
origin,
1137+
obligation.predicate.trait_ref.clone(),
1138+
projection.projection_ty.trait_ref.clone()) {
11371139
Ok(InferOk { obligations, .. }) => {
1138-
// FIXME(#32730) propagate obligations
1140+
// FIXME(#32730) once obligations are generated in inference, remove this assertion
11391141
assert!(obligations.is_empty());
1142+
obligations
11401143
}
11411144
Err(e) => {
11421145
span_bug!(
@@ -1146,9 +1149,9 @@ fn confirm_param_env_candidate<'cx, 'gcx, 'tcx>(
11461149
projection,
11471150
e);
11481151
}
1149-
}
1152+
};
11501153

1151-
(projection.ty, vec!())
1154+
(projection.ty, obligations)
11521155
}
11531156

11541157
fn confirm_impl_candidate<'cx, 'gcx, 'tcx>(

0 commit comments

Comments
 (0)