]> git.lizzy.rs Git - rust.git/blob - tests/ui/higher-rank-trait-bounds/issue-62203-hrtb-ice.rs
Auto merge of #106812 - oli-obk:output_filenames, r=petrochenkov
[rust.git] / tests / ui / higher-rank-trait-bounds / issue-62203-hrtb-ice.rs
1 trait T0<'a, A> {
2     type O;
3 }
4
5 struct L<T> {
6     f: T,
7 }
8
9 // explicitly named variants of what one would normally denote by the
10 // unit type `()`. Why do this? So that we can differentiate them in
11 // the diagnostic output.
12 struct Unit1;
13 struct Unit2;
14 struct Unit3;
15 struct Unit4;
16
17 impl<'a, A, T> T0<'a, A> for L<T>
18 where
19     T: FnMut(A) -> Unit3,
20 {
21     type O = T::Output;
22 }
23
24 trait T1: for<'r> Ty<'r> {
25     fn m<'a, B: Ty<'a>, F>(&self, f: F) -> Unit1
26     where
27         F: for<'r> T0<'r, (<Self as Ty<'r>>::V,), O = <B as Ty<'r>>::V>,
28     {
29         unimplemented!();
30     }
31 }
32
33 trait Ty<'a> {
34     type V;
35 }
36
37 fn main() {
38     let v = Unit2.m(
39         L {
40             //~^ ERROR to be a closure that returns `Unit3`, but it returns `Unit4`
41             //~| ERROR type mismatch
42             f: |x| {
43                 drop(x);
44                 Unit4
45             },
46         },
47     );
48 }
49
50 impl<'a> Ty<'a> for Unit2 {
51     type V = &'a u8;
52 }
53
54 impl T1 for Unit2 {}