Skip to content

Commit 32d4968

Browse files
committed
fmt
1 parent 6280e26 commit 32d4968

File tree

7 files changed

+27
-19
lines changed

7 files changed

+27
-19
lines changed

src/tools/miri/src/concurrency/init_once.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
3939
|ecx| &mut ecx.machine.sync.init_onces,
4040
|_| interp_ok(Default::default()),
4141
)?
42-
.ok_or_else(|| err_ub_format!("init_once has invalid ID")).into()
42+
.ok_or_else(|| err_ub_format!("init_once has invalid ID"))
43+
.into()
4344
}
4445

4546
#[inline]

src/tools/miri/src/concurrency/sync.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
307307
|ecx| &mut ecx.machine.sync.mutexes,
308308
|ecx| initialize_data(ecx).map(|data| Mutex { data, ..Default::default() }),
309309
)?
310-
.ok_or_else(|| err_ub_format!("mutex has invalid ID")).into()
310+
.ok_or_else(|| err_ub_format!("mutex has invalid ID"))
311+
.into()
311312
}
312313

313314
/// Retrieve the additional data stored for a mutex.
@@ -334,7 +335,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
334335
|ecx| &mut ecx.machine.sync.rwlocks,
335336
|ecx| initialize_data(ecx).map(|data| RwLock { data, ..Default::default() }),
336337
)?
337-
.ok_or_else(|| err_ub_format!("rwlock has invalid ID")).into()
338+
.ok_or_else(|| err_ub_format!("rwlock has invalid ID"))
339+
.into()
338340
}
339341

340342
/// Retrieve the additional data stored for a rwlock.
@@ -375,7 +377,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
375377
|ecx| &mut ecx.machine.sync.condvars,
376378
|ecx| initialize_data(ecx).map(|data| Condvar { data, ..Default::default() }),
377379
)?
378-
.ok_or_else(|| err_ub_format!("condvar has invalid ID")).into()
380+
.ok_or_else(|| err_ub_format!("condvar has invalid ID"))
381+
.into()
379382
}
380383

381384
/// Retrieve the additional data stored for a condvar.

src/tools/miri/src/helpers.rs

+13-11
Original file line numberDiff line numberDiff line change
@@ -752,17 +752,19 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
752752
let nanoseconds_scalar = this.read_scalar(&nanoseconds_place)?;
753753
let nanoseconds = nanoseconds_scalar.to_target_isize(this)?;
754754

755-
interp_ok(try {
756-
// tv_sec must be non-negative.
757-
let seconds: u64 = seconds.try_into().ok()?;
758-
// tv_nsec must be non-negative.
759-
let nanoseconds: u32 = nanoseconds.try_into().ok()?;
760-
if nanoseconds >= 1_000_000_000 {
761-
// tv_nsec must not be greater than 999,999,999.
762-
None?
763-
}
764-
Duration::new(seconds, nanoseconds)
765-
})
755+
interp_ok(
756+
try {
757+
// tv_sec must be non-negative.
758+
let seconds: u64 = seconds.try_into().ok()?;
759+
// tv_nsec must be non-negative.
760+
let nanoseconds: u32 = nanoseconds.try_into().ok()?;
761+
if nanoseconds >= 1_000_000_000 {
762+
// tv_nsec must not be greater than 999,999,999.
763+
None?
764+
}
765+
Duration::new(seconds, nanoseconds)
766+
},
767+
)
766768
}
767769

768770
/// Read bytes from a byte slice.

src/tools/miri/src/shims/time.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ use crate::*;
1111
/// Returns the time elapsed between the provided time and the unix epoch as a `Duration`.
1212
pub fn system_time_to_duration<'tcx>(time: &SystemTime) -> InterpResult<'tcx, Duration> {
1313
time.duration_since(SystemTime::UNIX_EPOCH)
14-
.map_err(|_| err_unsup_format!("times before the Unix epoch are not supported")).into()
14+
.map_err(|_| err_unsup_format!("times before the Unix epoch are not supported"))
15+
.into()
1516
}
1617

1718
impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
517517
let start = this.read_scalar(&args[2])?.to_i32()?;
518518

519519
match this.machine.fds.get(fd_num) {
520-
Some(fd) => interp_ok(Scalar::from_i32(this.machine.fds.insert_with_min_num(fd, start))),
520+
Some(fd) =>
521+
interp_ok(Scalar::from_i32(this.machine.fds.insert_with_min_num(fd, start))),
521522
None => interp_ok(Scalar::from_i32(this.fd_not_found()?)),
522523
}
523524
} else if this.tcx.sess.target.os == "macos" && cmd == this.eval_libc_i32("F_FULLFSYNC") {

src/tools/miri/tests/fail/data_race/mixed_size_read_read_write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Two variants: the atomic store matches the size of the first or second atomic load.
55
//@revisions: match_first_load match_second_load
66

7-
use std::sync::atomic::{AtomicU16, AtomicU8, Ordering};
7+
use std::sync::atomic::{AtomicU8, AtomicU16, Ordering};
88
use std::thread;
99

1010
fn convert(a: &AtomicU16) -> &[AtomicU8; 2] {

src/tools/miri/tests/fail/data_race/mixed_size_read_write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Two revisions, depending on which access goes first.
55
//@revisions: read_write write_read
66

7-
use std::sync::atomic::{AtomicU16, AtomicU8, Ordering};
7+
use std::sync::atomic::{AtomicU8, AtomicU16, Ordering};
88
use std::thread;
99

1010
fn convert(a: &AtomicU16) -> &[AtomicU8; 2] {

0 commit comments

Comments
 (0)