summaryrefslogtreecommitdiffstats
path: root/tests/ui/dropck
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:36 +0000
commite02c5b5930c2c9ba3e5423fe12e2ef0155017297 (patch)
treefd60ebbbb5299e16e5fca8c773ddb74f764760db /tests/ui/dropck
parentAdding debian version 1.73.0+dfsg1-1. (diff)
downloadrustc-e02c5b5930c2c9ba3e5423fe12e2ef0155017297.tar.xz
rustc-e02c5b5930c2c9ba3e5423fe12e2ef0155017297.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/dropck')
-rw-r--r--tests/ui/dropck/coroutine-liveness-1.rs18
-rw-r--r--tests/ui/dropck/coroutine-liveness-2.rs23
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/ui/dropck/coroutine-liveness-1.rs b/tests/ui/dropck/coroutine-liveness-1.rs
new file mode 100644
index 000000000..aea4d15ad
--- /dev/null
+++ b/tests/ui/dropck/coroutine-liveness-1.rs
@@ -0,0 +1,18 @@
+// check-pass
+// edition: 2021
+
+// regression test for #116242.
+use std::future;
+
+fn main() {
+ let mut recv = future::ready(());
+ let _combined_fut = async {
+ let _ = || read(&mut recv);
+ };
+
+ drop(recv);
+}
+
+fn read<F: future::Future>(_: &mut F) -> F::Output {
+ todo!()
+}
diff --git a/tests/ui/dropck/coroutine-liveness-2.rs b/tests/ui/dropck/coroutine-liveness-2.rs
new file mode 100644
index 000000000..416a073c6
--- /dev/null
+++ b/tests/ui/dropck/coroutine-liveness-2.rs
@@ -0,0 +1,23 @@
+// check-pass
+// edition: 2021
+
+// regression test found while working on #117134.
+use std::future;
+
+fn main() {
+ let mut recv = future::ready(());
+ let _combined_fut = async {
+ let _ = || read(&mut recv);
+ };
+
+ let _uwu = (String::new(), _combined_fut);
+ // Dropping a coroutine as part of a more complex
+ // types should not add unnecessary liveness
+ // constraints.
+
+ drop(recv);
+}
+
+fn read<F: future::Future>(_: &mut F) -> F::Output {
+ todo!()
+}