Repository navigation
d3d12: fix remaining workspace clippy warnings - #2873
kirigayakazima wants to merge 1 commit into
Conversation
KelboLive
left a comment
There was a problem hiding this comment.
The four targeted fixes are behaviour-preserving, and I checked the ones that could bite rather than the ones that look safe:
(0.0..1e9).contains(&v)is exactly the oldis_finite && v >= 0.0 && v < 1e9(NaN/±inf/−0.0/1e9all agree;is_finitewas redundant) — a separate check over those values found zero differences.while letkeeps onefetch_add(Relaxed)per iteration including the final failing one, andcontinuestill re-tests the condition.let _ = places.insert(...)is the same no-op:Option<(u8,u64,u32)>isCopy, sodropnever did anything.MeshStagesregroups POD arguments in the same source order (amplify, ms, ps), no allocation, no drops.
No #[allow] was added — the only too_many_arguments allow in the touched file is pre-existing on the inner build.
Two caveats before merge:
--all-targetsis not clean: six pre-existingleonida-shadertest warnings remain (double_comparisons,neg_cmp_op_on_partial_ordinvalu_tests.rs), socargo clippy --workspace --all-targets -- -D warningsstill fails. The body's command (without--all-targets) is clean — say which one you mean.- The branch is 14 commits behind main, and current main already has an
unused_mutatleonida-gpu/src/host.rs:7435that this PR does not touch (it disappeared in the diff only because of the stale base). Rebase before merging or the "remaining warnings" claim is not true of the merged tree.
Tests: same pre-existing xtask asset-policy failure before and after (it names host.rs, lower.rs and amplify_dxil.rs); the only PR-attributable change is the new HLE test (+1 passed), no failures moved. One GPU test (texture::alias_cast_tests::committed_and_placed_r32_uint_textures_cast_to_r9g9b9e5_under_legacy_barriers) flaked once when two suites ran concurrently and passed in isolation — pre-existing, unrelated, but worth knowing.
|
I tested the overlap with #2877 on Independent Win64 MSVC-target MEASURED, AI-assisted (Codex). |
VERIFY-2873 — Linux, Rust 1.98.1 (the pinned toolchain), no GPU device, no game filesVerdict: 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 1. What it fixesThe same three clippy warnings #2877 fixes, in a different spelling:
And it adds a test for the last one, 2. The rewrite is semantically identical — checkedDropping I checked it rather than reasoning it, comparing the old and the new closure over:
3. Clippy does not require dropping
|
| spelling | clippy 1.98 |
|---|---|
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) |
no warning |
v.is_finite() && (0.0..1e9).contains(&v) && v.fract() == 0.0 (#2877) |
no warning |
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] in valu_tests.rs that #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:
$ git merge pr2873 pr2877
ERROR: content conflict in d3d12/crates/leonida-gpu/src/pipeline/known.rs
ERROR: content conflict in d3d12/crates/leonida-hle/src/modules/glyphs/live.rs
They are two versions of the same fixes — the same let _ = and while let, the same struct for the arguments (MeshStages here, Stages in #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
- The tests of
leonida-gpuandleonida-hle. Neither crate builds on Linux for reasons that predate this pull request (upstream: "The crates are Windows-only today … Linux follows Linux: build leonida.exe and run it under Proton or Wine #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. - The warning count. Clippy needs the crate to compile, so I could not run
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.
Claimed in the coordination issue as: D3D12-CLIPPY-WORKSPACE-CLEAN (#2570 (comment))
What and why
Clears the four workspace clippy warnings reported in #2570 (comment) 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)