Skip to content

Lint workspace test targets in CI, and fix the one site that fails - #486

Merged
nihalpasham merged 1 commit into
NVIDIA:mainfrom
alejandro-soto-franco:fix/clippy-all-targets
Jul 27, 2026
Merged

nihalpasham merged 1 commit into
NVIDIA:mainfrom
alejandro-soto-franco:fix/clippy-all-targets

Conversation

@alejandro-soto-franco

Copy link
Copy Markdown
Contributor

Closes #401

Summary

just clippy fails on main:

error: the function `IntegerType::get` doesn't need a mutable reference
    --> crates/mir-lower/src/convert/types.rs:2805:52
     |
2805 |     let carrier: TypeHandle = IntegerType::get(&mut ctx, 32, Signedness::Signless).into();
     |                                                ^^^^^^^^
     |
     = note: `-D clippy::unnecessary-mut-passed` implied by `-D warnings`

pliron's IntegerType::get takes &Context. Rust accepts the implicit downgrade from &mut, and clippy::unnecessary_mut_passed does not.

Two changes, of slightly different kinds

They are separable, and I have put them together because each is a few lines and neither is much use alone. Say the word and I will split them.

A lint fix, one line in a #[cfg(test)] module:

-let carrier: TypeHandle = IntegerType::get(&mut ctx, 32, Signedness::Signless).into();
+let carrier: TypeHandle = IntegerType::get(&ctx, 32, Signedness::Signless).into();

A CI change, adding --all-targets to one workflow step. The clippy workflow runs three steps and only the first omits it:

step before
workspace crates cargo clippy --workspace -- -D warnings
rustc-codegen-cuda cargo clippy --all-targets -- -D warnings
examples loop cargo clippy --all-targets -- -D warnings

So no test target in a workspace crate is linted in CI. That is why this lint sat on main while failing for anyone running the local recipe, as #401 worked out when it was filed.

The lint fix alone closes the issue. Without the CI change the next lint confined to a test target lands just as quietly, so the two belong in one commit.

Scope

crates/mir-lower/src/convert/types.rs:2805 is the only site left in the workspace. The ten in crates/mir-lower/tests/lowering_test.rs that #401 quoted are already gone, as @honeyspoon noted on the issue; this one is in a test module inside src/, which is a different file and still present.

The CI step now compiles workspace test targets, so it costs more runner time than before. unit-tests.yml already compiles test targets for most of these packages, and clippy checks without linking, so nothing new is needed on the runner beyond the toolkit the job already installs.

Validation

$ cargo clippy --workspace --all-targets -- -D warnings     # the new CI command
    Finished `dev` profile [unoptimized + debuginfo] target(s)

$ cargo clippy --all-targets --lib --tests -- -D warnings   # just clippy
    Finished `dev` profile [unoptimized + debuginfo] target(s)

$ cargo test -p mir-lower
test result: ok. 143 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
test result: ok. 76 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

$ cargo fmt --all -- --check
(clean)

Reverting only the one-line change reproduces the failure under both commands, so the workflow step does gate on it:

error: the function `IntegerType::get` doesn't need a mutable reference
    --> crates/mir-lower/src/convert/types.rs:2805:52
error: could not compile `mir-lower` (lib test) due to 1 previous error
  • cargo oxide run <example> passes
  • cargo test --workspace passes
  • New example added (if applicable)

No example added: this is a lint fix in a test module and a workflow flag. No device code changes.

Checklist

  • All commits signed off (git commit -s)
  • SPDX headers on new source files (no new files)

`just clippy` runs `cargo clippy --all-targets --lib --tests -- -D warnings`
and fails on main:

    error: the function `IntegerType::get` doesn't need a mutable reference
      --> crates/mir-lower/src/convert/types.rs:2805:52

pliron's IntegerType::get takes &Context. Rust accepts the implicit
downgrade from &mut, clippy's unnecessary_mut_passed does not. Pass the
shared reference.

The clippy workflow runs three steps, and only the workspace one omits
--all-targets, so no workspace test target is linted there. Add it, which
matches the rustc-codegen-cuda step, the per-example loop and the local
recipe. The workspace is clean under it once the site above is fixed.

Closes NVIDIA#401.

Signed-off-by: Alejandro Soto Franco <[email protected]>
@nihalpasham nihalpasham added bug Something isn't working build-related Build scripts, toolchain discovery, or compilation setup labels Jul 27, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator

Thanks.

Verified the types.rs change is behavior-identical at the pinned pliron rev (the derive-generated get takes &Context), and the new gate already earned its keep by catching a test-target lint in another PR of this batch before it merged. Closes #401.

Merging.

@nihalpasham
nihalpasham merged commit b392c9a into NVIDIA:main Jul 27, 2026
33 checks passed
honeyspoon added a commit to honeyspoon/cuda-oxide that referenced this pull request Jul 27, 2026
CI now lints test targets too (NVIDIA#486 added --all-targets), and the modulo
checks in cast_chunks trip clippy::manual_is_multiple_of under it. No
behaviour change.

Signed-off-by: abder <[email protected]>
honeyspoon added a commit to honeyspoon/cuda-oxide that referenced this pull request Jul 27, 2026
CI now lints test targets (NVIDIA#486). Three modulo checks trip
clippy::manual_is_multiple_of and one nested if trips collapsible_if. No
behaviour change; tests unchanged and still pass.

Signed-off-by: abder <[email protected]>
honeyspoon added a commit to honeyspoon/cuda-oxide that referenced this pull request Jul 27, 2026
CI now lints test targets (NVIDIA#486). Three modulo checks trip
clippy::manual_is_multiple_of, one of them inside a test. No behaviour
change.

Signed-off-by: abder <[email protected]>
honeyspoon added a commit to honeyspoon/cuda-oxide that referenced this pull request Jul 27, 2026
CI now lints test targets (NVIDIA#486), and the counterexample wrote the colliding
pair as `0 * bad_period + 2 * n` against `1 * bad_period + 0 * n`, which trips
clippy::erasing_op and clippy::identity_op.

The literals were carrying meaning - they are the (k, t) digit pair - so
suppressing the lint would have been the wrong fix. Routed through a small
`at(k, t, period, n)` instead, which keeps the pair visible at each call and
makes the two assertions read as the same expression under two periods.

Same assertions, same numbers.

Signed-off-by: abder <[email protected]>
honeyspoon added a commit to honeyspoon/cuda-oxide that referenced this pull request Jul 27, 2026
CI now lints test targets (NVIDIA#486); the two ownership loops index a slice by
range, which trips clippy::needless_range_loop. Iterating the subslice says the
same thing more directly.

Signed-off-by: abder <[email protected]>
honeyspoon added a commit to honeyspoon/cuda-oxide that referenced this pull request Jul 27, 2026
CI now lints test targets (NVIDIA#486). Three modulo checks trip
clippy::manual_is_multiple_of and one nested if trips collapsible_if. No
behaviour change; tests unchanged and still pass.

Signed-off-by: abder <[email protected]>
honeyspoon added a commit to honeyspoon/cuda-oxide that referenced this pull request Jul 27, 2026
CI now lints test targets (NVIDIA#486). Three modulo checks trip
clippy::manual_is_multiple_of, one of them inside a test. No behaviour
change.

Signed-off-by: abder <[email protected]>
honeyspoon added a commit to honeyspoon/cuda-oxide that referenced this pull request Jul 27, 2026
CI now lints test targets too (NVIDIA#486 added --all-targets), and the modulo
checks in cast_chunks trip clippy::manual_is_multiple_of under it. No
behaviour change.

Signed-off-by: abder <[email protected]>
honeyspoon added a commit to honeyspoon/cuda-oxide that referenced this pull request Jul 28, 2026
CI now lints test targets (NVIDIA#486). Three modulo checks trip
clippy::manual_is_multiple_of and one nested if trips collapsible_if. No
behaviour change; tests unchanged and still pass.

Signed-off-by: abder <[email protected]>
honeyspoon added a commit to honeyspoon/cuda-oxide that referenced this pull request Jul 28, 2026
CI now lints test targets (NVIDIA#486), and the counterexample wrote the colliding
pair as `0 * bad_period + 2 * n` against `1 * bad_period + 0 * n`, which trips
clippy::erasing_op and clippy::identity_op.

The literals were carrying meaning - they are the (k, t) digit pair - so
suppressing the lint would have been the wrong fix. Routed through a small
`at(k, t, period, n)` instead, which keeps the pair visible at each call and
makes the two assertions read as the same expression under two periods.

Same assertions, same numbers.

Signed-off-by: abder <[email protected]>
honeyspoon added a commit to honeyspoon/cuda-oxide that referenced this pull request Jul 28, 2026
CI now lints test targets (NVIDIA#486); the two ownership loops index a slice by
range, which trips clippy::needless_range_loop. Iterating the subslice says the
same thing more directly.

Signed-off-by: abder <[email protected]>
honeyspoon added a commit to honeyspoon/cuda-oxide that referenced this pull request Jul 29, 2026
CI now lints test targets (NVIDIA#486), and the counterexample wrote the colliding
pair as `0 * bad_period + 2 * n` against `1 * bad_period + 0 * n`, which trips
clippy::erasing_op and clippy::identity_op.

The literals were carrying meaning - they are the (k, t) digit pair - so
suppressing the lint would have been the wrong fix. Routed through a small
`at(k, t, period, n)` instead, which keeps the pair visible at each call and
makes the two assertions read as the same expression under two periods.

Same assertions, same numbers.

Signed-off-by: abder <[email protected]>
honeyspoon added a commit to honeyspoon/cuda-oxide that referenced this pull request Jul 29, 2026
CI now lints test targets (NVIDIA#486); the two ownership loops index a slice by
range, which trips clippy::needless_range_loop. Iterating the subslice says the
same thing more directly.

Signed-off-by: abder <[email protected]>
@alejandro-soto-franco
alejandro-soto-franco deleted the fix/clippy-all-targets branch September 9, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working build-related Build scripts, toolchain discovery, or compilation setup

Projects

None yet

Development

Successfully merging this pull request may close these issues.

just clippy fails due to unnecessary_mut_passed in mir-lower's lowering_test.rs

2 participants