Setup global cargo lint configuration (#13691)

# Description
`cargo` somewhat recently gained the capability to store `lints`
settings for the crate and workspace, that can override the defaults
from `rustc` and `clippy` lints. This means we can enforce some lints
without having to actively pass them to clippy via `cargo clippy -- -W
...`. So users just forking the repo have an easier time to follow
similar requirements like our CI.

## Limitation

An exception that remains is that those lints apply to both the primary
code base and the tests. Thus we can't include e.g. `unwrap_used`
without generating noise in the tests. Here the setup in the CI remains
the most helpful.

## Included lints

- Add `clippy::unchecked_duration_subtraction` (added by #12549)
# User-Facing Changes
Running `cargo clippy --workspace` should be closer to the CI. This has
benefits for editor configured runs of clippy and saves you from having
to use `toolkit` to be close to CI in more cases.
This commit is contained in:
Stefan Holderbach
2024-08-28 23:37:17 +02:00
committed by GitHub
parent 644bebf4c6
commit 84e1ac27e5
31 changed files with 126 additions and 30 deletions

View File

@ -244,7 +244,7 @@ mod tests {
let mut state = test_state();
state.config.enabled = true;
state.config.stop_after = Duration::from_secs(1).as_nanos() as i64;
state.last_update = Some(now - Duration::from_secs(2));
state.last_update = Some(now.checked_sub(Duration::from_secs(2)).unwrap());
assert_eq!(Some(Duration::ZERO), state.next_timeout(now));
}
@ -295,7 +295,8 @@ mod tests {
#[test]
fn adding_locks_changes_last_update() {
let mut state = test_state();
let original_last_update = Some(Instant::now() - Duration::from_secs(1));
let original_last_update =
Some(Instant::now().checked_sub(Duration::from_secs(1)).unwrap());
state.last_update = original_last_update;
state.handle_message(PluginGcMsg::AddLocks(1));
assert_ne!(original_last_update, state.last_update, "not updated");