Skip to content

Commit d6f52bf

Browse files
author
The Miri Conjob Bot
committed
fmt
1 parent 2ca415c commit d6f52bf

File tree

11 files changed

+14
-49
lines changed

11 files changed

+14
-49
lines changed

src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,7 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<'
206206
// Make sure the new permission makes sense as the initial permission of a fresh tag.
207207
assert!(new_perm.initial_state.is_initial());
208208
// Ensure we bail out if the pointer goes out-of-bounds (see miri#1050).
209-
this.check_ptr_access(
210-
place.ptr(),
211-
ptr_size,
212-
CheckInAllocMsg::InboundsTest,
213-
)?;
209+
this.check_ptr_access(place.ptr(), ptr_size, CheckInAllocMsg::InboundsTest)?;
214210

215211
// It is crucial that this gets called on all code paths, to ensure we track tag creation.
216212
let log_creation = |this: &MiriInterpCx<'mir, 'tcx>,

src/tools/miri/src/concurrency/data_race.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,10 +1017,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> {
10171017
// even if the type they wrap would be less aligned (e.g. AtomicU64 on 32bit must
10181018
// be 8-aligned).
10191019
let align = Align::from_bytes(place.layout.size.bytes()).unwrap();
1020-
this.check_ptr_align(
1021-
place.ptr(),
1022-
align,
1023-
)?;
1020+
this.check_ptr_align(place.ptr(), align)?;
10241021
// Ensure the allocation is mutable. Even failing (read-only) compare_exchange need mutable
10251022
// memory on many targets (i.e., they segfault if taht memory is mapped read-only), and
10261023
// atomic loads can be implemented via compare_exchange on some targets. There could

src/tools/miri/src/helpers.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -868,9 +868,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
868868
let size2 = Size::from_bytes(2);
869869
let this = self.eval_context_mut();
870870
this.check_ptr_align(ptr, Align::from_bytes(2).unwrap())?;
871-
let mut alloc = this
872-
.get_ptr_alloc_mut(ptr, size2 * string_length)?
873-
.unwrap(); // not a ZST, so we will get a result
871+
let mut alloc = this.get_ptr_alloc_mut(ptr, size2 * string_length)?.unwrap(); // not a ZST, so we will get a result
874872
for (offset, wchar) in wide_str.iter().copied().chain(iter::once(0x0000)).enumerate() {
875873
let offset = u64::try_from(offset).unwrap();
876874
alloc.write_scalar(alloc_range(size2 * offset, size2), Scalar::from_u16(wchar))?;

src/tools/miri/src/shims/foreign_items.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -805,12 +805,7 @@ trait EvalContextExtPriv<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
805805
this.ptr_get_alloc_id(ptr_dest)?;
806806
this.ptr_get_alloc_id(ptr_src)?;
807807

808-
this.mem_copy(
809-
ptr_src,
810-
ptr_dest,
811-
Size::from_bytes(n),
812-
true,
813-
)?;
808+
this.mem_copy(ptr_src, ptr_dest, Size::from_bytes(n), true)?;
814809
this.write_pointer(ptr_dest, dest)?;
815810
}
816811
"strcpy" => {
@@ -826,12 +821,7 @@ trait EvalContextExtPriv<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
826821
// reason to have `strcpy` destroy pointer provenance.
827822
// This reads at least 1 byte, so we are already enforcing that this is a valid pointer.
828823
let n = this.read_c_str(ptr_src)?.len().checked_add(1).unwrap();
829-
this.mem_copy(
830-
ptr_src,
831-
ptr_dest,
832-
Size::from_bytes(n),
833-
true,
834-
)?;
824+
this.mem_copy(ptr_src, ptr_dest, Size::from_bytes(n), true)?;
835825
this.write_pointer(ptr_dest, dest)?;
836826
}
837827

src/tools/miri/src/shims/unix/fs.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -756,11 +756,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
756756
trace!("Reading from FD {}, size {}", fd, count);
757757

758758
// Check that the *entire* buffer is actually valid memory.
759-
this.check_ptr_access(
760-
buf,
761-
Size::from_bytes(count),
762-
CheckInAllocMsg::MemoryAccessTest,
763-
)?;
759+
this.check_ptr_access(buf, Size::from_bytes(count), CheckInAllocMsg::MemoryAccessTest)?;
764760

765761
// We cap the number of read bytes to the largest value that we are able to fit in both the
766762
// host's and target's `isize`. This saves us from having to handle overflows later.
@@ -809,11 +805,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
809805
// Isolation check is done via `FileDescriptor` trait.
810806

811807
// Check that the *entire* buffer is actually valid memory.
812-
this.check_ptr_access(
813-
buf,
814-
Size::from_bytes(count),
815-
CheckInAllocMsg::MemoryAccessTest,
816-
)?;
808+
this.check_ptr_access(buf, Size::from_bytes(count), CheckInAllocMsg::MemoryAccessTest)?;
817809

818810
// We cap the number of written bytes to the largest value that we are able to fit in both the
819811
// host's and target's `isize`. This saves us from having to handle overflows later.

src/tools/miri/src/shims/unix/linux/sync.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,7 @@ pub fn futex<'tcx>(
8585
return Ok(());
8686
}
8787

88-
let timeout = this.deref_pointer_as(
89-
&args[3],
90-
this.libc_ty_layout("timespec"),
91-
)?;
88+
let timeout = this.deref_pointer_as(&args[3], this.libc_ty_layout("timespec"))?;
9289
let timeout_time = if this.ptr_is_null(timeout.ptr())? {
9390
None
9491
} else {

src/tools/miri/src/shims/windows/sync.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
321321
this.atomic_fence(AtomicFenceOrd::SeqCst)?;
322322

323323
let layout = this.machine.layouts.uint(size).unwrap();
324-
let futex_val = this
325-
.read_scalar_atomic(&this.ptr_to_mplace(ptr, layout), AtomicReadOrd::Relaxed)?;
324+
let futex_val =
325+
this.read_scalar_atomic(&this.ptr_to_mplace(ptr, layout), AtomicReadOrd::Relaxed)?;
326326
let compare_val = this.read_scalar(&this.ptr_to_mplace(compare, layout))?;
327327

328328
if futex_val == compare_val {

src/tools/miri/src/shims/x86/sse3.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,7 @@ pub(super) trait EvalContextExt<'mir, 'tcx: 'mir>:
7373
let src_ptr = this.read_pointer(src_ptr)?;
7474
let dest = dest.force_mplace(this)?;
7575

76-
this.mem_copy(
77-
src_ptr,
78-
dest.ptr(),
79-
dest.layout.size,
80-
/*nonoverlapping*/ true,
81-
)?;
76+
this.mem_copy(src_ptr, dest.ptr(), dest.layout.size, /*nonoverlapping*/ true)?;
8277
}
8378
_ => return Ok(EmulateForeignItemResult::NotSupported),
8479
}

src/tools/miri/tests/fail/dangling_pointers/deref_dangling_box.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Should be caught even without retagging
22
//@compile-flags: -Zmiri-disable-stacked-borrows
33
#![feature(strict_provenance)]
4-
use std::ptr::{addr_of_mut, self};
4+
use std::ptr::{self, addr_of_mut};
55

66
// Deref'ing a dangling raw pointer is fine, but for a dangling box it is not.
77
// We do this behind a pointer indirection to potentially fool validity checking.

src/tools/miri/tests/fail/dangling_pointers/deref_dangling_ref.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Should be caught even without retagging
22
//@compile-flags: -Zmiri-disable-stacked-borrows
33
#![feature(strict_provenance)]
4-
use std::ptr::{addr_of_mut, self};
4+
use std::ptr::{self, addr_of_mut};
55

66
// Deref'ing a dangling raw pointer is fine, but for a dangling reference it is not.
77
// We do this behind a pointer indirection to potentially fool validity checking.

src/tools/miri/tests/pass/ptr_raw.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![feature(strict_provenance)]
2-
use std::ptr::{self, addr_of};
32
use std::mem;
3+
use std::ptr::{self, addr_of};
44

55
fn basic_raw() {
66
let mut x = 12;

0 commit comments

Comments
 (0)