-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clippy: Disallow lock and instant types from
std
(#1458)
We use `parking_lot` locks throughout our code. This change disallows the introduction of std::sync's locks. This change also enforces the use of `tokio::time::Instant`, which allows for a mockable time source in tests. Signed-off-by: Oliver Gould <ver@buoyant.io>
- Loading branch information
Showing
89 changed files
with
514 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = [ | ||
# Use parking_lot instead. | ||
"std::sync::Mutex", | ||
"std::sync::RwLock", | ||
|
||
# Use tokio::time::Instant instead. | ||
"std::time::Instant", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.