Err(InProgress) => return ProjectAndUnifyResult::Recursive,
};
debug!(?normalized, ?obligations, "project_and_unify_type result");
- match infcx
- .at(&obligation.cause, obligation.param_env)
- .eq(normalized, obligation.predicate.term)
- {
+ let actual = obligation.predicate.term;
+ // For an example where this is neccessary see src/test/ui/impl-trait/nested-return-type2.rs
+ // This allows users to omit re-mentioning all bounds on an associated type and just use an
+ // `impl Trait` for the assoc type to add more bounds.
+ let InferOk { value: actual, obligations: new } =
+ selcx.infcx().replace_opaque_types_with_inference_vars(
+ actual,
+ obligation.cause.body_id,
+ obligation.cause.span,
+ obligation.param_env,
+ );
+ obligations.extend(new);
+
+ match infcx.at(&obligation.cause, obligation.param_env).eq(normalized, actual) {
Ok(InferOk { obligations: inferred_obligations, value: () }) => {
obligations.extend(inferred_obligations);
ProjectAndUnifyResult::Holds(obligations)