-
Notifications
You must be signed in to change notification settings - Fork 274
clippy: Disallow lock and instant types from std
#1458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7e407f6
9fcd0d8
9ef47d6
31f919e
19aa378
a2a0a75
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,22 @@ | ||
type-complexity-threshold = 500 | ||
disallowed-methods = [ | ||
# mutating environment variables in a multi-threaded context can | ||
# Mutating environment variables in a multi-threaded context can | ||
# cause data races. | ||
# see https://github.com/rust-lang/rust/issues/90308 for details. | ||
"std::env::set_var", | ||
"std::env::remove_var", | ||
|
||
# Avoid instances of https://github.com/rust-lang/rust/issues/86470 | ||
"std::time::Instant::duration_since", | ||
"std::time::Instant::elapsed", | ||
# Clippy doesn't let us ban std::time::Instant::sub, but it knows what it did. | ||
# Avoid instances of https://github.com/rust-lang/rust/issues/86470 until tokio/tokio#4461 is | ||
# available. | ||
"tokio::time::Instant::duration_since", | ||
"tokio::time::Instant::elapsed", | ||
# Clippy doesn't let us ban tokio::time::Instant::sub, but it knows what it did. | ||
] | ||
disallowed-types = [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think we might also need to add most uses are in tests, but there's at least one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks. fixed |
||
# Use parking_lot instead. | ||
"std::sync::Mutex", | ||
"std::sync::RwLock", | ||
|
||
# Use tokio::time::Instant instead. | ||
"std::time::Instant", | ||
Comment on lines
+16
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looking at the clippy docs, it seems like we can also add reasons to these, so that they're displayed with the warning when a disallowed type is used. we may want to add that, but not a blocker. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. afaict this isn't supported in our version of clippy There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, got it. could be nice to add later when it's available. |
||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol