]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/manual_instant_elapsed.rs
Rollup merge of #102345 - chenyukang:fix-102182-impl-trait, r=estebank
[rust.git] / src / tools / clippy / tests / ui / manual_instant_elapsed.rs
1 // run-rustfix
2 #![warn(clippy::manual_instant_elapsed)]
3 #![allow(clippy::unnecessary_operation)]
4 #![allow(unused_variables)]
5 #![allow(unused_must_use)]
6
7 use std::time::Instant;
8
9 fn main() {
10     let prev_instant = Instant::now();
11
12     {
13         // don't influence
14         let another_instant = Instant::now();
15     }
16
17     let duration = Instant::now() - prev_instant;
18
19     // don't catch
20     let duration = prev_instant.elapsed();
21
22     Instant::now() - duration;
23
24     let ref_to_instant = &Instant::now();
25
26     Instant::now() - *ref_to_instant; // to ensure parens are added correctly
27 }