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>:
1030
1030
) ?;
1031
1031
}
1032
1032
( 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"
1035
1034
// 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
+ }
1042
1046
}
1043
1047
// For function type zsts just printing the path is enough
1044
1048
( 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> {
106
106
}
107
107
ScalarMaybeUninit :: Uninit => cx. typed_value (
108
108
|mut this| {
109
- this. write_str ( "{ uninit " ) ?;
109
+ this. write_str ( "uninit " ) ?;
110
110
Ok ( this)
111
111
} ,
112
112
|this| this. print_type ( ty) ,
You can’t perform that action at this time.
0 commit comments