From 9130484db91e609686e287f7547fc7c085068d9b Mon Sep 17 00:00:00 2001 From: ouz-a Date: Sat, 30 Sep 2023 16:40:15 +0300 Subject: [PATCH] create localdecl and add span to it --- compiler/rustc_smir/src/rustc_smir/mod.rs | 9 ++++++++- compiler/stable_mir/src/mir/body.rs | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs index c6c97ce35e8b9..d83b92b578b03 100644 --- a/compiler/rustc_smir/src/rustc_smir/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/mod.rs @@ -106,7 +106,14 @@ impl<'tcx> Context for Tables<'tcx> { .collect(), }) .collect(), - locals: mir.local_decls.iter().map(|decl| self.intern_ty(decl.ty)).collect(), + locals: mir + .local_decls + .iter() + .map(|decl| stable_mir::mir::LocalDecl { + ty: self.intern_ty(decl.ty), + span: decl.source_info.span.stable(self), + }) + .collect(), } } diff --git a/compiler/stable_mir/src/mir/body.rs b/compiler/stable_mir/src/mir/body.rs index 6f8f7b06fa393..f2cdee0aafcd0 100644 --- a/compiler/stable_mir/src/mir/body.rs +++ b/compiler/stable_mir/src/mir/body.rs @@ -5,7 +5,13 @@ use crate::{ty::Ty, Span}; #[derive(Clone, Debug)] pub struct Body { pub blocks: Vec, - pub locals: Vec, + pub locals: Vec, +} + +#[derive(Clone, Debug)] +pub struct LocalDecl { + pub ty: Ty, + pub span: Span, } #[derive(Clone, Debug)]