mirror of
https://github.com/imjasonh/nescript
synced 2026-07-13 02:59:36 +00:00
compiler: satisfy four new clippy 1.95 lints so CI stays green
Rust stable rolled to 1.95.0 today (2026-04-16), which fires four
new warning-by-default lints on pre-existing code. All four have
mechanical fixes suggested by clippy itself:
- `collapsible_match` (2x) in `src/analyzer/mod.rs` — merge the
`if args.len() != N` guard into the `match` arm pattern. One
diagnostic-push per arm, shape is identical to before.
- `unnecessary_sort_by` in `src/optimizer/mod.rs` — replace
`sort_by(|a, b| b.1.cmp(&a.1))` with
`sort_by_key(|(_, c)| std::cmp::Reverse(*c))`.
- `manual_checked_ops` in `src/optimizer/mod.rs::Div` folding —
replace `if vb == 0 { 0 } else { va / vb }` with
`va.checked_div(vb).unwrap_or(0)`. Same `x / 0 == 0` fallback.
- `map_unwrap_or` in `src/main.rs` — `std::fs::metadata(...).
map(|m| m.len()).unwrap_or(0)` → `.map_or(0, |m| m.len())`.
Verified with both the old 1.94.1 stable and the freshly-installed
1.95.0: `cargo clippy --all-targets -- -D warnings` is clean on
both; `cargo fmt --check` is clean; `cargo test --all-targets`
still passes 616 + 3 + 75; the emulator harness still matches
all 34 goldens byte-for-byte.
This unblocks the SHA-256 PR (imjasonh/nescript#28) and any
other PRs that run CI against Rust 1.95.
https://claude.ai/code/session_01FRmSBruVWCufm3LsUVMs8v
This commit is contained in:
parent
5976b74b2f
commit
f128170abf
3 changed files with 22 additions and 22 deletions
|
|
@ -110,7 +110,7 @@ fn main() {
|
|||
"compiled {} -> {} ({} bytes)",
|
||||
input.display(),
|
||||
output.display(),
|
||||
std::fs::metadata(&output).map(|m| m.len()).unwrap_or(0)
|
||||
std::fs::metadata(&output).map_or(0, |m| m.len())
|
||||
);
|
||||
}
|
||||
Err(()) => std::process::exit(1),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue