about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJonas Schievink <jonasschievink@gmail.com>2020-10-02 20:27:08 +0200
committerGitHub <noreply@github.com>2020-10-02 20:27:08 +0200
commitcac5352e334d96d36ee09dbefa765037b5f834e2 (patch)
tree09235f7c9b0a23e51f13e09f3a92409743e22758 /src
parent18ac26d1c5f60c9753a1d0ab8bb1499cf2669797 (diff)
parentb48def819e8ddf8c073f34459948ed8fc77d6e94 (diff)
downloadrust-cac5352e334d96d36ee09dbefa765037b5f834e2.tar.gz
rust-cac5352e334d96d36ee09dbefa765037b5f834e2.zip
Rollup merge of #77415 - ecstatic-morse:const-checking-async-block, r=oli-obk
Better error message for `async` blocks in a const-context

Improves the error message for the case in #77361.

r? @oli-obk
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/consts/async-block.rs8
-rw-r--r--src/test/ui/consts/async-block.stderr8
2 files changed, 16 insertions, 0 deletions
diff --git a/src/test/ui/consts/async-block.rs b/src/test/ui/consts/async-block.rs
new file mode 100644
index 00000000000..1fa2a616091
--- /dev/null
+++ b/src/test/ui/consts/async-block.rs
@@ -0,0 +1,8 @@
+// From <https://github.com/rust-lang/rust/issues/77361>
+
+// edition:2018
+
+const _: i32 = { core::mem::ManuallyDrop::new(async { 0 }); 4 };
+//~^ `async` block
+
+fn main() {}
diff --git a/src/test/ui/consts/async-block.stderr b/src/test/ui/consts/async-block.stderr
new file mode 100644
index 00000000000..99f470623ac
--- /dev/null
+++ b/src/test/ui/consts/async-block.stderr
@@ -0,0 +1,8 @@
+error: `async` blocks are not allowed in constants
+  --> $DIR/async-block.rs:5:47
+   |
+LL | const _: i32 = { core::mem::ManuallyDrop::new(async { 0 }); 4 };
+   |                                               ^^^^^^^^^^^
+
+error: aborting due to previous error
+