Forbid generator-specific MIR in all const-contexts
This commit is contained in:
parent
c38aca0502
commit
20e07e7b8e
1 changed files with 3 additions and 5 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue