Skip to content

fix(clippy): collapse nested if into match guard (clippy 1.96)#180

Merged
developer0hye merged 1 commit into
mainfrom
fix/clippy-collapsible-match
May 31, 2026
Merged

fix(clippy): collapse nested if into match guard (clippy 1.96)#180
developer0hye merged 1 commit into
mainfrom
fix/clippy-collapsible-match

Conversation

@developer0hye
Copy link
Copy Markdown
Owner

What

clippy 1.96.0 (current stable) enforces collapsible_match, which flags a match arm whose entire body is a single if. Four pre-existing parser arms hit it; this folds each if condition into the arm as a guard:

  • parser/docx_sections.rsRunChild::Tab(_) if !in_field => …
  • parser/docx_tables.rsTableCellContent::Table(t) if depth < MAX_TABLE_DEPTH => …
  • parser/docx_text.rsRunChild::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 main CI run since clippy 1.96 became stable, and the Clippy job (-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 previous if.

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 main to green.

…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>
@developer0hye developer0hye merged commit 3a3723c into main May 31, 2026
14 checks passed
@developer0hye developer0hye deleted the fix/clippy-collapsible-match branch May 31, 2026 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant