1
Fork 0

de-structure variable and add stables

This commit is contained in:
ouz-a 2023-11-17 23:41:34 +03:00
parent 018b85986d
commit d0dd19a6c9
2 changed files with 45 additions and 33 deletions

View file

@ -457,22 +457,42 @@ impl<'tcx> Stable<'tcx> for mir::VarDebugInfo<'tcx> {
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T { fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
stable_mir::mir::VarDebugInfo { stable_mir::mir::VarDebugInfo {
name: self.name.to_string(), name: self.name.to_string(),
source_info: stable_mir::mir::SourceInfo { source_info: self.source_info.stable(tables),
span: self.source_info.span.stable(tables), composite: self.composite.as_ref().map(|composite| composite.stable(tables)),
scope: self.source_info.scope.into(), value: self.value.stable(tables),
}, argument_index: self.argument_index,
composite: {
if let Some(composite) = &self.composite {
Some(VarDebugInfoFragment {
ty: composite.ty.stable(tables),
projection: composite.projection.iter().map(|e| e.stable(tables)).collect(),
})
} else {
None
} }
}, }
value: { }
match self.value {
impl<'tcx> Stable<'tcx> for mir::Statement<'tcx> {
type T = stable_mir::mir::Statement;
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
Statement { kind: self.kind.stable(tables), span: self.source_info.span.stable(tables) }
}
}
impl<'tcx> Stable<'tcx> for mir::SourceInfo {
type T = stable_mir::mir::SourceInfo;
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
stable_mir::mir::SourceInfo { span: self.span.stable(tables), scope: self.scope.into() }
}
}
impl<'tcx> Stable<'tcx> for mir::VarDebugInfoFragment<'tcx> {
type T = stable_mir::mir::VarDebugInfoFragment;
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
VarDebugInfoFragment {
ty: self.ty.stable(tables),
projection: self.projection.iter().map(|e| e.stable(tables)).collect(),
}
}
}
impl<'tcx> Stable<'tcx> for mir::VarDebugInfoContents<'tcx> {
type T = stable_mir::mir::VarDebugInfoContents;
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
match self {
mir::VarDebugInfoContents::Place(place) => { mir::VarDebugInfoContents::Place(place) => {
stable_mir::mir::VarDebugInfoContents::Place(place.stable(tables)) stable_mir::mir::VarDebugInfoContents::Place(place.stable(tables))
} }
@ -485,16 +505,6 @@ impl<'tcx> Stable<'tcx> for mir::VarDebugInfo<'tcx> {
stable_mir::mir::VarDebugInfoContents::Const(op) stable_mir::mir::VarDebugInfoContents::Const(op)
} }
} }
},
argument_index: self.argument_index,
}
}
}
impl<'tcx> Stable<'tcx> for mir::Statement<'tcx> {
type T = stable_mir::mir::Statement;
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
Statement { kind: self.kind.stable(tables), span: self.source_info.span.stable(tables) }
} }
} }

View file

@ -391,12 +391,14 @@ pub trait MirVisitor {
} }
fn super_var_debug_info(&mut self, var_debug_info: &VarDebugInfo) { fn super_var_debug_info(&mut self, var_debug_info: &VarDebugInfo) {
self.visit_span(&var_debug_info.source_info.span); let VarDebugInfo { source_info, composite, value, name: _, argument_index: _ } =
let location = Location(var_debug_info.source_info.span); var_debug_info;
if let Some(composite) = &var_debug_info.composite { self.visit_span(&source_info.span);
let location = Location(source_info.span);
if let Some(composite) = composite {
self.visit_ty(&composite.ty, location); self.visit_ty(&composite.ty, location);
} }
match &var_debug_info.value { match value {
VarDebugInfoContents::Place(place) => { VarDebugInfoContents::Place(place) => {
self.visit_place(place, PlaceContext::NON_USE, location); self.visit_place(place, PlaceContext::NON_USE, location);
} }