]> git.lizzy.rs Git - rust.git/blob - tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90612.rs
Rollup merge of #106670 - albertlarsan68:check-docs-in-pr-ci, r=Mark-Simulacrum
[rust.git] / tests / ui / higher-rank-trait-bounds / normalize-under-binder / issue-90612.rs
1 // check-pass
2
3 use std::marker::PhantomData;
4
5 trait Family: Sized {
6     type Item<'a>;
7
8     fn apply_all<F>(&self, f: F)
9     where
10         F: FamilyItemFn<Self> { }
11 }
12
13 struct Array<T>(PhantomData<T>);
14
15 impl<T: 'static> Family for Array<T> {
16     type Item<'a> = &'a T;
17 }
18
19 trait FamilyItemFn<T: Family> {
20     fn apply(&self, item: T::Item<'_>);
21 }
22
23 impl<T, F> FamilyItemFn<T> for F
24 where
25     T: Family,
26     for<'a> F: Fn(T::Item<'a>)
27 {
28     fn apply(&self, item: T::Item<'_>) {
29         (*self)(item);
30     }
31 }
32
33 fn process<T: 'static>(array: Array<T>) {
34     // Works
35     array.apply_all(|x: &T| { });
36
37     // ICE: NoSolution
38     array.apply_all(|x: <Array<T> as Family>::Item<'_>| { });
39 }
40
41 fn main() {}