]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs
c4db6fc97dc32468798403b8f7505acb3cac0e44
[rust.git] / src / test / ui / nll / relate_tys / impl-fn-ignore-binder-via-bottom.rs
1 // Test that the NLL solver cannot find a solution
2 // for `exists<R1> { forall<R1> { R2: R1 } }`.
3 //
4 // In this test, the impl should match `fn(T)` for some `T`,
5 // but we ask it to match `for<'a> fn(&'a ())`. Due to argument
6 // contravariance, this effectively requires a `T = &'b ()` where
7 // `forall<'a> { 'a: 'b }`. Therefore, we get an error.
8 //
9 // Note the use of `-Zno-leak-check` here. This is presently required in order
10 // to skip the leak-check errors.
11 //
12 // c.f. Issue #57642.
13 //
14 // compile-flags:-Zno-leak-check
15
16 trait Y {
17     type F;
18     fn make_f() -> Self::F;
19 }
20
21 impl<T> Y for fn(T) {
22     type F = fn(T);
23
24     fn make_f() -> Self::F {
25         |_| {}
26     }
27 }
28
29 fn main() {
30     let _x = <fn(&())>::make_f();
31     //~^ ERROR implementation of `Y` is not general enough
32     //~| ERROR implementation of `Y` is not general enough
33 }