Rollup merge of #119100 - celinval:smir-body-span, r=compiler-errors
Add the function body span to StableMIR We were missing the body span, which differs from the function definition span, since it covers the entire function body. r? `@ouz-a`
This commit is contained in:
commit
739364b77c
@ -37,6 +37,7 @@ fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
|
|||||||
self.arg_count,
|
self.arg_count,
|
||||||
self.var_debug_info.iter().map(|info| info.stable(tables)).collect(),
|
self.var_debug_info.iter().map(|info| info.stable(tables)).collect(),
|
||||||
self.spread_arg.stable(tables),
|
self.spread_arg.stable(tables),
|
||||||
|
self.span.stable(tables),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,9 @@ pub struct Body {
|
|||||||
///
|
///
|
||||||
/// This is used for the "rust-call" ABI such as closures.
|
/// This is used for the "rust-call" ABI such as closures.
|
||||||
pub(super) spread_arg: Option<Local>,
|
pub(super) spread_arg: Option<Local>,
|
||||||
|
|
||||||
|
/// The span that covers the entire function body.
|
||||||
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type BasicBlockIdx = usize;
|
pub type BasicBlockIdx = usize;
|
||||||
@ -42,6 +45,7 @@ pub fn new(
|
|||||||
arg_count: usize,
|
arg_count: usize,
|
||||||
var_debug_info: Vec<VarDebugInfo>,
|
var_debug_info: Vec<VarDebugInfo>,
|
||||||
spread_arg: Option<Local>,
|
spread_arg: Option<Local>,
|
||||||
|
span: Span,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
// If locals doesn't contain enough entries, it can lead to panics in
|
// If locals doesn't contain enough entries, it can lead to panics in
|
||||||
// `ret_local`, `arg_locals`, and `inner_locals`.
|
// `ret_local`, `arg_locals`, and `inner_locals`.
|
||||||
@ -49,7 +53,7 @@ pub fn new(
|
|||||||
locals.len() > arg_count,
|
locals.len() > arg_count,
|
||||||
"A Body must contain at least a local for the return value and each of the function's arguments"
|
"A Body must contain at least a local for the return value and each of the function's arguments"
|
||||||
);
|
);
|
||||||
Self { blocks, locals, arg_count, var_debug_info, spread_arg }
|
Self { blocks, locals, arg_count, var_debug_info, spread_arg, span }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return local that holds this function's return value.
|
/// Return local that holds this function's return value.
|
||||||
|
@ -133,7 +133,7 @@ fn visit_var_debug_info(&mut self, var_debug_info: &VarDebugInfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn super_body(&mut self, body: &Body) {
|
fn super_body(&mut self, body: &Body) {
|
||||||
let Body { blocks, locals: _, arg_count, var_debug_info, spread_arg: _ } = body;
|
let Body { blocks, locals: _, arg_count, var_debug_info, spread_arg: _, span } = body;
|
||||||
|
|
||||||
for bb in blocks {
|
for bb in blocks {
|
||||||
self.visit_basic_block(bb);
|
self.visit_basic_block(bb);
|
||||||
@ -153,6 +153,8 @@ fn super_body(&mut self, body: &Body) {
|
|||||||
for info in var_debug_info.iter() {
|
for info in var_debug_info.iter() {
|
||||||
self.visit_var_debug_info(info);
|
self.visit_var_debug_info(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.visit_span(span)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_basic_block(&mut self, bb: &BasicBlock) {
|
fn super_basic_block(&mut self, bb: &BasicBlock) {
|
||||||
|
Loading…
Reference in New Issue
Block a user