style(clippy): ban direct use of std::time::SystemTime::now (#1043)

This commit is contained in:
Paolo Barbolini
2025-02-22 09:32:38 +01:00
committed by GitHub
parent 54934e1492
commit 2d1ccda2ef
2 changed files with 11 additions and 0 deletions

3
clippy.toml Normal file
View File

@@ -0,0 +1,3 @@
disallowed-methods = [
{ "path" = "std::time::SystemTime::now", reason = "does not work on WASM environments", replacement = "crate::time::now" }
]

View File

@@ -9,10 +9,18 @@ pub(crate) fn now() -> SystemTime {
SystemTime::UNIX_EPOCH + duration
}
// FIXME: change to:
// #[allow(
// clippy::disallowed_methods,
// reason = "`web-time` aliases `std::time::SystemTime::now` on non-WASM platforms"
// )]
#[allow(clippy::disallowed_methods)]
to_std_systemtime(web_time::SystemTime::now())
}
#[cfg(not(feature = "web"))]
pub(crate) fn now() -> SystemTime {
// FIXME: change to #[expect(clippy::disallowed_methods, reason = "the `web` feature is disabled")]
#[allow(clippy::disallowed_methods)]
SystemTime::now()
}