about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-01-16 17:55:22 +0100
committerGitHub <noreply@github.com>2024-01-16 17:55:22 +0100
commitd4b276caa446ec08162ae2843d39cc48a2b77a9f (patch)
tree6a71aacf358b492216708f8e940ba3f907c416ad
parent304a17a4750428d2d791dfe7cda69b0cb2e4fb0d (diff)
parent0ae00444dc075c814dd061aa1cfdc5c461c1f608 (diff)
downloadrust-d4b276caa446ec08162ae2843d39cc48a2b77a9f.tar.gz
rust-d4b276caa446ec08162ae2843d39cc48a2b77a9f.zip
Rollup merge of #119816 - oli-obk:tait_ice_unify_obligations, r=lcnr
Define hidden types in confirmation

fixes  #111470

r? `@lcnr` or `@compiler-errors`

explanation in the newly added test
-rw-r--r--compiler/rustc_trait_selection/src/traits/project.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/nested_inference_failure.rs28
2 files changed, 29 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs
index dd4e69efe37..abbc2066eac 100644
--- a/compiler/rustc_trait_selection/src/traits/project.rs
+++ b/compiler/rustc_trait_selection/src/traits/project.rs
@@ -2466,7 +2466,7 @@ fn confirm_param_env_candidate<'cx, 'tcx>(
     debug!(?cache_projection, ?obligation_projection);
 
     match infcx.at(cause, param_env).eq(
-        DefineOpaqueTypes::No,
+        DefineOpaqueTypes::Yes,
         cache_projection,
         obligation_projection,
     ) {
diff --git a/tests/ui/type-alias-impl-trait/nested_inference_failure.rs b/tests/ui/type-alias-impl-trait/nested_inference_failure.rs
new file mode 100644
index 00000000000..d2091ca96ea
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/nested_inference_failure.rs
@@ -0,0 +1,28 @@
+// check-pass
+// revisions: new old
+//[new] compile-flags: -Znext-solver
+
+//! This test checks that we can successfully infer
+//! the hidden type of `FooImpl` to be `Foo<i32, {closure}>`
+//! and `ImplT` to be `i32`. This test used to fail, because
+//! we were unable to make the connection that the closure
+//! argument is the same as the first argument of `Foo`.
+
+#![feature(type_alias_impl_trait)]
+
+use std::fmt::Debug;
+use std::marker::PhantomData;
+
+struct Foo<T: Debug, F: FnOnce(T)> {
+    f: F,
+    _phantom: PhantomData<T>,
+}
+
+type ImplT = impl Debug;
+type FooImpl = Foo<ImplT, impl FnOnce(ImplT)>;
+
+fn bar() -> FooImpl {
+    Foo::<i32, _> { f: |_| (), _phantom: PhantomData }
+}
+
+fn main() {}