]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/hrtb/issue-46989.rs
1 // Regression test for #46989:
3 // In the move to universes, this test started passing.
4 // It is not necessarily WRONG to do so, but it was a bit
5 // surprising. The reason that it passed is that when we were
8 // for<'a> fn(&'a i32): Foo
10 // we were able to use the impl below to prove
12 // fn(&'empty i32): Foo
14 // and then we were able to prove that
16 // fn(&'empty i32) = for<'a> fn(&'a i32)
18 // This last fact is somewhat surprising, but essentially "falls out"
19 // from handling variance correctly. In particular, consider the subtyping
22 // fn(&'empty i32) <: for<'a> fn(&'a i32)
24 // This holds because -- intuitively -- a fn that takes a reference but doesn't use
25 // it can be given a reference with any lifetime. Similarly, the opposite direction:
27 // for<'a> fn(&'a i32) <: fn(&'empty i32)
29 // holds because 'a can be instantiated to 'empty.
33 impl<A
> Foo
for fn(A
) {}
35 fn assert_foo
<T
: Foo
>() {}
38 assert_foo
::<fn(&i32)>();
39 //~^ ERROR implementation of `Foo` is not general enough