Add stable for Constant in smir
This commit is contained in:
parent
c9228aeaba
commit
cab9fc99c9
@ -481,7 +481,19 @@ fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
|
||||
match self {
|
||||
Copy(place) => stable_mir::mir::Operand::Copy(place.stable(tables)),
|
||||
Move(place) => stable_mir::mir::Operand::Move(place.stable(tables)),
|
||||
Constant(c) => stable_mir::mir::Operand::Constant(c.to_string()),
|
||||
Constant(c) => stable_mir::mir::Operand::Constant(c.stable(tables)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::Constant<'tcx> {
|
||||
type T = stable_mir::mir::Constant;
|
||||
|
||||
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
|
||||
stable_mir::mir::Constant {
|
||||
span: self.span.stable(tables),
|
||||
user_ty: self.user_ty.map(|u| u.as_usize()).or(None),
|
||||
literal: self.literal.stable(tables),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
use crate::rustc_internal::Opaque;
|
||||
use crate::stable_mir::ty::{
|
||||
AdtDef, ClosureDef, Const, GeneratorDef, GenericArgs, Movability, Region,
|
||||
AdtDef, ClosureDef, Const, ConstantKind, GeneratorDef, GenericArgs, Movability, Region,
|
||||
};
|
||||
use crate::stable_mir::{self, ty::Ty};
|
||||
use crate::stable_mir::{self, ty::Ty, Span};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Body {
|
||||
@ -359,7 +359,7 @@ pub enum AggregateKind {
|
||||
pub enum Operand {
|
||||
Copy(Place),
|
||||
Move(Place),
|
||||
Constant(String),
|
||||
Constant(Constant),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
@ -383,6 +383,13 @@ pub struct UserTypeProjection {
|
||||
|
||||
type UserTypeAnnotationIndex = usize;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Constant {
|
||||
pub span: Span,
|
||||
pub user_ty: Option<UserTypeAnnotationIndex>,
|
||||
pub literal: ConstantKind,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct SwitchTarget {
|
||||
pub value: u128,
|
||||
|
Loading…
Reference in New Issue
Block a user