diff options
Diffstat (limited to 'src/tools/clippy/tests/ui/unchecked_duration_subtraction.fixed')
-rw-r--r-- | src/tools/clippy/tests/ui/unchecked_duration_subtraction.fixed | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/unchecked_duration_subtraction.fixed b/src/tools/clippy/tests/ui/unchecked_duration_subtraction.fixed new file mode 100644 index 000000000..a0e49a8be --- /dev/null +++ b/src/tools/clippy/tests/ui/unchecked_duration_subtraction.fixed @@ -0,0 +1,17 @@ +// run-rustfix +#![warn(clippy::unchecked_duration_subtraction)] + +use std::time::{Duration, Instant}; + +fn main() { + let _first = Instant::now(); + let second = Duration::from_secs(3); + + let _ = _first.checked_sub(second).unwrap(); + + let _ = Instant::now().checked_sub(Duration::from_secs(5)).unwrap(); + + let _ = _first.checked_sub(Duration::from_secs(5)).unwrap(); + + let _ = Instant::now().checked_sub(second).unwrap(); +} |