Replace arg_count in public API with return/arg getters
This commit hides the arg_count field in Body and instead exposes more stable and user-friendly methods to get the return and argument locals. As a result, Body instances must now be constructed using the `new` function.
This commit is contained in:
parent
e4c41b07f0
commit
93d1b3e92a
2 changed files with 37 additions and 13 deletions
|
@ -287,9 +287,8 @@ impl<'tcx> Stable<'tcx> for mir::Body<'tcx> {
|
|||
type T = stable_mir::mir::Body;
|
||||
|
||||
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
|
||||
stable_mir::mir::Body {
|
||||
blocks: self
|
||||
.basic_blocks
|
||||
stable_mir::mir::Body::new(
|
||||
self.basic_blocks
|
||||
.iter()
|
||||
.map(|block| stable_mir::mir::BasicBlock {
|
||||
terminator: block.terminator().stable(tables),
|
||||
|
@ -300,16 +299,15 @@ impl<'tcx> Stable<'tcx> for mir::Body<'tcx> {
|
|||
.collect(),
|
||||
})
|
||||
.collect(),
|
||||
locals: self
|
||||
.local_decls
|
||||
self.local_decls
|
||||
.iter()
|
||||
.map(|decl| stable_mir::mir::LocalDecl {
|
||||
ty: decl.ty.stable(tables),
|
||||
span: decl.source_info.span.stable(tables),
|
||||
})
|
||||
.collect(),
|
||||
arg_count: self.arg_count,
|
||||
}
|
||||
self.arg_count,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue