about summary refs log tree commit diff
diff options
context:
space:
mode:
authorStefano Buliani <stefano.buliani@gmail.com>2021-09-04 11:49:13 -0700
committerStefano Buliani <stefano.buliani@gmail.com>2021-09-04 11:49:13 -0700
commit0696c28430c58508e40e027f565f48ff8e0c0b34 (patch)
tree2423eab45c708b6a31e0c42c5279a098282fa96b
parent82f1f50335e114071fea6f5b873871b66e9c4372 (diff)
downloadrust-0696c28430c58508e40e027f565f48ff8e0c0b34.tar.gz
rust-0696c28430c58508e40e027f565f48ff8e0c0b34.zip
test for issue #77175
-rw-r--r--src/test/ui/lifetimes/issue-77175.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/test/ui/lifetimes/issue-77175.rs b/src/test/ui/lifetimes/issue-77175.rs
new file mode 100644
index 00000000000..2282752b6c1
--- /dev/null
+++ b/src/test/ui/lifetimes/issue-77175.rs
@@ -0,0 +1,19 @@
+#[deny(single_use_lifetimes)]
+// edition:2018
+// check-pass
+
+// Prior to the fix, the compiler complained that the 'a lifetime was only used
+// once. This was obviously wrong since the lifetime is used twice: For the s3
+// parameter and the return type. The issue was caused by the compiler
+// desugaring the async function into a generator that uses only a single
+// lifetime, which then the validator complained about becauase of the
+// single_use_lifetimes constraints.
+async fn bar<'a>(s1: String, s2: &'_ str, s3: &'a str) -> &'a str {
+    s3
+}
+
+fn foo<'a>(s1: String, s2: &'_ str, s3: &'a str) -> &'a str {
+    s3
+}
+
+fn main() {}