mirror of
https://github.com/rust-lang/rust
synced 2024-09-30 22:04:36 +00:00
Enable users to dump the body of an instance
This commit is contained in:
parent
ff504a09fe
commit
5f6257429d
|
@ -91,7 +91,8 @@ pub fn local_decls(&self) -> impl Iterator<Item = (Local, &LocalDecl)> {
|
|||
self.locals.iter().enumerate()
|
||||
}
|
||||
|
||||
pub(crate) fn dump<W: io::Write>(&self, w: &mut W, fn_name: &str) -> io::Result<()> {
|
||||
/// Emit the body using the provided name for the signature.
|
||||
pub fn dump<W: io::Write>(&self, w: &mut W, fn_name: &str) -> io::Result<()> {
|
||||
function_body(w, self, fn_name)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
use crate::ty::{Allocation, ClosureDef, ClosureKind, FnDef, GenericArgs, IndexedVal, Ty};
|
||||
use crate::{with, CrateItem, DefId, Error, ItemKind, Opaque, Symbol};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::io;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum MonoItem {
|
||||
|
@ -157,6 +158,11 @@ pub fn is_empty_shim(&self) -> bool {
|
|||
pub fn try_const_eval(&self, const_ty: Ty) -> Result<Allocation, Error> {
|
||||
with(|cx| cx.eval_instance(self.def, const_ty))
|
||||
}
|
||||
|
||||
/// Emit the body of this instance if it has one.
|
||||
pub fn emit_mir<W: io::Write>(&self, w: &mut W) -> io::Result<()> {
|
||||
if let Some(body) = self.body() { body.dump(w, &self.name()) } else { Ok(()) }
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for Instance {
|
||||
|
|
Loading…
Reference in a new issue