chore: lints (#2725)

This commit is contained in:
Antonio 2026-05-11 14:15:51 +02:00 committed by GitHub
parent 80b43ae7a8
commit 77c503b6f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 32 additions and 8 deletions

View File

@ -399,7 +399,6 @@ shadow_same = { level = "allow" }
shadow_unrelated = { level = "allow" }
tests_outside_test_module = { level = "allow" }
todo = { level = "allow" }
unchecked_time_subtraction = { level = "allow" }
unimplemented = { level = "allow" }
unreachable = { level = "allow" }
unwrap_in_result = { level = "allow" }
@ -416,8 +415,10 @@ unused_results = { level = "allow" } # We have Clippy lints to warn o
ambiguous_negative_literals = { level = "warn" }
closure_returning_async_block = { level = "warn" }
deref_into_dyn_supertrait = { level = "warn" }
ffi_unwind_calls = { level = "warn" }
impl_trait_redundant_captures = { level = "warn" }
let_underscore_drop = { level = "warn" }
linker_messages = { level = "warn" }
macro_use_extern_crate = { level = "warn" }
missing_unsafe_on_extern = { level = "warn" }
redundant_imports = { level = "warn" }
@ -435,12 +436,10 @@ unused_lifetimes = { level = "warn" }
unused_macro_rules = { level = "warn" }
unused_qualifications = { level = "warn" }
# TODO: Address these allow-by-default Rustc lints at some point. To allow them, move them to the list of explicitly allowed lints. To enforce them, move them to the list of explicitly warned ones.
# TODO: Address these allow-by-default Rustc lints at some point. To allow them, simply remove them from this list. To enforce them, move them to the list of explicitly warned ones and mark them as "warn" level.
absolute_paths_not_starting_with_crate = { level = "allow" }
elided_lifetimes_in_paths = { level = "allow" }
ffi_unwind_calls = { level = "allow" }
impl_trait_overcaptures = { level = "allow" }
linker_messages = { level = "allow" }
missing_copy_implementations = { level = "allow" }
missing_debug_implementations = { level = "allow" }
missing_docs = { level = "allow" }

View File

@ -173,9 +173,10 @@ mod tests {
));
let elapsed = start_time.elapsed();
assert!(
elapsed.abs_diff(session_duration - transition_period) <= time_tolerance,
elapsed.abs_diff(session_duration.checked_sub(transition_period).unwrap())
<= time_tolerance,
"elapsed:{elapsed:?}, expected:{:?}",
session_duration - transition_period
session_duration.checked_sub(transition_period).unwrap()
);
// TransitionEnd should be emitted after transition_period.

View File

@ -1,7 +1,7 @@
#!/usr/bin/env sh
set -eu
# Enforces workspace dependency policy across Cargo manifests.
# Enforces workspace dependency and lint policy across Cargo manifests.
#
# Checks:
# - Workspace members must declare dependencies using `workspace = true` only
@ -9,6 +9,8 @@ set -eu
# - Workspace members must not override `default-features` on workspace deps.
# - Root `[workspace.dependencies]` entries must set `default-features = false`.
# - Root `[workspace.dependencies]` entries must not set `features`.
# - Workspace members must inherit lints from the workspace via a `[lints]`
# section containing `workspace = true`.
#
# Exit codes:
# - 0: all checks passed.
@ -84,6 +86,11 @@ function record_violation(rule, dep, line_no, details) {
printf("- [%s] %s:%d dependency=%s %s\n", rule, manifest_path, line_no, dep, details)
}
function record_manifest_violation(rule, details) {
violations += 1
printf("- [%s] %s %s\n", rule, manifest_path, details)
}
function braces_delta(s, opens, closes, copy) {
copy = s
opens = gsub(/\{/, "{", copy)
@ -188,6 +195,7 @@ function analyze_dependency_assignment(dep, value_text, line_no) {
BEGIN {
violations = 0
current_section = ""
lints_workspace_true = 0
reset_specific_state()
}
@ -257,6 +265,17 @@ BEGIN {
next
}
if (!is_root_manifest && current_section == "lints") {
eq_pos = index(line, "=")
if (eq_pos > 0) {
key = trim(substr(line, 1, eq_pos - 1))
value = trim(substr(line, eq_pos + 1))
if (key == "workspace" && value ~ /^true([[:space:]]|$)/) {
lints_workspace_true = 1
}
}
}
if ((is_root_manifest && current_section == "workspace.dependencies") ||
(!is_root_manifest && in_member_dependency_table(current_section))) {
eq_pos = index(line, "=")

View File

@ -12,3 +12,6 @@ version = { workspace = true }
[dependencies]
lb-core = { workspace = true }
serde = { features = ["derive"], workspace = true }
[lints]
workspace = true

View File

@ -39,7 +39,9 @@ impl CompressedRollingAppender {
inner: rolling_appender,
directory,
prefix: prefix_str,
last_compression: Instant::now() - compression_threshold,
last_compression: Instant::now()
.checked_sub(compression_threshold)
.expect("Specified compression threshold is too large."),
compression_threshold,
is_compressing: Arc::new(AtomicBool::new(false)),
}