Skip to content

Commit d4b276c

Browse files
authored
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
2 parents 304a17a + 0ae0044 commit d4b276c

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

compiler/rustc_trait_selection/src/traits/project.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2466,7 +2466,7 @@ fn confirm_param_env_candidate<'cx, 'tcx>(
24662466
debug!(?cache_projection, ?obligation_projection);
24672467

24682468
match infcx.at(cause, param_env).eq(
2469-
DefineOpaqueTypes::No,
2469+
DefineOpaqueTypes::Yes,
24702470
cache_projection,
24712471
obligation_projection,
24722472
) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// check-pass
2+
// revisions: new old
3+
//[new] compile-flags: -Znext-solver
4+
5+
//! This test checks that we can successfully infer
6+
//! the hidden type of `FooImpl` to be `Foo<i32, {closure}>`
7+
//! and `ImplT` to be `i32`. This test used to fail, because
8+
//! we were unable to make the connection that the closure
9+
//! argument is the same as the first argument of `Foo`.
10+
11+
#![feature(type_alias_impl_trait)]
12+
13+
use std::fmt::Debug;
14+
use std::marker::PhantomData;
15+
16+
struct Foo<T: Debug, F: FnOnce(T)> {
17+
f: F,
18+
_phantom: PhantomData<T>,
19+
}
20+
21+
type ImplT = impl Debug;
22+
type FooImpl = Foo<ImplT, impl FnOnce(ImplT)>;
23+
24+
fn bar() -> FooImpl {
25+
Foo::<i32, _> { f: |_| (), _phantom: PhantomData }
26+
}
27+
28+
fn main() {}

0 commit comments

Comments
 (0)