summaryrefslogtreecommitdiffstats
path: root/src/test/ui/async-await/async-await-let-else.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/async-await/async-await-let-else.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/test/ui/async-await/async-await-let-else.rs53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/test/ui/async-await/async-await-let-else.rs b/src/test/ui/async-await/async-await-let-else.rs
new file mode 100644
index 000000000..7ea07ae9a
--- /dev/null
+++ b/src/test/ui/async-await/async-await-let-else.rs
@@ -0,0 +1,53 @@
+// edition:2021
+#![feature(let_else)]
+use std::rc::Rc;
+
+async fn foo(x: Option<bool>) {
+ let Some(_) = x else {
+ let r = Rc::new(());
+ bar().await
+ };
+}
+
+async fn bar() -> ! {
+ panic!()
+}
+
+fn is_send<T: Send>(_: T) {}
+
+async fn foo2(x: Option<bool>) {
+ let Some(_) = x else {
+ bar2(Rc::new(())).await
+ };
+}
+
+async fn bar2<T>(_: T) -> ! {
+ panic!()
+}
+
+async fn foo3(x: Option<bool>) {
+ let Some(_) = x else {
+ (Rc::new(()), bar().await);
+ return;
+ };
+}
+
+async fn foo4(x: Option<bool>) {
+ let Some(_) = x else {
+ let r = Rc::new(());
+ bar().await;
+ println!("{:?}", r);
+ return;
+ };
+}
+
+fn main() {
+ is_send(foo(Some(true)));
+ //~^ ERROR future cannot be sent between threads safely
+ is_send(foo2(Some(true)));
+ //~^ ERROR future cannot be sent between threads safely
+ is_send(foo3(Some(true)));
+ //~^ ERROR future cannot be sent between threads safely
+ is_send(foo4(Some(true)));
+ //~^ ERROR future cannot be sent between threads safely
+}