about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-09-27 10:42:35 +0200
committerGitHub <noreply@github.com>2023-09-27 10:42:35 +0200
commit243ce35b9fbad1fb024c85a96ef79ef9755935af (patch)
tree16b2927c3d71bcc1554490793cac3085e7b980cd
parent50417a5457327e0eb6cd214307421c798cef990b (diff)
parent35f9345076b80a26c7c96f18fb95f69adbee2375 (diff)
downloadrust-243ce35b9fbad1fb024c85a96ef79ef9755935af.tar.gz
rust-243ce35b9fbad1fb024c85a96ef79ef9755935af.zip
Rollup merge of #116178 - Milo123459:milo/add-test-for-const-async-function-in-main, r=wesleywiser
Add test for `const async fn`

This adds a test for #102796
-rw-r--r--tests/ui/async-await/const-async-fn-in-main.rs7
-rw-r--r--tests/ui/async-await/const-async-fn-in-main.stderr11
2 files changed, 18 insertions, 0 deletions
diff --git a/tests/ui/async-await/const-async-fn-in-main.rs b/tests/ui/async-await/const-async-fn-in-main.rs
new file mode 100644
index 00000000000..5d1aa4d83f3
--- /dev/null
+++ b/tests/ui/async-await/const-async-fn-in-main.rs
@@ -0,0 +1,7 @@
+// edition:2021
+// Check what happens when a const async fn is in the main function (#102796)
+
+fn main() {
+    const async fn a() {}
+//~^ ERROR functions cannot be both `const` and `async`
+}
diff --git a/tests/ui/async-await/const-async-fn-in-main.stderr b/tests/ui/async-await/const-async-fn-in-main.stderr
new file mode 100644
index 00000000000..10b15170922
--- /dev/null
+++ b/tests/ui/async-await/const-async-fn-in-main.stderr
@@ -0,0 +1,11 @@
+error: functions cannot be both `const` and `async`
+  --> $DIR/const-async-fn-in-main.rs:5:5
+   |
+LL |     const async fn a() {}
+   |     ^^^^^-^^^^^----------
+   |     |     |
+   |     |     `async` because of this
+   |     `const` because of this
+
+error: aborting due to previous error
+