diff options
| author | Michael Goulet <michael@errs.io> | 2023-12-22 21:29:12 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-12-25 16:29:15 +0000 |
| commit | 909dd864f140b5aeefd116d60ec6bffa4271617a (patch) | |
| tree | ea8ec45036b9abec61efd27d7ac5ed4d65122011 /compiler/rustc_passes/src/loops.rs | |
| parent | 981fc6e174ced2b3448e61b0851ad2db0fd5ddb3 (diff) | |
| download | rust-909dd864f140b5aeefd116d60ec6bffa4271617a.tar.gz rust-909dd864f140b5aeefd116d60ec6bffa4271617a.zip | |
Make closures carry their own ClosureKind, rather than deducing what it is from movability
Diffstat (limited to 'compiler/rustc_passes/src/loops.rs')
| -rw-r--r-- | compiler/rustc_passes/src/loops.rs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/compiler/rustc_passes/src/loops.rs b/compiler/rustc_passes/src/loops.rs index bfaf4a5a957..b8b7e0d4580 100644 --- a/compiler/rustc_passes/src/loops.rs +++ b/compiler/rustc_passes/src/loops.rs @@ -3,7 +3,7 @@ use Context::*; use rustc_hir as hir; use rustc_hir::def_id::{LocalDefId, LocalModDefId}; use rustc_hir::intravisit::{self, Visitor}; -use rustc_hir::{Destination, Movability, Node}; +use rustc_hir::{Destination, Node}; use rustc_middle::hir::nested_filter; use rustc_middle::query::Providers; use rustc_middle::ty::TyCtxt; @@ -86,16 +86,18 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> { self.with_context(Loop(source), |v| v.visit_block(b)); } hir::ExprKind::Closure(&hir::Closure { - ref fn_decl, - body, - fn_decl_span, - movability, - .. + ref fn_decl, body, fn_decl_span, kind, .. }) => { - let cx = if let Some(Movability::Static) = movability { - AsyncClosure(fn_decl_span) - } else { - Closure(fn_decl_span) + // FIXME(coroutines): This doesn't handle coroutines correctly + let cx = match kind { + hir::ClosureKind::Coroutine( + hir::CoroutineKind::Desugared( + hir::CoroutineDesugaring::Async, + hir::CoroutineSource::Block, + ), + _, + ) => AsyncClosure(fn_decl_span), + _ => Closure(fn_decl_span), }; self.visit_fn_decl(fn_decl); self.with_context(cx, |v| v.visit_nested_body(body)); |
