#![warn(clippy::manual_instant_elapsed)]
#![allow(clippy::unnecessary_operation)]
#![allow(clippy::unchecked_time_subtraction)]
#![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();
    //~^ manual_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
    //
    //~^^ manual_instant_elapsed
}

fn issue16236() {
    use std::ops::Sub as _;
    macro_rules! deref {
        ($e:expr) => {
            *$e
        };
    }

    let start = &Instant::now();
    let _ = deref!(start).elapsed();
    //~^ manual_instant_elapsed

    deref!(start).elapsed();
    //~^ manual_instant_elapsed
}
