@@ -9,7 +9,7 @@ use rustc_target::abi::LayoutOf;
9
9
10
10
use crate :: interpret:: {
11
11
intrinsics:: { InterpCx , Machine } ,
12
- InterpResult , MPlaceTy , MemoryKind , Scalar ,
12
+ MPlaceTy , MemoryKind , Scalar ,
13
13
} ;
14
14
15
15
impl < ' mir , ' tcx : ' mir , M : Machine < ' mir , ' tcx > > InterpCx < ' mir , ' tcx , M > {
@@ -79,7 +79,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
79
79
filename : Symbol ,
80
80
line : u32 ,
81
81
col : u32 ,
82
- ) -> InterpResult < ' static , MPlaceTy < ' tcx , M :: PointerTag > > {
82
+ ) -> MPlaceTy < ' tcx , M :: PointerTag > {
83
83
let file =
84
84
self . allocate_str ( & filename. as_str ( ) , MemoryKind :: CallerLocation , Mutability :: Not ) ;
85
85
let line = Scalar :: from_u32 ( line) ;
@@ -91,7 +91,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
91
91
. type_of ( self . tcx . require_lang_item ( LangItem :: PanicLocation , None ) )
92
92
. subst ( * self . tcx , self . tcx . mk_substs ( [ self . tcx . lifetimes . re_erased . into ( ) ] . iter ( ) ) ) ;
93
93
let loc_layout = self . layout_of ( loc_ty) . unwrap ( ) ;
94
- let location = self . allocate ( loc_layout, MemoryKind :: CallerLocation ) ?;
94
+ // This can fail if rustc runs out of memory right here. Trying to emit an error would be
95
+ // pointless, since that would require allocating more memory than a Location.
96
+ let location = self . allocate ( loc_layout, MemoryKind :: CallerLocation ) . unwrap ( ) ;
95
97
96
98
// Initialize fields.
97
99
self . write_immediate ( file. to_ref ( ) , & self . mplace_field ( & location, 0 ) . unwrap ( ) . into ( ) )
@@ -101,7 +103,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
101
103
self . write_scalar ( col, & self . mplace_field ( & location, 2 ) . unwrap ( ) . into ( ) )
102
104
. expect ( "writing to memory we just allocated cannot fail" ) ;
103
105
104
- Ok ( location)
106
+ location
105
107
}
106
108
107
109
crate fn location_triple_for_span ( & self , span : Span ) -> ( Symbol , u32 , u32 ) {
@@ -114,10 +116,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
114
116
)
115
117
}
116
118
117
- pub fn alloc_caller_location_for_span (
118
- & mut self ,
119
- span : Span ,
120
- ) -> InterpResult < ' static , MPlaceTy < ' tcx , M :: PointerTag > > {
119
+ pub fn alloc_caller_location_for_span ( & mut self , span : Span ) -> MPlaceTy < ' tcx , M :: PointerTag > {
121
120
let ( file, line, column) = self . location_triple_for_span ( span) ;
122
121
self . alloc_caller_location ( file, line, column)
123
122
}
0 commit comments