Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 8cb7274

Browse files
committed
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.
1 parent 923f44c commit 8cb7274

File tree

1 file changed

+2
-11
lines changed
  • compiler/rustc_borrowck/src

1 file changed

+2
-11
lines changed

compiler/rustc_borrowck/src/lib.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -374,17 +374,8 @@ fn do_mir_borrowck<'tcx>(
374374
let diags_buffer = &mut BorrowckDiagnosticsBuffer::default();
375375
nll::dump_annotation(&infcx, body, &regioncx, &opt_closure_req, diags_buffer);
376376

377-
let movable_coroutine =
378-
// The first argument is the coroutine type passed by value
379-
if let Some(local) = body.local_decls.raw.get(1)
380-
// Get the interior types and args which typeck computed
381-
&& let ty::Coroutine(def_id, _) = *local.ty.kind()
382-
&& tcx.coroutine_movability(def_id) == hir::Movability::Movable
383-
{
384-
true
385-
} else {
386-
false
387-
};
377+
let movable_coroutine = body.coroutine.is_some()
378+
&& tcx.coroutine_movability(def.to_def_id()) == hir::Movability::Movable;
388379

389380
// While promoteds should mostly be correct by construction, we need to check them for
390381
// invalid moves to detect moving out of arrays:`struct S; fn main() { &([S][0]); }`.

0 commit comments

Comments
 (0)