]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/issue-57642-higher-ranked-subtype.rs
Rollup merge of #105216 - GuillaumeGomez:rm-unused-gui-test, r=notriddle
[rust.git] / src / test / ui / nll / issue-57642-higher-ranked-subtype.rs
1 // Regression test for issue #57642
2 // Tests that we reject a bad higher-ranked subtype
3
4 trait X {
5     type G;
6     fn make_g() -> Self::G;
7 }
8
9 impl<'a> X for fn(&'a ()) {
10     type G = &'a ();
11
12     fn make_g() -> Self::G {
13         &()
14     }
15 }
16
17 trait Y {
18     type F;
19     fn make_f() -> Self::F;
20 }
21
22 impl<T> Y for fn(T) {
23     type F = fn(T);
24
25     fn make_f() -> Self::F {
26         |_| {}
27     }
28 }
29
30 fn higher_ranked_region_has_lost_its_binder() {
31     let x = <fn (&())>::make_g(); //~ ERROR the function
32 }
33
34 fn magical() {
35     let x = <fn (&())>::make_f(); //~ ERROR no function
36 }
37
38 fn main() {}