Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 20e07e7

Browse files
Forbid generator-specific MIR in all const-contexts
1 parent c38aca0 commit 20e07e7

File tree

1 file changed

+3
-5
lines changed
  • compiler/rustc_mir/src/transform/check_consts

1 file changed

+3
-5
lines changed

compiler/rustc_mir/src/transform/check_consts/ops.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,12 @@ impl NonConstOp for FnPtrCast {
216216
#[derive(Debug)]
217217
pub struct Generator;
218218
impl NonConstOp for Generator {
219-
fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status {
220-
// FIXME: This means generator-only MIR is only forbidden in const fn. This is for
221-
// compatibility with the old code. Such MIR should be forbidden everywhere.
222-
mcf_status_in_item(ccx)
219+
fn status_in_item(&self, _: &ConstCx<'_, '_>) -> Status {
220+
Status::Forbidden
223221
}
224222

225223
fn emit_error(&self, ccx: &ConstCx<'_, '_>, span: Span) {
226-
mcf_emit_error(ccx, span, "const fn generators are unstable");
224+
ccx.tcx.sess.struct_span_err(span, "Generators and `async` functions cannot be `const`").emit();
227225
}
228226
}
229227

0 commit comments

Comments
 (0)