Skip to content

Commit b06f0d1

Browse files
committed
Use try block instead of closure
1 parent 06aaea1 commit b06f0d1

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/helpers.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,17 +530,17 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
530530
let nanoseconds_scalar = this.read_scalar(nanoseconds_place.into())?;
531531
let nanoseconds = nanoseconds_scalar.to_machine_isize(this)?;
532532

533-
Ok((move || {
533+
Ok(try {
534534
// tv_sec must be non-negative.
535535
let seconds: u64 = seconds.try_into().ok()?;
536536
// tv_nsec must be non-negative.
537537
let nanoseconds: u32 = nanoseconds.try_into().ok()?;
538538
if nanoseconds >= 1_000_000_000 {
539539
// tv_nsec must not be greater than 999,999,999.
540-
return None;
540+
None?
541541
}
542-
Some(Duration::new(seconds, nanoseconds))
543-
})())
542+
Duration::new(seconds, nanoseconds)
543+
})
544544
}
545545
}
546546

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![feature(map_first_last)]
44
#![feature(never_type)]
55
#![feature(or_patterns)]
6+
#![feature(try_blocks)]
67

78
#![warn(rust_2018_idioms)]
89
#![allow(clippy::cast_lossless)]

0 commit comments

Comments
 (0)