diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2024-09-14 11:53:12 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-14 11:53:12 +1000 |
| commit | 04e744e77d1389a366aa4c9477abf026eb360411 (patch) | |
| tree | 251e695e2b7dfc2a8dd415d1c10478f6581cd484 /compiler/rustc_mir_transform/src | |
| parent | 2bf0dd2735d0165a95036594f5f900a12217f6a0 (diff) | |
| parent | 5cf117ed0514af068a6e0e42f732dd93ff5e90dc (diff) | |
| download | rust-04e744e77d1389a366aa4c9477abf026eb360411.tar.gz rust-04e744e77d1389a366aa4c9477abf026eb360411.zip | |
Rollup merge of #130199 - compiler-errors:by-move, r=cjgillot
Don't call closure_by_move_body_def_id on FnOnce async closures in MIR validation Refactors the check in #129847 to not unncessarily call the `closure_by_move_body_def_id` query for async closures that don't *need* a by-move body. Fixes #130167
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/lib.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_mir_transform/src/validate.rs | 6 |
2 files changed, 2 insertions, 6 deletions
diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 84d07d38330..424e7008326 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -330,7 +330,7 @@ fn mir_promoted( tcx.ensure_with_value().has_ffi_unwind_calls(def); // the `by_move_body` query uses the raw mir, so make sure it is run. - if tcx.needs_coroutine_by_move_body_def_id(def) { + if tcx.needs_coroutine_by_move_body_def_id(def.to_def_id()) { tcx.ensure_with_value().coroutine_by_move_body_def_id(def); } diff --git a/compiler/rustc_mir_transform/src/validate.rs b/compiler/rustc_mir_transform/src/validate.rs index 3b84755dded..e5837b1b475 100644 --- a/compiler/rustc_mir_transform/src/validate.rs +++ b/compiler/rustc_mir_transform/src/validate.rs @@ -1,7 +1,6 @@ //! Validates the MIR to ensure that invariants are upheld. use rustc_data_structures::fx::{FxHashMap, FxHashSet}; -use rustc_hir as hir; use rustc_hir::LangItem; use rustc_index::bit_set::BitSet; use rustc_index::IndexVec; @@ -717,10 +716,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { // first place. let layout = if def_id == self.caller_body.source.def_id() { self.caller_body.coroutine_layout_raw() - } else if let Some(hir::CoroutineKind::Desugared( - _, - hir::CoroutineSource::Closure, - )) = self.tcx.coroutine_kind(def_id) + } else if self.tcx.needs_coroutine_by_move_body_def_id(def_id) && let ty::ClosureKind::FnOnce = args.as_coroutine().kind_ty().to_opt_closure_kind().unwrap() && self.caller_body.source.def_id() |
