Closed
Description
fn test1<F>(_: F)
where
F: Fn(i32, i32),
{
}
fn test2<F>(_: F)
where
F: Fn(i32, &i32),
{
}
fn test3<F>(_: F)
where
F: Fn(&mut i32, &i32),
{
}
fn main() {
test1(|_, _| {});
test2(|_, _| {});
test3(|_, _| {});
test1(|_: i32, _: i32| {});
test2(|_: i32, _: &i32| {});
test3(|_: &mut i32, _: &i32| {});
test1(|_, _: i32| {});
test2(|_, _: &i32| {});
//this gives an error
test3(|_, _: &i32| {});
}
Compiling playground v0.0.1 (file:///playground)
error[E0281]: type mismatch: `[closure@src/main.rs:33:11: 33:26]` implements the trait `for<'r> std::ops::Fn<(&'r mut i32, &'r i32)>`, but the trait `for<'r, 'r> std::ops::Fn<(&'r mut i32, &'r i32)>` is required
--> src/main.rs:33:5
|
33 | test3(|_, _: &i32| {});
| ^^^^^ --------------- implements `for<'r> std::ops::Fn<(&'r mut i32, &'r i32)>`
| |
| expected concrete lifetime, found bound lifetime parameter
| requires `for<'r, 'r> std::ops::Fn<(&'r mut i32, &'r i32)>`
|
= note: required by `test3`
error[E0271]: type mismatch resolving `for<'r, 'r> <[closure@src/main.rs:33:11: 33:26] as std::ops::FnOnce<(&'r mut i32, &'r i32)>>::Output == ()`
--> src/main.rs:33:5
|
33 | test3(|_, _: &i32| {});
| ^^^^^ expected bound lifetime parameter, found concrete lifetime
|
= note: concrete lifetime that was found is lifetime ReSkolemized(1, BrAnon(1))
= note: required by `test3`
error: aborting due to 2 previous errors
error: Could not compile `playground`.
To learn more, run the command again with --verbose.
Also, it could be related to #13998