]> git.lizzy.rs Git - rust.git/blob - src/test/ui/async-await/issue-74072-lifetime-name-annotations.rs
Auto merge of #83152 - guswynn:jemallocator_part2, r=Mark-Simulacrum
[rust.git] / src / test / ui / async-await / issue-74072-lifetime-name-annotations.rs
1 // edition:2018
2 #![feature(async_closure)]
3 use std::future::Future;
4
5 // test the quality of annotations giving lifetimes names (`'1`) when async constructs are involved
6
7 pub async fn async_fn(x: &mut i32) -> &i32 {
8     let y = &*x;
9     *x += 1; //~ ERROR cannot assign to `*x` because it is borrowed
10     y
11 }
12
13 pub fn async_closure(x: &mut i32) -> impl Future<Output=&i32> {
14     (async move || {
15         let y = &*x;
16         *x += 1; //~ ERROR cannot assign to `*x` because it is borrowed
17         y
18     })()
19 }
20
21 pub fn async_closure_explicit_return_type(x: &mut i32) -> impl Future<Output=&i32> {
22     (async move || -> &i32 {
23         let y = &*x;
24         *x += 1; //~ ERROR cannot assign to `*x` because it is borrowed
25         y
26     })()
27 }
28
29 pub fn async_block(x: &mut i32) -> impl Future<Output=&i32> {
30     async move {
31         let y = &*x;
32         *x += 1; //~ ERROR cannot assign to `*x` because it is borrowed
33         y
34     }
35 }
36
37 fn main() {}