@@ -9,7 +9,7 @@ use rustc_target::abi::LayoutOf;
99
1010use crate :: interpret:: {
1111 intrinsics:: { InterpCx , Machine } ,
12- InterpResult , MPlaceTy , MemoryKind , Scalar ,
12+ MPlaceTy , MemoryKind , Scalar ,
1313} ;
1414
1515impl < ' 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> {
7979 filename : Symbol ,
8080 line : u32 ,
8181 col : u32 ,
82- ) -> InterpResult < ' static , MPlaceTy < ' tcx , M :: PointerTag > > {
82+ ) -> MPlaceTy < ' tcx , M :: PointerTag > {
8383 let file =
8484 self . allocate_str ( & filename. as_str ( ) , MemoryKind :: CallerLocation , Mutability :: Not ) ;
8585 let line = Scalar :: from_u32 ( line) ;
@@ -91,7 +91,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
9191 . type_of ( self . tcx . require_lang_item ( LangItem :: PanicLocation , None ) )
9292 . subst ( * self . tcx , self . tcx . mk_substs ( [ self . tcx . lifetimes . re_erased . into ( ) ] . iter ( ) ) ) ;
9393 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 ( ) ;
9597
9698 // Initialize fields.
9799 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> {
101103 self . write_scalar ( col, & self . mplace_field ( & location, 2 ) . unwrap ( ) . into ( ) )
102104 . expect ( "writing to memory we just allocated cannot fail" ) ;
103105
104- Ok ( location)
106+ location
105107 }
106108
107109 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> {
114116 )
115117 }
116118
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 > {
121120 let ( file, line, column) = self . location_triple_for_span ( span) ;
122121 self . alloc_caller_location ( file, line, column)
123122 }
0 commit comments