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