@@ -291,21 +291,18 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
291
291
) ;
292
292
}
293
293
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)
306
299
}
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) ) ,
308
304
}
305
+ . into ( ) ) ;
309
306
} ;
310
307
311
308
if alloc. mutability == Mutability :: Not {
@@ -957,9 +954,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
957
954
ptr : Pointer < Option < M :: PointerTag > > ,
958
955
size : Size ,
959
956
) -> 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 ( & [ ] ) ;
963
960
} ;
964
961
// Side-step AllocRef and directly access the underlying bytes more efficiently.
965
962
// (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> {
983
980
assert_eq ! ( lower, len, "can only write iterators with a precise length" ) ;
984
981
985
982
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 ( ( ) ) ;
997
991
} ;
998
992
999
993
// 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> {
1043
1037
// and once below to get the underlying `&[mut] Allocation`.
1044
1038
1045
1039
// 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 ( ( ) ) ;
1049
1043
} ;
1050
1044
let src_alloc = self . get_raw ( src_alloc_id) ?;
1051
1045
let src_range = alloc_range ( src_offset, size) ;
1052
1046
M :: memory_read ( & self . extra , & src_alloc. extra , src. provenance , src_range) ?;
1053
1047
// We need the `dest` ptr for the next operation, so we get it now.
1054
1048
// 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 ( ( ) ) ;
1058
1052
} ;
1059
1053
1060
1054
// This checks relocation edges on the src, which needs to happen before
0 commit comments