diff --git a/compiler/rustc_smir/src/rustc_internal/internal.rs b/compiler/rustc_smir/src/rustc_internal/internal.rs index 629f863e620..17162d0de25 100644 --- a/compiler/rustc_smir/src/rustc_internal/internal.rs +++ b/compiler/rustc_smir/src/rustc_internal/internal.rs @@ -104,7 +104,7 @@ impl<'tcx> RustcInternal<'tcx> for RigidTy { RigidTy::Closure(def, args) => { rustc_ty::TyKind::Closure(def.0.internal(tables), args.internal(tables)) } - RigidTy::Coroutine(def, args) => { + RigidTy::Coroutine(def, args, _mov) => { rustc_ty::TyKind::Coroutine(def.0.internal(tables), args.internal(tables)) } RigidTy::CoroutineWitness(def, args) => { diff --git a/compiler/rustc_smir/src/rustc_smir/convert/mir.rs b/compiler/rustc_smir/src/rustc_smir/convert/mir.rs index 52359c3188b..027fdb3493b 100644 --- a/compiler/rustc_smir/src/rustc_smir/convert/mir.rs +++ b/compiler/rustc_smir/src/rustc_smir/convert/mir.rs @@ -535,6 +535,7 @@ impl<'tcx> Stable<'tcx> for mir::AggregateKind<'tcx> { stable_mir::mir::AggregateKind::Coroutine( tables.coroutine_def(*def_id), generic_arg.stable(tables), + tables.tcx.movability(*def_id).stable(tables), ) } } diff --git a/compiler/rustc_smir/src/rustc_smir/convert/ty.rs b/compiler/rustc_smir/src/rustc_smir/convert/ty.rs index a265c610f4a..b12951859bc 100644 --- a/compiler/rustc_smir/src/rustc_smir/convert/ty.rs +++ b/compiler/rustc_smir/src/rustc_smir/convert/ty.rs @@ -389,6 +389,7 @@ impl<'tcx> Stable<'tcx> for ty::TyKind<'tcx> { ty::Coroutine(def_id, generic_args) => TyKind::RigidTy(RigidTy::Coroutine( tables.coroutine_def(*def_id), generic_args.stable(tables), + tables.tcx.movability(*def_id).stable(tables), )), ty::Never => TyKind::RigidTy(RigidTy::Never), ty::Tuple(fields) => { diff --git a/compiler/stable_mir/src/mir/body.rs b/compiler/stable_mir/src/mir/body.rs index c7f14476304..72227a04bf1 100644 --- a/compiler/stable_mir/src/mir/body.rs +++ b/compiler/stable_mir/src/mir/body.rs @@ -1,6 +1,7 @@ use crate::mir::pretty::{function_body, pretty_statement, pretty_terminator}; use crate::ty::{ - AdtDef, ClosureDef, Const, CoroutineDef, GenericArgs, Region, RigidTy, Ty, TyKind, VariantIdx, + AdtDef, ClosureDef, Const, CoroutineDef, GenericArgs, Movability, Region, RigidTy, Ty, TyKind, + VariantIdx, }; use crate::{Error, Opaque, Span, Symbol}; use std::io; @@ -645,7 +646,9 @@ impl Rvalue { )), AggregateKind::Adt(def, _, ref args, _, _) => Ok(def.ty_with_args(args)), AggregateKind::Closure(def, ref args) => Ok(Ty::new_closure(def, args.clone())), - AggregateKind::Coroutine(def, ref args) => Ok(Ty::new_coroutine(def, args.clone())), + AggregateKind::Coroutine(def, ref args, mov) => { + Ok(Ty::new_coroutine(def, args.clone(), mov)) + } }, Rvalue::ShallowInitBox(_, ty) => Ok(Ty::new_box(*ty)), Rvalue::CopyForDeref(place) => place.ty(locals), @@ -659,7 +662,8 @@ pub enum AggregateKind { Tuple, Adt(AdtDef, VariantIdx, GenericArgs, Option, Option), Closure(ClosureDef, GenericArgs), - Coroutine(CoroutineDef, GenericArgs), + // FIXME(stable_mir): Movability here is redundant + Coroutine(CoroutineDef, GenericArgs, Movability), } #[derive(Clone, Debug, Eq, PartialEq)] diff --git a/compiler/stable_mir/src/mir/pretty.rs b/compiler/stable_mir/src/mir/pretty.rs index 13ebfb8f5de..8b7b488d312 100644 --- a/compiler/stable_mir/src/mir/pretty.rs +++ b/compiler/stable_mir/src/mir/pretty.rs @@ -443,7 +443,7 @@ pub fn pretty_ty(ty: TyKind) -> String { RigidTy::FnDef(_, _) => format!("{:#?}", rigid_ty), RigidTy::FnPtr(_) => format!("{:#?}", rigid_ty), RigidTy::Closure(_, _) => format!("{:#?}", rigid_ty), - RigidTy::Coroutine(_, _) => format!("{:#?}", rigid_ty), + RigidTy::Coroutine(_, _, _) => format!("{:#?}", rigid_ty), RigidTy::Dynamic(data, region, repr) => { // FIXME: Fix binder printing, it looks ugly now pretty.push_str("("); diff --git a/compiler/stable_mir/src/ty.rs b/compiler/stable_mir/src/ty.rs index 5a9a38c9155..9e6ecbe8315 100644 --- a/compiler/stable_mir/src/ty.rs +++ b/compiler/stable_mir/src/ty.rs @@ -58,8 +58,8 @@ impl Ty { } /// Create a new coroutine type. - pub fn new_coroutine(def: CoroutineDef, args: GenericArgs) -> Ty { - Ty::from_rigid_kind(RigidTy::Coroutine(def, args)) + pub fn new_coroutine(def: CoroutineDef, args: GenericArgs, mov: Movability) -> Ty { + Ty::from_rigid_kind(RigidTy::Coroutine(def, args, mov)) } /// Create a new box type that represents `Box`, for the given inner type `T`. @@ -460,7 +460,8 @@ pub enum RigidTy { FnDef(FnDef, GenericArgs), FnPtr(PolyFnSig), Closure(ClosureDef, GenericArgs), - Coroutine(CoroutineDef, GenericArgs), + // FIXME(stable_mir): Movability here is redundant + Coroutine(CoroutineDef, GenericArgs, Movability), Dynamic(Vec>, Region, DynKind), Never, Tuple(Vec), diff --git a/compiler/stable_mir/src/visitor.rs b/compiler/stable_mir/src/visitor.rs index 4e27c916b34..65e42879d61 100644 --- a/compiler/stable_mir/src/visitor.rs +++ b/compiler/stable_mir/src/visitor.rs @@ -148,7 +148,7 @@ impl Visitable for RigidTy { RigidTy::FnDef(_, args) => args.visit(visitor), RigidTy::FnPtr(sig) => sig.visit(visitor), RigidTy::Closure(_, args) => args.visit(visitor), - RigidTy::Coroutine(_, args) => args.visit(visitor), + RigidTy::Coroutine(_, args, _) => args.visit(visitor), RigidTy::CoroutineWitness(_, args) => args.visit(visitor), RigidTy::Dynamic(pred, r, _) => { pred.visit(visitor)?;