diff options
| author | Michael Goulet <michael@errs.io> | 2023-12-26 22:43:11 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-12-28 16:35:01 +0000 |
| commit | e24da8ea197b4b6724aaf7b5a5a2de64bb3c7445 (patch) | |
| tree | 3c6d6e8b5b1f6adb15869238d11665fa48dab0fa /compiler/rustc_mir_transform | |
| parent | 15ccf2e7bda95b5dd28cb98d5fee79592fb7b854 (diff) | |
| download | rust-e24da8ea197b4b6724aaf7b5a5a2de64bb3c7445.tar.gz rust-e24da8ea197b4b6724aaf7b5a5a2de64bb3c7445.zip | |
Movability doesn't need to be a query anymore
Diffstat (limited to 'compiler/rustc_mir_transform')
| -rw-r--r-- | compiler/rustc_mir_transform/src/coroutine.rs | 27 | ||||
| -rw-r--r-- | compiler/rustc_mir_transform/src/shim.rs | 2 |
2 files changed, 12 insertions, 17 deletions
diff --git a/compiler/rustc_mir_transform/src/coroutine.rs b/compiler/rustc_mir_transform/src/coroutine.rs index 62fc15ee775..5e434d30b00 100644 --- a/compiler/rustc_mir_transform/src/coroutine.rs +++ b/compiler/rustc_mir_transform/src/coroutine.rs @@ -1565,7 +1565,7 @@ pub(crate) fn mir_coroutine_witnesses<'tcx>( let coroutine_ty = body.local_decls[ty::CAPTURE_STRUCT_LOCAL].ty; let movable = match *coroutine_ty.kind() { - ty::Coroutine(def_id, _) => tcx.movability(def_id) == hir::Movability::Movable, + ty::Coroutine(def_id, _) => tcx.coroutine_movability(def_id) == hir::Movability::Movable, ty::Error(_) => return None, _ => span_bug!(body.span, "unexpected coroutine type {}", coroutine_ty), }; @@ -1597,12 +1597,13 @@ impl<'tcx> MirPass<'tcx> for StateTransform { // The first argument is the coroutine type passed by value let coroutine_ty = body.local_decls.raw[1].ty; + let coroutine_kind = body.coroutine_kind().unwrap(); // Get the discriminant type and args which typeck computed let (discr_ty, movable) = match *coroutine_ty.kind() { - ty::Coroutine(def_id, args) => { + ty::Coroutine(_, args) => { let args = args.as_coroutine(); - (args.discr_ty(tcx), tcx.movability(def_id) == hir::Movability::Movable) + (args.discr_ty(tcx), coroutine_kind.movability() == hir::Movability::Movable) } _ => { tcx.dcx().span_delayed_bug( @@ -1613,19 +1614,13 @@ impl<'tcx> MirPass<'tcx> for StateTransform { } }; - let is_async_kind = matches!( - body.coroutine_kind(), - Some(CoroutineKind::Desugared(CoroutineDesugaring::Async, _)) - ); - let is_async_gen_kind = matches!( - body.coroutine_kind(), - Some(CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _)) - ); - let is_gen_kind = matches!( - body.coroutine_kind(), - Some(CoroutineKind::Desugared(CoroutineDesugaring::Gen, _)) - ); - let new_ret_ty = match body.coroutine_kind().unwrap() { + let is_async_kind = + matches!(coroutine_kind, CoroutineKind::Desugared(CoroutineDesugaring::Async, _)); + let is_async_gen_kind = + matches!(coroutine_kind, CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _)); + let is_gen_kind = + matches!(coroutine_kind, CoroutineKind::Desugared(CoroutineDesugaring::Gen, _)); + let new_ret_ty = match coroutine_kind { CoroutineKind::Desugared(CoroutineDesugaring::Async, _) => { // Compute Poll<return_ty> let poll_did = tcx.require_lang_item(LangItem::Poll, None); diff --git a/compiler/rustc_mir_transform/src/shim.rs b/compiler/rustc_mir_transform/src/shim.rs index 983834ef195..f6b820bfcd0 100644 --- a/compiler/rustc_mir_transform/src/shim.rs +++ b/compiler/rustc_mir_transform/src/shim.rs @@ -395,7 +395,7 @@ fn build_clone_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, self_ty: Ty<'tcx>) - ty::Closure(_, args) => builder.tuple_like_shim(dest, src, args.as_closure().upvar_tys()), ty::Tuple(..) => builder.tuple_like_shim(dest, src, self_ty.tuple_fields()), ty::Coroutine(coroutine_def_id, args) => { - assert_eq!(tcx.movability(coroutine_def_id), hir::Movability::Movable); + assert_eq!(tcx.coroutine_movability(*coroutine_def_id), hir::Movability::Movable); builder.coroutine_shim(dest, src, *coroutine_def_id, args.as_coroutine()) } _ => bug!("clone shim for `{:?}` which is not `Copy` and is not an aggregate", self_ty), |
