Restore movability to SMIR

This commit is contained in:
Michael Goulet 2023-12-25 17:04:14 +00:00
parent fcb42b42d6
commit 15ccf2e7bd
7 changed files with 16 additions and 9 deletions

View File

@ -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) => {

View File

@ -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),
)
}
}

View File

@ -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) => {

View File

@ -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<UserTypeAnnotationIndex>, Option<FieldIdx>),
Closure(ClosureDef, GenericArgs),
Coroutine(CoroutineDef, GenericArgs),
// FIXME(stable_mir): Movability here is redundant
Coroutine(CoroutineDef, GenericArgs, Movability),
}
#[derive(Clone, Debug, Eq, PartialEq)]

View File

@ -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("(");

View File

@ -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<T>`, 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<Binder<ExistentialPredicate>>, Region, DynKind),
Never,
Tuple(Vec<Ty>),

View File

@ -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)?;