@@ -291,21 +291,18 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
291291 ) ;
292292 }
293293
294- let ( alloc_kind, mut alloc) = match self . alloc_map . remove ( & alloc_id) {
295- Some ( alloc) => alloc,
296- None => {
297- // Deallocating global memory -- always an error
298- return Err ( match self . tcx . get_global_alloc ( alloc_id) {
299- Some ( GlobalAlloc :: Function ( ..) ) => {
300- err_ub_format ! ( "deallocating {}, which is a function" , alloc_id)
301- }
302- Some ( GlobalAlloc :: Static ( ..) | GlobalAlloc :: Memory ( ..) ) => {
303- err_ub_format ! ( "deallocating {}, which is static memory" , alloc_id)
304- }
305- None => err_ub ! ( PointerUseAfterFree ( alloc_id) ) ,
294+ let Some ( ( alloc_kind, mut alloc) ) = self . alloc_map . remove ( & alloc_id) else {
295+ // Deallocating global memory -- always an error
296+ return Err ( match self . tcx . get_global_alloc ( alloc_id) {
297+ Some ( GlobalAlloc :: Function ( ..) ) => {
298+ err_ub_format ! ( "deallocating {}, which is a function" , alloc_id)
306299 }
307- . into ( ) ) ;
300+ Some ( GlobalAlloc :: Static ( ..) | GlobalAlloc :: Memory ( ..) ) => {
301+ err_ub_format ! ( "deallocating {}, which is static memory" , alloc_id)
302+ }
303+ None => err_ub ! ( PointerUseAfterFree ( alloc_id) ) ,
308304 }
305+ . into ( ) ) ;
309306 } ;
310307
311308 if alloc. mutability == Mutability :: Not {
@@ -957,9 +954,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
957954 ptr : Pointer < Option < M :: PointerTag > > ,
958955 size : Size ,
959956 ) -> InterpResult < ' tcx , & [ u8 ] > {
960- let alloc_ref = match self . get ( ptr, size, Align :: ONE ) ? {
961- Some ( a ) => a ,
962- None => return Ok ( & [ ] ) , // zero-sized access
957+ let Some ( alloc_ref) = self . get ( ptr, size, Align :: ONE ) ? else {
958+ // zero-sized access
959+ return Ok ( & [ ] ) ;
963960 } ;
964961 // Side-step AllocRef and directly access the underlying bytes more efficiently.
965962 // (We are staying inside the bounds here so all is good.)
@@ -983,17 +980,14 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
983980 assert_eq ! ( lower, len, "can only write iterators with a precise length" ) ;
984981
985982 let size = Size :: from_bytes ( len) ;
986- let alloc_ref = match self . get_mut ( ptr, size, Align :: ONE ) ? {
987- Some ( alloc_ref) => alloc_ref,
988- None => {
989- // zero-sized access
990- assert_matches ! (
991- src. next( ) ,
992- None ,
993- "iterator said it was empty but returned an element"
994- ) ;
995- return Ok ( ( ) ) ;
996- }
983+ let Some ( alloc_ref) = self . get_mut ( ptr, size, Align :: ONE ) ? else {
984+ // zero-sized access
985+ assert_matches ! (
986+ src. next( ) ,
987+ None ,
988+ "iterator said it was empty but returned an element"
989+ ) ;
990+ return Ok ( ( ) ) ;
997991 } ;
998992
999993 // Side-step AllocRef and directly access the underlying bytes more efficiently.
@@ -1043,18 +1037,18 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
10431037 // and once below to get the underlying `&[mut] Allocation`.
10441038
10451039 // Source alloc preparations and access hooks.
1046- let ( src_alloc_id, src_offset, src) = match src_parts {
1047- None => return Ok ( ( ) ) , // Zero-sized *source*, that means dst is also zero-sized and we have nothing to do.
1048- Some ( src_ptr ) => src_ptr ,
1040+ let Some ( ( src_alloc_id, src_offset, src) ) = src_parts else {
1041+ // Zero-sized *source*, that means dst is also zero-sized and we have nothing to do.
1042+ return Ok ( ( ) ) ;
10491043 } ;
10501044 let src_alloc = self . get_raw ( src_alloc_id) ?;
10511045 let src_range = alloc_range ( src_offset, size) ;
10521046 M :: memory_read ( & self . extra , & src_alloc. extra , src. provenance , src_range) ?;
10531047 // We need the `dest` ptr for the next operation, so we get it now.
10541048 // We already did the source checks and called the hooks so we are good to return early.
1055- let ( dest_alloc_id, dest_offset, dest) = match dest_parts {
1056- None => return Ok ( ( ) ) , // Zero-sized *destiantion *.
1057- Some ( dest_ptr ) => dest_ptr ,
1049+ let Some ( ( dest_alloc_id, dest_offset, dest) ) = dest_parts else {
1050+ // Zero-sized *destination *.
1051+ return Ok ( ( ) ) ;
10581052 } ;
10591053
10601054 // This checks relocation edges on the src, which needs to happen before
0 commit comments