]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lifetimes/issue-79187-2.rs
Rollup merge of #105555 - krasimirgg:llvm-int-opt-2, r=cuviper
[rust.git] / src / test / ui / lifetimes / issue-79187-2.rs
1 trait Foo {}
2
3 impl<F> Foo for F where F: Fn(&i32) -> &i32 {}
4
5 fn take_foo(_: impl Foo) {}
6
7 fn main() {
8     take_foo(|a| a);
9     //~^ ERROR implementation of `FnOnce` is not general enough
10     //~| ERROR mismatched types
11     take_foo(|a: &i32| a);
12     //~^ ERROR lifetime may not live long enough
13     //~| ERROR mismatched types
14     take_foo(|a: &i32| -> &i32 { a });
15     //~^ ERROR lifetime may not live long enough
16     //~| ERROR mismatched types
17
18     // OK
19     take_foo(identity(|a| a));
20     take_foo(identity(|a: &i32| a));
21     take_foo(identity(|a: &i32| -> &i32 { a }));
22
23     fn identity<F>(t: F) -> F
24     where
25         F: Fn(&i32) -> &i32,
26     {
27         t
28     }
29 }