2019-10-24 01:25:05 +08:00
|
|
|
// edition:2018
|
|
|
|
async fn foo<F>(fun: F)
|
|
|
|
where
|
|
|
|
F: FnOnce() + 'static
|
|
|
|
{
|
|
|
|
fun()
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Struct;
|
|
|
|
|
|
|
|
impl Struct {
|
2022-05-21 15:46:25 -04:00
|
|
|
pub async fn run_dummy_fn(&self) {
|
2019-10-24 01:25:05 +08:00
|
|
|
foo(|| self.bar()).await;
|
2022-04-01 13:13:25 -04:00
|
|
|
//~^ ERROR closure may outlive the current function
|
|
|
|
//~| ERROR borrowed data escapes outside of associated function
|
2019-10-24 01:25:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn bar(&self) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|