fix MIR fn-ptr pretty-printing
This commit is contained in:
parent
090dac0c38
commit
b08bc7836b
2 changed files with 13 additions and 9 deletions
|
@ -1030,15 +1030,19 @@ pub trait PrettyPrinter<'tcx>:
|
|||
)?;
|
||||
}
|
||||
(Scalar::Ptr(ptr), ty::FnPtr(_)) => {
|
||||
// FIXME: this can ICE when the ptr is dangling or points to a non-function.
|
||||
// We should probably have a helper method to share code with the "Byte strings"
|
||||
// FIXME: We should probably have a helper method to share code with the "Byte strings"
|
||||
// printing above (which also has to handle pointers to all sorts of things).
|
||||
let instance = self.tcx().global_alloc(ptr.alloc_id).unwrap_fn();
|
||||
self = self.typed_value(
|
||||
|this| this.print_value_path(instance.def_id(), instance.substs),
|
||||
|this| this.print_type(ty),
|
||||
" as ",
|
||||
)?;
|
||||
match self.tcx().get_global_alloc(ptr.alloc_id) {
|
||||
Some(GlobalAlloc::Function(instance)) => {
|
||||
self = self.typed_value(
|
||||
|this| this.print_value_path(instance.def_id(), instance.substs),
|
||||
|this| this.print_type(ty),
|
||||
" as ",
|
||||
)?;
|
||||
}
|
||||
Some(_) => p!("<non-executable memory>"),
|
||||
None => p!("<dangling pointer>"),
|
||||
}
|
||||
}
|
||||
// For function type zsts just printing the path is enough
|
||||
(Scalar::Int(int), ty::FnDef(d, s)) if int == ScalarInt::ZST => {
|
||||
|
|
|
@ -106,7 +106,7 @@ impl<Tag: Copy> std::fmt::Display for ImmTy<'tcx, Tag> {
|
|||
}
|
||||
ScalarMaybeUninit::Uninit => cx.typed_value(
|
||||
|mut this| {
|
||||
this.write_str("{uninit ")?;
|
||||
this.write_str("uninit ")?;
|
||||
Ok(this)
|
||||
},
|
||||
|this| this.print_type(ty),
|
||||
|
|
Loading…
Add table
Reference in a new issue