fix(clippy): collapse nested if into match guard (clippy 1.96)#180
Merged
Conversation
…ible_match)
clippy 1.96.0 (current stable) enforces `collapsible_match`, which flagged four
parser match arms whose body was a single `if`. Fold each `if` condition into
the match arm as a guard. Every one of these matches has a `_ => {}` catch-all,
so a failed guard falls through to the no-op arm — behavior is unchanged.
Surfaced by the first `main` CI run since clippy 1.96 became stable; unrelated
to the wasm fix (#179).
Verified: `cargo +1.96.0 clippy --workspace --all-targets -- -D warnings` passes;
`cargo test -p office2pdf --lib` (1061 passed); `cargo fmt --all -- --check` passes.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
clippy 1.96.0 (current
stable) enforcescollapsible_match, which flags amatcharm whose entire body is a singleif. Four pre-existing parser arms hit it; this folds eachifcondition into the arm as a guard:parser/docx_sections.rs—RunChild::Tab(_) if !in_field => …parser/docx_tables.rs—TableCellContent::Table(t) if depth < MAX_TABLE_DEPTH => …parser/docx_text.rs—RunChild::Break(br) if !is_column_break(br) => …parser/smartart.rs—"node" if !pt.text.is_empty() => …Why now
This is not new code — it surfaced because the merge of #179 was the first
mainCI run since clippy 1.96 became stable, and theClippyjob (-D warnings) now fails on these. Unrelated to the wasm fix itself.Safety
Each of these matches has a
_ => {}catch-all, so when the new guard fails the arm falls through to the no-op arm — behavior is identical to the previousif.Verification
cargo +1.96.0 clippy --workspace --all-targets -- -D warnings✓ (reproduces the failing CI job; now clean)cargo test -p office2pdf --lib✓ (1061 passed)cargo fmt --all -- --check✓Restores
mainto green.