Add a public API to get all body locals
This is particularly helpful for the ui tests, but also could be helpful for Stable MIR users who just want all the locals without needing to concatenate responses
This commit is contained in:
parent
372c533532
commit
39b293fb5a
@ -48,6 +48,14 @@ impl Body {
|
||||
pub fn internal_locals(&self) -> &[LocalDecl] {
|
||||
&self.locals[self.arg_count + 1..]
|
||||
}
|
||||
|
||||
/// Convenience function to get all the locals in this function.
|
||||
///
|
||||
/// Locals are typically accessed via the more specific methods `ret_local`,
|
||||
/// `arg_locals`, and `internal_locals`.
|
||||
pub fn locals(&self) -> &[LocalDecl] {
|
||||
&self.locals
|
||||
}
|
||||
}
|
||||
|
||||
type LocalDecls = Vec<LocalDecl>;
|
||||
|
@ -59,7 +59,7 @@ fn test_body(body: mir::Body) {
|
||||
for term in body.blocks.iter().map(|bb| &bb.terminator) {
|
||||
match &term.kind {
|
||||
Call { func, .. } => {
|
||||
let TyKind::RigidTy(ty) = func.ty(&body.locals).kind() else { unreachable!() };
|
||||
let TyKind::RigidTy(ty) = func.ty(&body.locals()).kind() else { unreachable!() };
|
||||
let RigidTy::FnDef(def, args) = ty else { unreachable!() };
|
||||
let result = Instance::resolve(def, &args);
|
||||
assert!(result.is_ok());
|
||||
|
Loading…
x
Reference in New Issue
Block a user