diff options
| author | Michael Goulet <michael@errs.io> | 2023-12-21 18:49:20 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-12-22 23:58:29 +0000 |
| commit | 004450506e1302239fa9ea09d50d9dc5a3261a32 (patch) | |
| tree | 1eeff59a02cdb0512f147a06514b756c57208f25 /compiler/rustc_const_eval/src | |
| parent | d6d7a93866f2ffcfb51828b8859bdad760b54ce0 (diff) | |
| download | rust-004450506e1302239fa9ea09d50d9dc5a3261a32.tar.gz rust-004450506e1302239fa9ea09d50d9dc5a3261a32.zip | |
Split coroutine desugaring kind from source
Diffstat (limited to 'compiler/rustc_const_eval/src')
| -rw-r--r-- | compiler/rustc_const_eval/src/transform/check_consts/check.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/transform/check_consts/ops.rs | 12 |
2 files changed, 16 insertions, 4 deletions
diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs index 949606ed6c9..8a1e5356a15 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs @@ -464,8 +464,12 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { Rvalue::Aggregate(kind, ..) => { if let AggregateKind::Coroutine(def_id, ..) = kind.as_ref() - && let Some(coroutine_kind @ hir::CoroutineKind::Async(..)) = - self.tcx.coroutine_kind(def_id) + && let Some( + coroutine_kind @ hir::CoroutineKind::Desugared( + hir::CoroutineDesugaring::Async, + _, + ), + ) = self.tcx.coroutine_kind(def_id) { self.check_op(ops::Coroutine(coroutine_kind)); } diff --git a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs index 2de6362b9fe..23d8a563d91 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs @@ -359,7 +359,11 @@ impl<'tcx> NonConstOp<'tcx> for FnCallUnstable { pub struct Coroutine(pub hir::CoroutineKind); impl<'tcx> NonConstOp<'tcx> for Coroutine { fn status_in_item(&self, _: &ConstCx<'_, 'tcx>) -> Status { - if let hir::CoroutineKind::Async(hir::CoroutineSource::Block) = self.0 { + if let hir::CoroutineKind::Desugared( + hir::CoroutineDesugaring::Async, + hir::CoroutineSource::Block, + ) = self.0 + { Status::Unstable(sym::const_async_blocks) } else { Status::Forbidden @@ -372,7 +376,11 @@ impl<'tcx> NonConstOp<'tcx> for Coroutine { span: Span, ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { let msg = format!("{:#}s are not allowed in {}s", self.0, ccx.const_kind()); - if let hir::CoroutineKind::Async(hir::CoroutineSource::Block) = self.0 { + if let hir::CoroutineKind::Desugared( + hir::CoroutineDesugaring::Async, + hir::CoroutineSource::Block, + ) = self.0 + { ccx.tcx.sess.create_feature_err( errors::UnallowedOpInConstContext { span, msg }, sym::const_async_blocks, |
