]> git.lizzy.rs Git - rust.git/blob - src/test/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits.rs
Rollup merge of #100462 - zohnannor:master, r=thomcc
[rust.git] / src / test / ui / higher-rank-trait-bounds / hrtb-higher-ranker-supertraits.rs
1 // Test a trait (`Bar`) with a higher-ranked supertrait.
2
3 trait Foo<'tcx>
4 {
5     fn foo(&'tcx self) -> &'tcx isize;
6 }
7
8 trait Bar<'ccx>
9     : for<'tcx> Foo<'tcx>
10 {
11     fn bar(&'ccx self) -> &'ccx isize;
12 }
13
14 fn want_foo_for_some_tcx<'x,F>(f: &'x F)
15     where F : Foo<'x>
16 {
17     want_foo_for_some_tcx(f);
18     want_foo_for_any_tcx(f); //~ ERROR not satisfied
19 }
20
21 fn want_foo_for_any_tcx<F>(f: &F)
22     where F : for<'tcx> Foo<'tcx>
23 {
24     want_foo_for_some_tcx(f);
25     want_foo_for_any_tcx(f);
26 }
27
28 fn want_bar_for_some_ccx<'x,B>(b: &B)
29     where B : Bar<'x>
30 {
31     want_foo_for_some_tcx(b);
32     want_foo_for_any_tcx(b);
33
34     want_bar_for_some_ccx(b);
35     want_bar_for_any_ccx(b); //~ ERROR not satisfied
36 }
37
38 fn want_bar_for_any_ccx<B>(b: &B)
39     where B : for<'ccx> Bar<'ccx>
40 {
41     want_foo_for_some_tcx(b);
42     want_foo_for_any_tcx(b);
43
44     want_bar_for_some_ccx(b);
45     want_bar_for_any_ccx(b);
46 }
47
48 fn main() {}