diff options
| author | lcnr <rust@lcnr.de> | 2025-04-11 10:42:45 +0200 |
|---|---|---|
| committer | lcnr <rust@lcnr.de> | 2025-04-11 11:01:53 +0200 |
| commit | 8cb727424dde83b841610700e40f399848e57700 (patch) | |
| tree | 0a994e8dae885945ee7792342f0c45ffdc3f8d98 /compiler/rustc_borrowck | |
| parent | 923f44c6313b86f3c1eeec264dce1a4317c8bbf6 (diff) | |
| download | rust-8cb727424dde83b841610700e40f399848e57700.tar.gz rust-8cb727424dde83b841610700e40f399848e57700.zip | |
use input `def_id` to compute `movable_coroutine`
This previously incorrectly returned `true` for parent functions whose first statement was `let local = <coroutine>;`. While that didn't cause any bugs as we only ever access `movable_coroutine` for `yield` terminators. It was still wrong.
Diffstat (limited to 'compiler/rustc_borrowck')
| -rw-r--r-- | compiler/rustc_borrowck/src/lib.rs | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index b4e807646c0..94c1b54672a 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -374,17 +374,8 @@ fn do_mir_borrowck<'tcx>( let diags_buffer = &mut BorrowckDiagnosticsBuffer::default(); nll::dump_annotation(&infcx, body, ®ioncx, &opt_closure_req, diags_buffer); - let movable_coroutine = - // The first argument is the coroutine type passed by value - if let Some(local) = body.local_decls.raw.get(1) - // Get the interior types and args which typeck computed - && let ty::Coroutine(def_id, _) = *local.ty.kind() - && tcx.coroutine_movability(def_id) == hir::Movability::Movable -{ - true -} else { - false -}; + let movable_coroutine = body.coroutine.is_some() + && tcx.coroutine_movability(def.to_def_id()) == hir::Movability::Movable; // While promoteds should mostly be correct by construction, we need to check them for // invalid moves to detect moving out of arrays:`struct S; fn main() { &([S][0]); }`. |
