d3d12: fix remaining workspace clippy warnings #2873
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2873
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/d3d12-clippy-workspace-clean"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
Claimed in the coordination issue as: D3D12-CLIPPY-WORKSPACE-CLEAN (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7311877902)
What and why
Clears the four workspace clippy warnings reported in https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7308565171 so
cargo clippy --workspace --locked -- -D warningspasses cleanly again:d3d12/crates/leonida-gpu/src/pipeline/host.rs(mesh_pipeline, line 1214): groupedamplify,ms, andpsinto a small privateMeshStagesstruct, reducing the argument count from 8 to 6 without suppressingclippy::too_many_arguments.d3d12/crates/leonida-gpu/src/pipeline/known.rs:drop(places.insert(hash, (stage, at, len)))(Option<(u8, u64, u32)>,Copy) withlet _ = places.insert(...);(clippy::dropping_copy_types).loop { let Some(&n) = ... else { break }; ... }withwhile let Some(&n) = ...(clippy::while_let_loop).d3d12/crates/leonida-hle/src/modules/glyphs/live.rs(plausible, line 121): replacedv.is_finite() && v >= 0.0 && v < 1e9with(0.0..1e9).contains(&v)(clippy::manual_range_contains, preserving NaN/infinity/sign boundary semantics) and added unit testplausible_checks_nonnegative_whole_counters_below_one_billion.Tested
Verified locally (Windows 11, Rust 1.98.1 / clippy 0.1.98, no game data):
cargo clippy --workspace --locked -- -D warningsfailed (rc = 101) with errors inpipeline/host.rs:1214andpipeline/known.rs:246,268(plusglyphs/live.rs:121downstream).cargo clippy --workspace --locked -- -D warnings: 0 warnings, exit 0cargo test --locked -p leonida-hle --lib modules::glyphs::live: 13 passed, 0 failedcargo test --locked -p leonida-gpu --lib pipeline::known: 2 passed, 0 failedcargo check --workspace --all-targets --locked: exit 0python -I scripts/check_no_game_data.py&git diff --check: cleanGPUs tested: n/a (lint/check and unit tests without GPU device creation)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a)I tested the overlap with #2877 on
3e7b34a5. Both fix the same four warnings. A direct merge of the pair conflicts inpipeline/host.rs,pipeline/known.rs, andmodules/glyphs/live.rs. Resolving those by keeping this PR's implementation and test leaves only #2877's scoped NaN test annotation as an additional change.Independent Win64 MSVC-target
cargo xwin clippy --workspace --all-targetsoutputs (Rust 1.98.1, separate target directories) have 11 unique diagnostics onmain, 7 with this PR and 1 with the combination. The remainingunused_mutis insend_published; the code that mutateshis already#[cfg(feature = "diagnostics")]. Bindinglet mut h = h;under the same cfg and removingmutfrom the parameter gives exit 0 with-D warningsunder default features. With diagnostics enabled the combined tree still reports ten separate pre-existing diagnostics, so the clean result applies to the default configuration.MEASURED, AI-assisted (Codex).
VERIFY-2873 — Linux, Rust 1.98.1 (the pinned toolchain), no GPU device, no game files
Verdict: PASS. The rewrites are correct, and the one that is not strictly required by clippy is semantically identical to what it replaces — I checked that over two million random bit patterns. It conflicts with #2877, which does the same work.
Head
7feda433, base the currentmain88a9f133, merge baseed867d7b, 1 commit, 3 files, +53/−11:d3d12/crates/leonida-gpu/src/pipeline/host.rs,d3d12/crates/leonida-gpu/src/pipeline/known.rs,d3d12/crates/leonida-hle/src/modules/glyphs/live.rs.1. What it fixes
The same three clippy warnings #2877 fixes, in a different spelling:
known.rs:drop(places.insert(..))→let _ = places.insert(..), andloop { … else { break } }→while let … { … };host.rs: the three shader bytecodes become aMeshStagesstruct, somesh_pipelinetakes six arguments instead of eight;live.rs:v >= 0.0 && v < 1e9→(0.0..1e9).contains(&v)— and herev.is_finite()is dropped, which thecontainsform does not need.And it adds a test for the last one,
plausible_checks_nonnegative_whole_counters_below_one_billion, which drivesplausible()with aFakememory over 0.0, −0.0, 999 999 999.0, 1e9, −1.0, 0.5, NaN, ±∞.2. The rewrite is semantically identical — checked
Dropping
is_finite()is safe because the range form already rejects every non-finite value:(0.0..1e9).contains(&v)is0.0 <= v && v < 1e9, and both comparisons are false for a NaN and for ±∞.I checked it rather than reasoning it, comparing the old and the new closure over:
f64::MIN_POSITIVE,f64::MAX, 2.0, −2.0, 1e-300);f64bit patterns;1e9boundary.3. Clippy does not require dropping
is_finite()The repository enables
clippy::all([workspace.lints.clippy] all = { level = "warn", priority = -1 }). I ran the pinned clippy (1.98) over the three spellings:v.is_finite() && v >= 0.0 && v < 1e9 && v.fract() == 0.0(main)manual_range_contains(0.0..1e9).contains(&v) && v.fract() == 0.0(this pull request)v.is_finite() && (0.0..1e9).contains(&v) && v.fract() == 0.0(#2877)So the
is_finite()may stay; dropping it is tidier, and the test that comes with it is what makes the dropping safe to do. The#[allow]invalu_tests.rsthat #2877 adds is not in this pull request — that is the one file of the four the two pull requests do not share.4. It conflicts with #2877
Merging the two together fails:
They are two versions of the same fixes — the same
let _ =andwhile let, the same struct for the arguments (MeshStageshere,Stagesin #2877), the same range rewrite — differing in the comments and in which of them brings a test. One needs to be rebased onto the other; the parts worth keeping are this one's test and #2877's comments.5. What I did not check
leonida-gpuandleonida-hle. Neither crate builds on Linux for reasons that predate this pull request (upstream: "The crates are Windows-only today … Linux follows #2577"), so the new testplausible_checks_nonnegative_whole_counters_below_one_billioncould not be run here — I checked the rewrite it pins by an independent equivalence test instead (§2), which is what the test asserts, but not the test itself.cargo clippy --workspacehere; I ran clippy on the three spellings of thelive.rsline in isolation (§3) instead.mesh_pipeline's new argument shape. The struct is a mechanical change to satisfytoo_many_arguments; the four call sites are the only thing that changes shape, and I read all four. I did not run the mesh pipeline (it needs a D3D12 device).cargo fmtis left out of the d3d12 workflow; this pull request'shost.rscall sites are formatted across several lines, which is the other of the two spellings of the same change.cargo clippy --workspace --all-targets --locked -- -D warningsfails onmainfor unrelated reasons (the workflow runs it as a report too).AI-assisted: MiniMax M3.1 Flash.
Merging as part of a group. Head 7feda433d; the group branch main 1e3e316c5 + #2862 + #2824 + #2873 (7988c1c89, merged in that order) passed the full CI (https://github.com/OreoFR/leonida/actions/runs/46740411028, the same workflow file as here, run on that branch) and No Game Data (https://github.com/OreoFR/leonida/actions/runs/46740416586); main was 1e3e316c5 with its CI green when the group merged. Claim: D3D12-CLIPPY-WORKSPACE-CLEAN (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7311877902). Red/green: no red/green possible (behaviour-preserving clippy cleanup); merzleckeier and imShangLi (Linux, PASS) checked it, KelboLive review on this head. I ran: the five PRs #2860-#2862, #2824 and #2873 merged together onto main ab374c7d5 (main since gained only #2935, a CI workflow change, and #2860 and #2861, both part of that test), with the shader (418 passed, 0 failed), gpu (644/0) and hle (247/0) cargo tests. In-game run: RTX 4070 Laptop 8 GB, NVIDIA 621.40, a cold start to the world then a 330 s warm walking run, 0 device lost, no panic. CI: green on head, main and the group branch. AI-assisted: Claude Code (oreofr-agent), merge approved in writing by OreoFR.