diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-04-19 16:12:54 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-04-19 16:12:54 +0000 |
| commit | dadece067ec1cfadaa9c2643abfa395e6c6e126b (patch) | |
| tree | 37b744abc3e329d4c68d83dbcfa4fdb44aa18cf7 | |
| parent | 07d0d7ce3fd22e4fadd61206034af6fadcdb3e4f (diff) | |
| download | rust-dadece067ec1cfadaa9c2643abfa395e6c6e126b.tar.gz rust-dadece067ec1cfadaa9c2643abfa395e6c6e126b.zip | |
Let inherent associated types constrain opaque types during projection
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/project.rs | 2 | ||||
| -rw-r--r-- | tests/ui/associated-inherent-types/constrain_opaque_types_during_projection.rs | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 4a8df6c6a5b..67865bfcaa3 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -641,7 +641,7 @@ pub fn compute_inherent_assoc_ty_args<'a, 'b, 'tcx>( ); } - match selcx.infcx.at(&cause, param_env).eq(DefineOpaqueTypes::No, impl_ty, self_ty) { + match selcx.infcx.at(&cause, param_env).eq(DefineOpaqueTypes::Yes, impl_ty, self_ty) { Ok(mut ok) => obligations.append(&mut ok.obligations), Err(_) => { tcx.dcx().span_bug( diff --git a/tests/ui/associated-inherent-types/constrain_opaque_types_during_projection.rs b/tests/ui/associated-inherent-types/constrain_opaque_types_during_projection.rs new file mode 100644 index 00000000000..292733cd492 --- /dev/null +++ b/tests/ui/associated-inherent-types/constrain_opaque_types_during_projection.rs @@ -0,0 +1,18 @@ +//@ check-pass + +#![feature(inherent_associated_types, type_alias_impl_trait)] +#![allow(incomplete_features)] + +struct Foo<T>(T); + +impl Foo<i32> { + type Assoc = u32; +} + +type Tait = impl Sized; + +fn bar(_: Tait) { + let x: Foo<Tait>::Assoc = 42; +} + +fn main() {} |
