@@ -18,8 +18,8 @@ use syntax::ast::Mutability;
1818
1919use super :: {
2020 Pointer , AllocId , Allocation , GlobalId , AllocationExtra ,
21- InterpResult , Scalar , InterpError , GlobalAlloc , PointerArithmetic ,
22- Machine , AllocMap , MayLeak , ErrorHandled , CheckInAllocMsg , InvalidProgramInfo ,
21+ InterpResult , Scalar , GlobalAlloc , PointerArithmetic ,
22+ Machine , AllocMap , MayLeak , ErrorHandled , CheckInAllocMsg ,
2323} ;
2424
2525#[ derive( Debug , PartialEq , Eq , Copy , Clone , Hash ) ]
@@ -250,18 +250,17 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
250250 Some ( alloc) => alloc,
251251 None => {
252252 // Deallocating static memory -- always an error
253- match self . tcx . alloc_map . lock ( ) . get ( ptr. alloc_id ) {
254- Some ( GlobalAlloc :: Function ( ..) ) => throw_unsup ! ( DeallocatedWrongMemoryKind (
253+ return Err ( match self . tcx . alloc_map . lock ( ) . get ( ptr. alloc_id ) {
254+ Some ( GlobalAlloc :: Function ( ..) ) => err_unsup ! ( DeallocatedWrongMemoryKind (
255255 "function" . to_string( ) ,
256256 format!( "{:?}" , kind) ,
257257 ) ) ,
258- Some ( GlobalAlloc :: Static ( ..) ) |
259- Some ( GlobalAlloc :: Memory ( ..) ) => throw_unsup ! ( DeallocatedWrongMemoryKind (
260- "static" . to_string( ) ,
261- format!( "{:?}" , kind) ,
262- ) ) ,
263- None => throw_unsup ! ( DoubleFree )
258+ Some ( GlobalAlloc :: Static ( ..) ) | Some ( GlobalAlloc :: Memory ( ..) ) => err_unsup ! (
259+ DeallocatedWrongMemoryKind ( "static" . to_string( ) , format!( "{:?}" , kind) )
260+ ) ,
261+ None => err_unsup ! ( DoubleFree ) ,
264262 }
263+ . into ( ) ) ;
265264 }
266265 } ;
267266
@@ -437,11 +436,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
437436 assert ! ( tcx. is_static( def_id) ) ;
438437 match err {
439438 ErrorHandled :: Reported =>
440- InterpError :: InvalidProgram (
441- InvalidProgramInfo :: ReferencedConstant
442- ) ,
439+ err_inval ! ( ReferencedConstant ) ,
443440 ErrorHandled :: TooGeneric =>
444- InterpError :: InvalidProgram ( InvalidProgramInfo :: TooGeneric ) ,
441+ err_inval ! ( TooGeneric ) ,
445442 }
446443 } ) ?;
447444 // Make sure we use the ID of the resolved memory, not the lazy one!
0 commit comments