summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/unchecked_duration_subtraction.fixed
blob: 757d159218472b89366c135693df5282a6f238b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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();
}