]> git.proxmox.com Git - rustc.git/blob - src/test/ui/lifetimes/issue-77175.rs
New upstream version 1.57.0+dfsg1
[rustc.git] / src / test / ui / lifetimes / issue-77175.rs
1 #[deny(single_use_lifetimes)]
2 // edition:2018
3 // check-pass
4
5 // Prior to the fix, the compiler complained that the 'a lifetime was only used
6 // once. This was obviously wrong since the lifetime is used twice: For the s3
7 // parameter and the return type. The issue was caused by the compiler
8 // desugaring the async function into a generator that uses only a single
9 // lifetime, which then the validator complained about becauase of the
10 // single_use_lifetimes constraints.
11 async fn bar<'a>(s1: String, s2: &'_ str, s3: &'a str) -> &'a str {
12 s3
13 }
14
15 fn foo<'a>(s1: String, s2: &'_ str, s3: &'a str) -> &'a str {
16 s3
17 }
18
19 fn main() {}