Open
Description
I tried this code: playground
fn foo<F>(func: F)
where
F: Fn(&str)
{
func("sss");
}
fn main() {
foo(|s| println!("{}",s)); // Ok
foo(&|s| println!("{}",s)); // Error
}
The current output is:
Compiling playground v0.0.1 (/playground)
error: implementation of `FnOnce` is not general enough
--> src/main.rs:10:5
|
10 | foo(&|s| println!("{}",s)); // Error
| ^^^ implementation of `FnOnce` is not general enough
|
= note: closure with signature `fn(&'2 str)` must implement `FnOnce<(&'1 str,)>`, for any lifetime `'1`...
= note: ...but it actually implements `FnOnce<(&'2 str,)>`, for some specific lifetime `'2`
error: aborting due to previous error
error: could not compile `playground`
This seems similar to #70263 but wasn't sure so I figured I'd error on the side of opening a new one.