diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-07-28 15:22:02 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-07-28 15:22:02 +0000 |
| commit | a85eb3d9df9f845b3ee166c8fa270efe20b4c82c (patch) | |
| tree | acc41199c423410398d79d2cb642509a48457050 /compiler/rustc_trait_selection | |
| parent | 05e678ccca974a8d0c26991083fb4cf8fff84e74 (diff) | |
| download | rust-a85eb3d9df9f845b3ee166c8fa270efe20b4c82c.tar.gz rust-a85eb3d9df9f845b3ee166c8fa270efe20b4c82c.zip | |
Revert "Rollup merge of #97346 - JohnTitor:remove-back-compat-hacks, r=oli-obk"
This reverts commit c703d11dccb4a895c7aead3b2fcd8cea8c483184, reversing changes made to 64eb9ab869bc3f9ef3645302fbf22e706eea16cf.
Diffstat (limited to 'compiler/rustc_trait_selection')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/project.rs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 9de4d3a646c..ad5817d2716 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -252,10 +252,20 @@ fn project_and_unify_type<'cx, 'tcx>( 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) |
