From ec315dc12725ba3376cab9124112e5a97a2f9c79 Mon Sep 17 00:00:00 2001 From: Cui Date: Fri, 28 Aug 2026 19:52:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(build):=20unblock=20CI=20native=20gate=20?= =?UTF-8?q?=E2=80=94=20autobenches=20+=20clippy=20clean=20(R-00261)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `.github/workflows/repository-policy.yml` job `native` was red on main: `cargo clippy --workspace --all-targets -- -D warnings` exited 101 for two independent reasons. (a) bench target compile failure `crates/lumio-platform/benches/clock.rs` is compiled as a `cfg(test)` module via `#[path]` from `lib.rs` (criterion is not approved; EXTERNAL_ALLOWLIST is empty). Living under `benches/` also made Cargo auto-register it as a bench target, where `use crate::{MonotonicClock, StdMonotonicClock}` does not resolve (E0432), so `--all-targets` and `--benches` both failed. `cargo test` never builds bench targets, which is why this stayed hidden. Fixed with `autobenches = false`, keeping the file and its `cargo test` coverage exactly where they were. (b) 14 clippy diagnostics 13 `new_without_default` across platform/kernel/job/spatial/codec/test-support and 1 `collapsible_if` in `xtask/src/baseline.rs`. Every flagged `new()` is a no-arg empty constructor, so `Default` is semantically sound; each forwards to `Self::new()`. No lint is silenced with `#[allow]`. No behaviour change, no public API semantics change, no new dependency (Cargo.lock untouched, external deps still 0). Verified at this commit on x86_64-apple-darwin and aarch64-apple-darwin: cargo clippy --workspace --all-targets -- -D warnings exit 0 cargo clippy --workspace --all-targets --all-features -- -D warnings exit 0 cargo build --workspace --benches exit 0 cargo test --workspace exit 0 90 passed/0 failed cargo test --workspace --all-features exit 0 cargo test --workspace --no-default-features exit 0 cargo fmt --all -- --check exit 0 cargo xtask check-dep-dag / dump-symbols / check-baseline exit 0 node .spec/tools/spec-lint.mjs && node --test spec-lint.test.mjs exit 0 clock_benchmark::clock_benchmark_reports_distribution ... ok Co-Authored-By: Claude Opus 5 --- crates/lumio-codec/src/resource.rs | 12 ++++++++++++ crates/lumio-job/src/cancel.rs | 6 ++++++ crates/lumio-job/src/operation.rs | 6 ++++++ crates/lumio-kernel/src/context/registry.rs | 6 ++++++ crates/lumio-platform/Cargo.toml | 5 +++++ crates/lumio-platform/src/clock.rs | 6 ++++++ .../lumio-spatial/src/index/grid_reference.rs | 6 ++++++ .../lumio-spatial/src/index/rstar_adapter.rs | 6 ++++++ crates/lumio-spatial/src/query.rs | 6 ++++++ crates/lumio-spatial/src/resource.rs | 6 ++++++ crates/lumio-test-support/src/fixtures.rs | 18 ++++++++++++++++++ xtask/src/baseline.rs | 12 ++++++------ 12 files changed, 89 insertions(+), 6 deletions(-) diff --git a/crates/lumio-codec/src/resource.rs b/crates/lumio-codec/src/resource.rs index bbb9724..9c99f9e 100644 --- a/crates/lumio-codec/src/resource.rs +++ b/crates/lumio-codec/src/resource.rs @@ -11,6 +11,12 @@ pub struct CodecWorkspace { scratch: Mutex>, } +impl Default for CodecWorkspace { + fn default() -> Self { + Self::new() + } +} + impl CodecWorkspace { pub fn new() -> Self { Self { @@ -41,6 +47,12 @@ pub struct CodecResource { destroyed: AtomicBool, } +impl Default for CodecResource { + fn default() -> Self { + Self::new() + } +} + impl CodecResource { pub fn new() -> Self { Self { diff --git a/crates/lumio-job/src/cancel.rs b/crates/lumio-job/src/cancel.rs index 55dd99e..1fa58bb 100644 --- a/crates/lumio-job/src/cancel.rs +++ b/crates/lumio-job/src/cancel.rs @@ -16,6 +16,12 @@ pub struct CancellationView { flag: Arc, } +impl Default for CancellationSource { + fn default() -> Self { + Self::new() + } +} + impl CancellationSource { pub fn new() -> Self { Self { diff --git a/crates/lumio-job/src/operation.rs b/crates/lumio-job/src/operation.rs index 9a942c2..c703cca 100644 --- a/crates/lumio-job/src/operation.rs +++ b/crates/lumio-job/src/operation.rs @@ -17,6 +17,12 @@ pub struct OperationRegistry { kernels: HashMap>, } +impl Default for OperationRegistry { + fn default() -> Self { + Self::new() + } +} + impl OperationRegistry { pub fn new() -> Self { Self { diff --git a/crates/lumio-kernel/src/context/registry.rs b/crates/lumio-kernel/src/context/registry.rs index e63d16a..c49363a 100644 --- a/crates/lumio-kernel/src/context/registry.rs +++ b/crates/lumio-kernel/src/context/registry.rs @@ -15,6 +15,12 @@ pub struct ResourceRegistry { items: Mutex>>, } +impl Default for ResourceRegistry { + fn default() -> Self { + Self::new() + } +} + impl ResourceRegistry { pub fn new() -> Self { Self { diff --git a/crates/lumio-platform/Cargo.toml b/crates/lumio-platform/Cargo.toml index 0742fd2..e7bd235 100644 --- a/crates/lumio-platform/Cargo.toml +++ b/crates/lumio-platform/Cargo.toml @@ -3,5 +3,10 @@ name = "lumio-platform" version.workspace = true edition.workspace = true publish.workspace = true +# `benches/clock.rs` is compiled as a `cfg(test)` module via `#[path]` from `lib.rs` +# (criterion is not approved; EXTERNAL_ALLOWLIST is empty). Cargo's bench +# auto-discovery would additionally register it as a bench target, where its +# `use crate::{..}` does not resolve (E0432) and `--all-targets` fails. +autobenches = false [dependencies] diff --git a/crates/lumio-platform/src/clock.rs b/crates/lumio-platform/src/clock.rs index a95c60f..2184642 100644 --- a/crates/lumio-platform/src/clock.rs +++ b/crates/lumio-platform/src/clock.rs @@ -65,6 +65,12 @@ pub struct StdMonotonicClock { epoch: Instant, } +impl Default for StdMonotonicClock { + fn default() -> Self { + Self::new() + } +} + impl StdMonotonicClock { pub fn new() -> Self { Self { diff --git a/crates/lumio-spatial/src/index/grid_reference.rs b/crates/lumio-spatial/src/index/grid_reference.rs index 1446589..b5cd3dc 100644 --- a/crates/lumio-spatial/src/index/grid_reference.rs +++ b/crates/lumio-spatial/src/index/grid_reference.rs @@ -14,6 +14,12 @@ pub struct GridReferenceIndex { objects: BTreeMap, } +impl Default for GridReferenceIndex { + fn default() -> Self { + Self::new() + } +} + impl GridReferenceIndex { pub fn new() -> Self { Self { diff --git a/crates/lumio-spatial/src/index/rstar_adapter.rs b/crates/lumio-spatial/src/index/rstar_adapter.rs index 846329e..76433dc 100644 --- a/crates/lumio-spatial/src/index/rstar_adapter.rs +++ b/crates/lumio-spatial/src/index/rstar_adapter.rs @@ -18,6 +18,12 @@ pub struct RStarIndexAdapter { inner: GridReferenceIndex, } +impl Default for RStarIndexAdapter { + fn default() -> Self { + Self::new() + } +} + impl RStarIndexAdapter { pub fn new() -> Self { Self { diff --git a/crates/lumio-spatial/src/query.rs b/crates/lumio-spatial/src/query.rs index c6c7d94..d34e066 100644 --- a/crates/lumio-spatial/src/query.rs +++ b/crates/lumio-spatial/src/query.rs @@ -23,6 +23,12 @@ pub struct SpatialContext { index: GridReferenceIndex, } +impl Default for SpatialContext { + fn default() -> Self { + Self::new() + } +} + impl SpatialContext { pub fn new() -> Self { Self { diff --git a/crates/lumio-spatial/src/resource.rs b/crates/lumio-spatial/src/resource.rs index d5536ef..c1c7b66 100644 --- a/crates/lumio-spatial/src/resource.rs +++ b/crates/lumio-spatial/src/resource.rs @@ -14,6 +14,12 @@ pub struct SpatialResource { destroyed: AtomicBool, } +impl Default for SpatialResource { + fn default() -> Self { + Self::new() + } +} + impl SpatialResource { pub fn new() -> Self { Self { diff --git a/crates/lumio-test-support/src/fixtures.rs b/crates/lumio-test-support/src/fixtures.rs index d4b9517..7b7dd0b 100644 --- a/crates/lumio-test-support/src/fixtures.rs +++ b/crates/lumio-test-support/src/fixtures.rs @@ -9,6 +9,12 @@ pub struct FixtureLoader { _private: (), } +impl Default for FixtureLoader { + fn default() -> Self { + Self::new() + } +} + impl FixtureLoader { pub fn new() -> Self { Self { _private: () } @@ -29,6 +35,12 @@ pub struct FaultPlan { _private: (), } +impl Default for FaultPlan { + fn default() -> Self { + Self::new() + } +} + impl FaultPlan { pub fn new() -> Self { Self { _private: () } @@ -40,6 +52,12 @@ pub struct PanicProbe { _private: (), } +impl Default for PanicProbe { + fn default() -> Self { + Self::new() + } +} + impl PanicProbe { pub fn new() -> Self { Self { _private: () } diff --git a/xtask/src/baseline.rs b/xtask/src/baseline.rs index cbb6fb0..3776209 100644 --- a/xtask/src/baseline.rs +++ b/xtask/src/baseline.rs @@ -41,12 +41,12 @@ fn must_not_contain(errors: &mut Vec, rel: &str, body: &str, needle: &st /// SHA-256 hex of `path` via `sha256sum` (CI) or `certutil` (Windows). pub fn file_sha256_hex(path: &Path) -> Result { - if let Ok(out) = Command::new("sha256sum").arg(path).output() { - if out.status.success() { - let text = String::from_utf8_lossy(&out.stdout); - if let Some(hex) = text.split_whitespace().next() { - return Ok(hex.to_ascii_lowercase()); - } + if let Ok(out) = Command::new("sha256sum").arg(path).output() + && out.status.success() + { + let text = String::from_utf8_lossy(&out.stdout); + if let Some(hex) = text.split_whitespace().next() { + return Ok(hex.to_ascii_lowercase()); } } let out = Command::new("certutil")