Skip to content

Commit 08fc5e8

Browse files
committed
Define hidden types in confirmation
1 parent e927184 commit 08fc5e8

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-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,26 @@
1+
// check-pass
2+
3+
//! This test checks that we can successfully infer
4+
//! the hidden type of `FooImpl` to be `Foo<i32, {closure}>`
5+
//! and `ImplT` to be `i32`. This test used to fail, because
6+
//! we were unable to make the connection that the closure
7+
//! argument is the same as the first argument of `Foo`.
8+
9+
#![feature(type_alias_impl_trait)]
10+
11+
use std::fmt::Debug;
12+
use std::marker::PhantomData;
13+
14+
struct Foo<T: Debug, F: FnOnce(T)> {
15+
f: F,
16+
_phantom: PhantomData<T>,
17+
}
18+
19+
type ImplT = impl Debug;
20+
type FooImpl = Foo<ImplT, impl FnOnce(ImplT)>;
21+
22+
fn bar() -> FooImpl {
23+
Foo::<i32, _> { f: |_| (), _phantom: PhantomData }
24+
}
25+
26+
fn main() {}

0 commit comments

Comments
 (0)