diff --git a/clippy.toml b/clippy.toml index bd907936f..ab5283af0 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,3 +1,3 @@ disallowed-methods = [ - { path = "std::time::SystemTime::now", reason = "prefere using SleepProvider::wallclock instead when possible" }, +# { path = "std::time::SystemTime::now", reason = "prefere using SleepProvider::wallclock instead when possible" }, ] diff --git a/crates/arti-bench/src/main.rs b/crates/arti-bench/src/main.rs index 2d0cc5b66..80114f9ac 100644 --- a/crates/arti-bench/src/main.rs +++ b/crates/arti-bench/src/main.rs @@ -34,7 +34,6 @@ // This file uses `unwrap()` a fair deal, but this is fine in test/bench code // because it's OK if tests and benchmarks simply crash if things go wrong. #![allow(clippy::unwrap_used)] -#![allow(clippy::disallowed_methods)] use anyhow::{anyhow, Result}; use arti::cfg::ArtiConfig; diff --git a/crates/arti-client/src/status.rs b/crates/arti-client/src/status.rs index 0afe87d24..742f0ee4e 100644 --- a/crates/arti-client/src/status.rs +++ b/crates/arti-client/src/status.rs @@ -38,10 +38,7 @@ impl BootstrapStatus { /// 0 is defined as "just started"; 1 is defined as "ready to use." pub fn as_frac(&self) -> f32 { // Coefficients chosen arbitrarily. - #[allow(clippy::disallowed_methods)] - let res = - self.conn_status.frac() * 0.15 + self.dir_status.frac_at(SystemTime::now()) * 0.85; - res + self.conn_status.frac() * 0.15 + self.dir_status.frac_at(SystemTime::now()) * 0.85 } /// Return true if the status indicates that the client is ready for @@ -50,7 +47,6 @@ impl BootstrapStatus { /// For the purposes of this function, the client is "ready for traffic" if, /// as far as we know, we can start acting on a new client request immediately. pub fn ready_for_traffic(&self) -> bool { - #[allow(clippy::disallowed_methods)] let now = SystemTime::now(); self.conn_status.usable() && self.dir_status.usable_at(now) } diff --git a/crates/tor-checkable/src/lib.rs b/crates/tor-checkable/src/lib.rs index 1d07cc806..4cd02c857 100644 --- a/crates/tor-checkable/src/lib.rs +++ b/crates/tor-checkable/src/lib.rs @@ -119,7 +119,6 @@ pub trait Timebound: Sized { /// Unwrap this Timebound object if it is valid now. fn check_valid_now(self) -> Result { - #[allow(clippy::disallowed_methods)] self.check_valid_at(&time::SystemTime::now()) } diff --git a/crates/tor-circmgr/src/path/exitpath.rs b/crates/tor-circmgr/src/path/exitpath.rs index 67150fc4a..17c2d50d7 100644 --- a/crates/tor-circmgr/src/path/exitpath.rs +++ b/crates/tor-circmgr/src/path/exitpath.rs @@ -265,7 +265,6 @@ mod test { let dirinfo = (&netdir).into(); let config = PathConfig::default(); let guards: OptDummyGuardMgr<'_> = None; - #[allow(clippy::disallowed_methods)] let now = SystemTime::now(); for _ in 0..1000 { @@ -311,7 +310,6 @@ mod test { .unwrap(); let dirinfo = (&netdir).into(); let guards: OptDummyGuardMgr<'_> = None; - #[allow(clippy::disallowed_methods)] let now = SystemTime::now(); let config = PathConfig::default(); @@ -359,7 +357,6 @@ mod test { let dirinfo = (&netdir).into(); let guards: OptDummyGuardMgr<'_> = None; let config = PathConfig::default(); - #[allow(clippy::disallowed_methods)] let now = SystemTime::now(); // With target ports diff --git a/crates/tor-circmgr/src/usage.rs b/crates/tor-circmgr/src/usage.rs index ecd2984a5..d3cd171f5 100644 --- a/crates/tor-circmgr/src/usage.rs +++ b/crates/tor-circmgr/src/usage.rs @@ -667,7 +667,6 @@ pub(crate) mod test { let di = (&netdir).into(); let config = crate::PathConfig::default(); let guards: OptDummyGuardMgr<'_> = None; - #[allow(clippy::disallowed_methods)] let now = SystemTime::now(); // Only doing basic tests for now. We'll test the path @@ -745,7 +744,6 @@ pub(crate) mod test { let di = (&netdir).into(); let config = crate::PathConfig::default(); let guards: OptDummyGuardMgr<'_> = None; - #[allow(clippy::disallowed_methods)] let now = SystemTime::now(); let (path, usage, _, _) = TargetCircUsage::TimeoutTesting diff --git a/crates/tor-dirclient/src/lib.rs b/crates/tor-dirclient/src/lib.rs index 5f7fa58e1..457c257bf 100644 --- a/crates/tor-dirclient/src/lib.rs +++ b/crates/tor-dirclient/src/lib.rs @@ -502,7 +502,6 @@ mod test { ) -> (RequestResult<()>, Vec) { // We don't need to do anything fancy here, since we aren't simulating // a timeout. - #[allow(clippy::disallowed_methods)] let mock_time = MockSleepProvider::new(std::time::SystemTime::now()); let mut output = Vec::new(); diff --git a/crates/tor-dirclient/src/request.rs b/crates/tor-dirclient/src/request.rs index 7d376dac1..5c5a72f13 100644 --- a/crates/tor-dirclient/src/request.rs +++ b/crates/tor-dirclient/src/request.rs @@ -469,7 +469,6 @@ mod test { .unwrap(); let d2 = b"blah blah blah 12 blah blah blah"; - #[allow(clippy::disallowed_methods)] let d3 = SystemTime::now(); let mut req = ConsensusRequest::default(); diff --git a/crates/tor-dirmgr/src/bootstrap.rs b/crates/tor-dirmgr/src/bootstrap.rs index ec29c13a9..28974905c 100644 --- a/crates/tor-dirmgr/src/bootstrap.rs +++ b/crates/tor-dirmgr/src/bootstrap.rs @@ -380,7 +380,6 @@ mod test { #[test] fn week() { - #[allow(clippy::disallowed_methods)] let now = SystemTime::now(); let one_day = Duration::new(86400, 0); diff --git a/crates/tor-dirmgr/src/event.rs b/crates/tor-dirmgr/src/event.rs index dda2e5836..2ce627d31 100644 --- a/crates/tor-dirmgr/src/event.rs +++ b/crates/tor-dirmgr/src/event.rs @@ -633,7 +633,6 @@ mod test { #[test] fn dir_status_basics() { - #[allow(clippy::disallowed_methods)] let now = SystemTime::now(); let hour = Duration::new(3600, 0); diff --git a/crates/tor-guardmgr/src/guard.rs b/crates/tor-guardmgr/src/guard.rs index 5f722cb76..b48f1f5d0 100644 --- a/crates/tor-guardmgr/src/guard.rs +++ b/crates/tor-guardmgr/src/guard.rs @@ -693,7 +693,6 @@ mod test { fn basic_guard() -> Guard { let id = basic_id(); let ports = vec!["127.0.0.7:7777".parse().unwrap()]; - #[allow(clippy::disallowed_methods)] let added = SystemTime::now(); Guard::new(id, ports, added) } @@ -814,7 +813,6 @@ mod test { fn record_success() { let t1 = Instant::now() - Duration::from_secs(10); // has to be in the future, since the guard's "added_at" time is based on now. - #[allow(clippy::disallowed_methods)] let now = SystemTime::now(); let t2 = now + Duration::from_secs(300 * 86400); let t3 = Instant::now() + Duration::from_secs(310 * 86400); @@ -871,7 +869,6 @@ mod test { fn expiration() { const DAY: Duration = Duration::from_secs(24 * 60 * 60); let params = GuardParams::default(); - #[allow(clippy::disallowed_methods)] let now = SystemTime::now(); let g = basic_guard(); @@ -903,7 +900,6 @@ mod test { .unwrap_if_sufficient() .unwrap(); let params = GuardParams::default(); - #[allow(clippy::disallowed_methods)] let now = SystemTime::now(); // Construct a guard from a relay from the netdir. @@ -960,7 +956,6 @@ mod test { .unwrap(); //let params = GuardParams::default(); - #[allow(clippy::disallowed_methods)] let now = SystemTime::now(); // Try a guard that isn't in the netdir at all. @@ -1043,7 +1038,6 @@ mod test { let mut g = basic_guard(); let params = GuardParams::default(); - #[allow(clippy::disallowed_methods)] let now = SystemTime::now(); let _ignore = g.record_success(now, ¶ms); diff --git a/crates/tor-guardmgr/src/sample.rs b/crates/tor-guardmgr/src/sample.rs index 254f7a9fb..d620335e4 100644 --- a/crates/tor-guardmgr/src/sample.rs +++ b/crates/tor-guardmgr/src/sample.rs @@ -869,7 +869,6 @@ mod test { let mut samples: Vec> = Vec::new(); for _ in 0..3 { let mut guards = GuardSet::default(); - #[allow(clippy::disallowed_methods)] guards.extend_sample_as_needed(SystemTime::now(), ¶ms, &netdir); assert_eq!(guards.guards.len(), params.min_filtered_sample_size); assert_eq!(guards.confirmed.len(), 0); @@ -882,14 +881,12 @@ mod test { assert!(relay.is_flagged_guard()); assert!(relay.is_dir_cache()); assert!(guards.contains_relay(&relay)); - #[allow(clippy::disallowed_methods)] { assert!(!guard.is_expired(¶ms, SystemTime::now())); } } // Make sure that the sample doesn't expand any further. - #[allow(clippy::disallowed_methods)] guards.extend_sample_as_needed(SystemTime::now(), ¶ms, &netdir); assert_eq!(guards.guards.len(), params.min_filtered_sample_size); guards.assert_consistency(); @@ -910,7 +907,6 @@ mod test { ..GuardParams::default() }; - #[allow(clippy::disallowed_methods)] let t1 = SystemTime::now(); let t2 = t1 + Duration::from_secs(20); @@ -947,7 +943,6 @@ mod test { n_primary: 4, ..GuardParams::default() }; - #[allow(clippy::disallowed_methods)] let t1 = SystemTime::now(); let t2 = t1 + Duration::from_secs(20); let t3 = t2 + Duration::from_secs(30); @@ -994,7 +989,6 @@ mod test { fn expiration() { let netdir = netdir(); let params = GuardParams::default(); - #[allow(clippy::disallowed_methods)] let t1 = SystemTime::now(); let mut guards = GuardSet::default(); @@ -1029,7 +1023,6 @@ mod test { n_primary: 2, ..GuardParams::default() }; - #[allow(clippy::disallowed_methods)] let st1 = SystemTime::now(); let i1 = Instant::now(); let sec = Duration::from_secs(1); @@ -1153,7 +1146,6 @@ mod test { max_sample_bw_fraction: 1.0, ..GuardParams::default() }; - #[allow(clippy::disallowed_methods)] let mut st = SystemTime::now(); let mut inst = Instant::now(); let sec = Duration::from_secs(1); @@ -1196,7 +1188,6 @@ mod test { let mut guards = GuardSet::default(); - #[allow(clippy::disallowed_methods)] guards.extend_sample_as_needed(SystemTime::now(), ¶ms, &netdir); guards.select_primary_guards(¶ms); @@ -1234,13 +1225,11 @@ mod test { }; let usage = crate::GuardUsageBuilder::default().build().unwrap(); let mut guards = GuardSet::default(); - #[allow(clippy::disallowed_methods)] guards.extend_sample_as_needed(SystemTime::now(), ¶ms, &netdir); guards.select_primary_guards(¶ms); assert_eq!(guards.primary.len(), 2); let (_kind, p_id1) = guards.pick_guard(&usage, ¶ms).unwrap(); - #[allow(clippy::disallowed_methods)] guards.record_success(&p_id1, ¶ms, SystemTime::now()); assert_eq!(guards.missing_primary_microdescriptors(&netdir), 0); diff --git a/crates/tor-guardmgr/src/util.rs b/crates/tor-guardmgr/src/util.rs index 5e89e1a67..48aaab106 100644 --- a/crates/tor-guardmgr/src/util.rs +++ b/crates/tor-guardmgr/src/util.rs @@ -66,7 +66,6 @@ mod test { #[test] fn test_randomize_time() { - #[allow(clippy::disallowed_methods)] let now = SystemTime::now(); let one_hour = Duration::from_secs(3600); let ten_sec = Duration::from_secs(10); diff --git a/crates/tor-netdir/src/testnet.rs b/crates/tor-netdir/src/testnet.rs index d08a0ef17..a8ca364f4 100644 --- a/crates/tor-netdir/src/testnet.rs +++ b/crates/tor-netdir/src/testnet.rs @@ -138,7 +138,6 @@ where f | RelayFlags::EXIT | RelayFlags::GUARD, ]; - #[allow(clippy::disallowed_methods)] let now = SystemTime::now(); let one_day = Duration::new(86400, 0); let mut bld = MdConsensus::builder(); diff --git a/crates/tor-netdir/src/weight.rs b/crates/tor-netdir/src/weight.rs index ecf804885..a1170bbe5 100644 --- a/crates/tor-netdir/src/weight.rs +++ b/crates/tor-netdir/src/weight.rs @@ -619,7 +619,6 @@ mod test { #[test] fn weightset_from_consensus() { use rand::Rng; - #[allow(clippy::disallowed_methods)] let now = SystemTime::now(); let one_hour = Duration::new(3600, 0); let mut rng = rand::thread_rng(); diff --git a/crates/tor-netdoc/src/doc/authcert/build.rs b/crates/tor-netdoc/src/doc/authcert/build.rs index eb09e251d..7c29e171c 100644 --- a/crates/tor-netdoc/src/doc/authcert/build.rs +++ b/crates/tor-netdoc/src/doc/authcert/build.rs @@ -146,7 +146,6 @@ mod test { #[test] fn simple_cert() { - #[allow(clippy::disallowed_methods)] let now = SystemTime::now(); let one_hour = Duration::new(3600, 0); let later = now + one_hour * 2; @@ -167,7 +166,6 @@ mod test { #[test] fn failing_cert() { - #[allow(clippy::disallowed_methods)] let now = SystemTime::now(); let one_hour = Duration::new(3600, 0); let later = now + one_hour * 2; diff --git a/crates/tor-netdoc/src/doc/netstatus/build.rs b/crates/tor-netdoc/src/doc/netstatus/build.rs index e1eb350c7..0863b8eb2 100644 --- a/crates/tor-netdoc/src/doc/netstatus/build.rs +++ b/crates/tor-netdoc/src/doc/netstatus/build.rs @@ -377,7 +377,6 @@ mod test { #[test] fn consensus() { - #[allow(clippy::disallowed_methods)] let now = SystemTime::now(); let one_hour = Duration::new(3600, 0); diff --git a/crates/tor-rtcompat/src/timer.rs b/crates/tor-rtcompat/src/timer.rs index d06765186..f2e0dc7e5 100644 --- a/crates/tor-rtcompat/src/timer.rs +++ b/crates/tor-rtcompat/src/timer.rs @@ -203,7 +203,6 @@ mod test { } let minute = Duration::from_secs(60); let second = Duration::from_secs(1); - #[allow(clippy::disallowed_methods)] let start = SystemTime::now(); let target = start + 30 * minute; diff --git a/crates/tor-rtcompat/src/traits.rs b/crates/tor-rtcompat/src/traits.rs index 8707f3d88..0ec17c8e2 100644 --- a/crates/tor-rtcompat/src/traits.rs +++ b/crates/tor-rtcompat/src/traits.rs @@ -95,7 +95,6 @@ pub trait SleepProvider { /// /// (This is the same as `SystemTime::now`, if not running in test mode.) fn wallclock(&self) -> SystemTime { - #[allow(clippy::disallowed_methods)] SystemTime::now() } diff --git a/crates/tor-rtmock/src/sleep_runtime.rs b/crates/tor-rtmock/src/sleep_runtime.rs index 2a1df5135..bcbc9c306 100644 --- a/crates/tor-rtmock/src/sleep_runtime.rs +++ b/crates/tor-rtmock/src/sleep_runtime.rs @@ -26,7 +26,6 @@ impl MockSleepRuntime { /// Create a new runtime that wraps `runtime`, but overrides /// its view of time with a [`MockSleepProvider`]. pub fn new(runtime: R) -> Self { - #[allow(clippy::disallowed_methods)] let sleep = MockSleepProvider::new(SystemTime::now()); MockSleepRuntime { runtime, sleep } } diff --git a/crates/tor-rtmock/src/time.rs b/crates/tor-rtmock/src/time.rs index e0e3c0cf1..c4d703e7b 100644 --- a/crates/tor-rtmock/src/time.rs +++ b/crates/tor-rtmock/src/time.rs @@ -439,7 +439,6 @@ mod test { #[test] fn basics_of_time_travel() { - #[allow(clippy::disallowed_methods)] let w1 = SystemTime::now(); let sp = MockSleepProvider::new(w1); let i1 = sp.now(); @@ -462,7 +461,6 @@ mod test { use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering; - #[allow(clippy::disallowed_methods)] let sp = MockSleepProvider::new(SystemTime::now()); let one_hour = Duration::new(3600, 0); diff --git a/crates/tor-rtmock/tests/rtcompat_timing.rs b/crates/tor-rtmock/tests/rtcompat_timing.rs index 21d6622cb..6c4daf68b 100644 --- a/crates/tor-rtmock/tests/rtcompat_timing.rs +++ b/crates/tor-rtmock/tests/rtcompat_timing.rs @@ -17,7 +17,6 @@ fn timeouts() { oneshot::Sender<()>, Timeout, tor_rtmock::time::Sleeping>, ) { - #[allow(clippy::disallowed_methods)] let start = SystemTime::now(); let (send, recv) = oneshot::channel::<()>(); let mock_sp = MockSleepProvider::new(start);