summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/manual_instant_elapsed.fixed
blob: 0fa776b7b2e4ed4b504691488e28d6ba9451b1f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// run-rustfix
#![warn(clippy::manual_instant_elapsed)]
#![allow(clippy::unnecessary_operation)]
#![allow(unused_variables)]
#![allow(unused_must_use)]

use std::time::Instant;

fn main() {
    let prev_instant = Instant::now();

    {
        // don't influence
        let another_instant = Instant::now();
    }

    let duration = prev_instant.elapsed();

    // don't catch
    let duration = prev_instant.elapsed();

    Instant::now() - duration;

    let ref_to_instant = &Instant::now();

    (*ref_to_instant).elapsed(); // to ensure parens are added correctly
}