about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan MacKenzie <ecstaticmorse@gmail.com>2020-09-29 19:20:05 -0700
committerDylan MacKenzie <ecstaticmorse@gmail.com>2020-09-29 19:20:33 -0700
commit20e07e7b8e1468f12a88281f6497304eb98d48f1 (patch)
tree9c7243a9a35b98527eb4c04e62bb7fb52403a5c1
parentc38aca0502316ae610ab93deda7efa7ef8ef8473 (diff)
downloadrust-20e07e7b8e1468f12a88281f6497304eb98d48f1.tar.gz
rust-20e07e7b8e1468f12a88281f6497304eb98d48f1.zip
Forbid generator-specific MIR in all const-contexts
-rw-r--r--compiler/rustc_mir/src/transform/check_consts/ops.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/compiler/rustc_mir/src/transform/check_consts/ops.rs b/compiler/rustc_mir/src/transform/check_consts/ops.rs
index 60300d3ba51..280f3e02058 100644
--- a/compiler/rustc_mir/src/transform/check_consts/ops.rs
+++ b/compiler/rustc_mir/src/transform/check_consts/ops.rs
@@ -216,14 +216,12 @@ impl NonConstOp for FnPtrCast {
 #[derive(Debug)]
 pub struct Generator;
 impl NonConstOp for Generator {
-    fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status {
-        // FIXME: This means generator-only MIR is only forbidden in const fn. This is for
-        // compatibility with the old code. Such MIR should be forbidden everywhere.
-        mcf_status_in_item(ccx)
+    fn status_in_item(&self, _: &ConstCx<'_, '_>) -> Status {
+        Status::Forbidden
     }
 
     fn emit_error(&self, ccx: &ConstCx<'_, '_>, span: Span) {
-        mcf_emit_error(ccx, span, "const fn generators are unstable");
+        ccx.tcx.sess.struct_span_err(span, "Generators and `async` functions cannot be `const`").emit();
     }
 }