diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 4a8df6c6a5ba6..67865bfcaa3d0 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 0000000000000..292733cd49239 --- /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); + +impl Foo { + type Assoc = u32; +} + +type Tait = impl Sized; + +fn bar(_: Tait) { + let x: Foo::Assoc = 42; +} + +fn main() {}