style(clippy): ban direct use of std::time::SystemTime::now (#1043)
This commit is contained in:
3
clippy.toml
Normal file
3
clippy.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
disallowed-methods = [
|
||||
{ "path" = "std::time::SystemTime::now", reason = "does not work on WASM environments", replacement = "crate::time::now" }
|
||||
]
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user