Open
Description
fn constrain<'a, F: FnOnce(&'a ())>(_: F) {}
fn foo<'a>(_: &'a ()) -> impl Sized + use<'a> {
constrain(foo); // adds use `opaque<'!a> = ()`
() // adds use `opaque<'a> = ()` -> leak check error
}
fn main() {}
results in the following error in HIR typeck
error[E0277]: expected a `FnOnce(&())` closure, found `for<'a> fn(&'a ()) -> impl Sized {foo}`
--> <source>:3:24
|
3 | constrain_identity(foo);
| ------------------ ^^^ expected an `FnOnce(&())` closure, found `for<'a> fn(&'a ()) -> impl Sized {foo}`
| |
| required by a bound introduced by this call
|
= help: the trait `FnOnce(&())` is not implemented for fn item `for<'a> fn(&'a ()) -> impl Sized {foo}`
note: required by a bound in `constrain_identity`
--> <source>:1:30
|
1 | fn constrain_identity<'a, F: FnOnce(&'a ())>(_: F) {}
| ^^^^^^^^^^^^^^ required by this bound in `constrain_identity`
Metadata
Metadata
Assignees
Labels
No labels