From 686df5fd82c54c63f5062aad6ea215f05f1278a1 Mon Sep 17 00:00:00 2001 From: Ellen Date: Thu, 8 Sep 2022 22:01:51 +0100 Subject: [PATCH] make CI pass --- .../src/traits/project.rs | 54 +++++++++++++------ .../generic-associated-types/issue-93340.rs | 7 +-- 2 files changed, 42 insertions(+), 19 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 0ed73de9370b2..df37269deb3b6 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -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( @@ -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!(), } @@ -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); diff --git a/src/test/ui/generic-associated-types/issue-93340.rs b/src/test/ui/generic-associated-types/issue-93340.rs index 4662fda537b5f..d60e4e41175ab 100644 --- a/src/test/ui/generic-associated-types/issue-93340.rs +++ b/src/test/ui/generic-associated-types/issue-93340.rs @@ -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( -) -> impl Fn(A::RefType<'_>, B::RefType<'_>) -> O { - cmp_eq +fn build_expression() +-> impl Fn(A::RefType<'_>, B::RefType<'_>) -> O { + // FIXME(BoxyUwU) + cmp_eq:: } fn main() {}