@@ -1309,29 +1309,20 @@ impl<'a, 'tcx, Prov: Provenance, Extra, Bytes: AllocBytes>
1309
1309
}
1310
1310
1311
1311
/// Mark the given sub-range (relative to this allocation reference) as uninitialized.
1312
- pub fn write_uninit ( & mut self , range : AllocRange ) -> InterpResult < ' tcx > {
1312
+ pub fn write_uninit ( & mut self , range : AllocRange ) {
1313
1313
let range = self . range . subrange ( range) ;
1314
1314
1315
- self . alloc
1316
- . write_uninit ( & self . tcx , range)
1317
- . map_err ( |e| e. to_interp_error ( self . alloc_id ) )
1318
- . into ( )
1315
+ self . alloc . write_uninit ( & self . tcx , range) ;
1319
1316
}
1320
1317
1321
1318
/// Mark the entire referenced range as uninitialized
1322
- pub fn write_uninit_full ( & mut self ) -> InterpResult < ' tcx > {
1323
- self . alloc
1324
- . write_uninit ( & self . tcx , self . range )
1325
- . map_err ( |e| e. to_interp_error ( self . alloc_id ) )
1326
- . into ( )
1319
+ pub fn write_uninit_full ( & mut self ) {
1320
+ self . alloc . write_uninit ( & self . tcx , self . range ) ;
1327
1321
}
1328
1322
1329
1323
/// Remove all provenance in the reference range.
1330
- pub fn clear_provenance ( & mut self ) -> InterpResult < ' tcx > {
1331
- self . alloc
1332
- . clear_provenance ( & self . tcx , self . range )
1333
- . map_err ( |e| e. to_interp_error ( self . alloc_id ) )
1334
- . into ( )
1324
+ pub fn clear_provenance ( & mut self ) {
1325
+ self . alloc . clear_provenance ( & self . tcx , self . range ) ;
1335
1326
}
1336
1327
}
1337
1328
@@ -1422,11 +1413,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
1422
1413
1423
1414
// Side-step AllocRef and directly access the underlying bytes more efficiently.
1424
1415
// (We are staying inside the bounds here and all bytes do get overwritten so all is good.)
1425
- let alloc_id = alloc_ref. alloc_id ;
1426
- let bytes = alloc_ref
1427
- . alloc
1428
- . get_bytes_unchecked_for_overwrite ( & alloc_ref. tcx , alloc_ref. range )
1429
- . map_err ( move |e| e. to_interp_error ( alloc_id) ) ?;
1416
+ let bytes =
1417
+ alloc_ref. alloc . get_bytes_unchecked_for_overwrite ( & alloc_ref. tcx , alloc_ref. range ) ;
1430
1418
// `zip` would stop when the first iterator ends; we want to definitely
1431
1419
// cover all of `bytes`.
1432
1420
for dest in bytes {
@@ -1508,10 +1496,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
1508
1496
// `get_bytes_mut` will clear the provenance, which is correct,
1509
1497
// since we don't want to keep any provenance at the target.
1510
1498
// This will also error if copying partial provenance is not supported.
1511
- let provenance = src_alloc
1512
- . provenance ( )
1513
- . prepare_copy ( src_range, dest_offset, num_copies, self )
1514
- . map_err ( |e| e. to_interp_error ( src_alloc_id) ) ?;
1499
+ let provenance =
1500
+ src_alloc. provenance ( ) . prepare_copy ( src_range, dest_offset, num_copies, self ) ;
1515
1501
// Prepare a copy of the initialization mask.
1516
1502
let init = src_alloc. init_mask ( ) . prepare_copy ( src_range) ;
1517
1503
@@ -1529,10 +1515,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
1529
1515
dest_range,
1530
1516
) ?;
1531
1517
// Yes we do overwrite all bytes in `dest_bytes`.
1532
- let dest_bytes = dest_alloc
1533
- . get_bytes_unchecked_for_overwrite_ptr ( & tcx, dest_range)
1534
- . map_err ( |e| e. to_interp_error ( dest_alloc_id) ) ?
1535
- . as_mut_ptr ( ) ;
1518
+ let dest_bytes =
1519
+ dest_alloc. get_bytes_unchecked_for_overwrite_ptr ( & tcx, dest_range) . as_mut_ptr ( ) ;
1536
1520
1537
1521
if init. no_bytes_init ( ) {
1538
1522
// Fast path: If all bytes are `uninit` then there is nothing to copy. The target range
@@ -1541,9 +1525,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
1541
1525
// This also avoids writing to the target bytes so that the backing allocation is never
1542
1526
// touched if the bytes stay uninitialized for the whole interpreter execution. On contemporary
1543
1527
// operating system this can avoid physically allocating the page.
1544
- dest_alloc
1545
- . write_uninit ( & tcx, dest_range)
1546
- . map_err ( |e| e. to_interp_error ( dest_alloc_id) ) ?;
1528
+ dest_alloc. write_uninit ( & tcx, dest_range) ;
1547
1529
// `write_uninit` also resets the provenance, so we are done.
1548
1530
return interp_ok ( ( ) ) ;
1549
1531
}
0 commit comments