Auto merge of #115202 - ouz-a:more_smir, r=spastorino
Add stable for Constant in smir Previously https://github.com/rust-lang/rust/pull/114587 we covered much of the groundwork needed to cover Const in smir, so there is no reason keep `Constant` as String. r? `@spastorino`
This commit is contained in:
commit
734a0d0aa0
@ -477,7 +477,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 {
|
||||
@ -324,7 +324,7 @@ pub enum AggregateKind {
|
||||
pub enum Operand {
|
||||
Copy(Place),
|
||||
Move(Place),
|
||||
Constant(String),
|
||||
Constant(Constant),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
@ -348,6 +348,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