File tree Expand file tree Collapse file tree 2 files changed +13
-9
lines changed
rustc_middle/src/ty/print Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -1030,15 +1030,19 @@ pub trait PrettyPrinter<'tcx>:
10301030 ) ?;
10311031 }
10321032 ( Scalar :: Ptr ( ptr) , ty:: FnPtr ( _) ) => {
1033- // FIXME: this can ICE when the ptr is dangling or points to a non-function.
1034- // We should probably have a helper method to share code with the "Byte strings"
1033+ // FIXME: We should probably have a helper method to share code with the "Byte strings"
10351034 // printing above (which also has to handle pointers to all sorts of things).
1036- let instance = self . tcx ( ) . global_alloc ( ptr. alloc_id ) . unwrap_fn ( ) ;
1037- self = self . typed_value (
1038- |this| this. print_value_path ( instance. def_id ( ) , instance. substs ) ,
1039- |this| this. print_type ( ty) ,
1040- " as " ,
1041- ) ?;
1035+ match self . tcx ( ) . get_global_alloc ( ptr. alloc_id ) {
1036+ Some ( GlobalAlloc :: Function ( instance) ) => {
1037+ self = self . typed_value (
1038+ |this| this. print_value_path ( instance. def_id ( ) , instance. substs ) ,
1039+ |this| this. print_type ( ty) ,
1040+ " as " ,
1041+ ) ?;
1042+ }
1043+ Some ( _) => p ! ( "<non-executable memory>" ) ,
1044+ None => p ! ( "<dangling pointer>" ) ,
1045+ }
10421046 }
10431047 // For function type zsts just printing the path is enough
10441048 ( Scalar :: Int ( int) , ty:: FnDef ( d, s) ) if int == ScalarInt :: ZST => {
Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ impl<Tag: Copy> std::fmt::Display for ImmTy<'tcx, Tag> {
106106 }
107107 ScalarMaybeUninit :: Uninit => cx. typed_value (
108108 |mut this| {
109- this. write_str ( "{ uninit " ) ?;
109+ this. write_str ( "uninit " ) ?;
110110 Ok ( this)
111111 } ,
112112 |this| this. print_type ( ty) ,
You can’t perform that action at this time.
0 commit comments