Skip to content

Commit

Permalink
make CI pass
Browse files Browse the repository at this point in the history
  • Loading branch information
BoxyUwU committed Sep 21, 2022
1 parent fc629fd commit 686df5f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 19 deletions.
54 changes: 38 additions & 16 deletions compiler/rustc_trait_selection/src/traits/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,18 +258,6 @@ fn project_and_unify_type<'cx, 'tcx>(
debug!(?normalized, ?obligations, "project_and_unify_type result");
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);

if let Some(ty) = normalized.ty() {
if let &ty::Projection(projection) = ty.kind() {
match opt_normalize_projection_type(
Expand Down Expand Up @@ -322,10 +310,32 @@ fn project_and_unify_type<'cx, 'tcx>(
obligation.recursion_depth,
&mut obligations,
) {
Ok(Some(_)) => infcx
.at(&obligation.cause, obligation.param_env)
.trace(ty, actual)
.eq(projection, normed_other),
Ok(Some(_)) => {
// 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: s_opaque_infer_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);

let s_opaque_infer_actual =
match s_opaque_infer_actual.kind() {
&ty::Projection(actual) => actual,
_ => unreachable!(),
};

infcx
.at(&obligation.cause, obligation.param_env)
.trace(ty, actual)
.eq(projection, s_opaque_infer_actual)
}
Ok(None) => Ok(flipped_projection_eq),
Err(InProgress) => unreachable!(),
}
Expand Down Expand Up @@ -357,6 +367,18 @@ fn project_and_unify_type<'cx, 'tcx>(
}
}

// 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);
Expand Down
7 changes: 4 additions & 3 deletions src/test/ui/generic-associated-types/issue-93340.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ fn cmp_eq<'a, 'b, A: Scalar, B: Scalar, O: Scalar>(a: A::RefType<'a>, b: B::RefT
todo!()
}

fn build_expression<A: Scalar, B: Scalar, O: Scalar>(
) -> impl Fn(A::RefType<'_>, B::RefType<'_>) -> O {
cmp_eq
fn build_expression<A: Scalar, B: Scalar, O: Scalar>()
-> impl Fn(A::RefType<'_>, B::RefType<'_>) -> O {
// FIXME(BoxyUwU)
cmp_eq::<A, B, O>
}

fn main() {}

0 comments on commit 686df5f

Please sign in to comment.