os-rust/tests/ui/async-await/async-closures/not-lending.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
575 B
Rust
Raw Normal View History

2024-01-25 17:43:35 +00:00
//@ aux-build:block-on.rs
//@ edition:2021
#![feature(async_closure)]
extern crate block_on;
// Make sure that we can't make an async closure that evaluates to a self-borrow.
// i.e. that the generator may reference captures, but the future's return type can't.
fn main() {
block_on::block_on(async {
let s = String::new();
let x = async move || -> &String { &s };
//~^ ERROR lifetime may not live long enough
let s = String::new();
let x = async move || { &s };
//~^ ERROR lifetime may not live long enough
});
}