summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/manual_instant_elapsed.fixed
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/tests/ui/manual_instant_elapsed.fixed')
-rw-r--r--src/tools/clippy/tests/ui/manual_instant_elapsed.fixed27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/manual_instant_elapsed.fixed b/src/tools/clippy/tests/ui/manual_instant_elapsed.fixed
new file mode 100644
index 000000000..0fa776b7b
--- /dev/null
+++ b/src/tools/clippy/tests/ui/manual_instant_elapsed.fixed
@@ -0,0 +1,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
+}