Skip to content

Commit

Permalink
Rollup merge of #119816 - oli-obk:tait_ice_unify_obligations, r=lcnr
Browse files Browse the repository at this point in the history
Define hidden types in confirmation

fixes  #111470

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

explanation in the newly added test
  • Loading branch information
matthiaskrgr authored Jan 16, 2024
2 parents 304a17a + 0ae0044 commit d4b276c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/traits/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
Expand Down
28 changes: 28 additions & 0 deletions tests/ui/type-alias-impl-trait/nested_inference_failure.rs
Original file line number Diff line number Diff line change
@@ -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() {}

0 comments on commit d4b276c

Please sign in to comment.