Skip to content

fix: resolve clippy assert_is_empty and needless_bool warnings - #74

Closed
dkam wants to merge 1 commit into
jonwiggins:mainfrom
dkam:chore/clippy-1.100-lints
Closed

dkam wants to merge 1 commit into
jonwiggins:mainfrom
dkam:chore/clippy-1.100-lints

Conversation

@dkam

@dkam dkam commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Summary

The Clippy job has failed on every CI run since 7 October, including Dependabot PRs such as #73:

  • Clippy 1.99 added the pedantic assert_is_empty lint, which fires 23 times in tests.
  • Clippy 1.100 extends needless_bool to one if in the HTML5 tree builder.

This PR fixes all 24 without allowing either lint:

  • assert!(x.is_empty()) becomes assert_eq!(x, [] as [T; 0]), and assert!(!x.is_empty()) becomes assert_ne!. A failing test now prints the value, which is what the lint is for. cargo clippy --fix can't make these changes itself: it suggests crate-relative paths such as tree::NodeId that aren't in scope in the test modules, so I applied them by hand.
  • should_use_foreign_content_rules now returns *token != Token::Eof instead of if … { return false; } true.

All but that last expression are test changes. There is no behaviour change.

Type of Change

  • Bug fix (corrects an existing issue)
  • New feature (adds new functionality)
  • Conformance fix (aligns behavior with the W3C spec or libxml2)
  • Refactoring (no functional change)
  • Documentation (docs, comments, examples)
  • CI / tooling (build scripts, workflows, hooks)

Test Plan

Each of the CI jobs was run locally on macOS (aarch64):

  • cargo fmt --all -- --check: passes
  • cargo clippy --all-targets --all-features -- -D warnings on 1.100.0: passes (24 errors before this PR)
  • cargo test --all-features on 1.100.0: passes, including the html5lib, libxml2-compat and W3C suites
  • cargo test --features cli,ffi on 1.81.0: passes
  • RUSTDOCFLAGS="-D warnings" cargo doc --all-features --no-deps: passes

Checklist

  • Code is formatted (cargo fmt --all)
  • No clippy warnings (cargo clippy --all-targets --all-features -- -D warnings)
  • All tests pass (cargo test --all-features)
  • Documentation updated for any public API changes (no public API changes)
  • Commit messages follow the <module>: <summary> convention
  • No new dependencies added

🤖 Generated with Claude Code

Clippy 1.99 added the pedantic `assert_is_empty` lint (23 errors) and
clippy 1.100 extends `needless_bool` to an `if` that returns a bool
literal ahead of the final one (1 error), so the Clippy CI job has failed
on every run since 7 October.

- Rewrite `assert!(x.is_empty())` as `assert_eq!(x, [] as [T; 0])`, and
  the negated form as `assert_ne!`, so a failing test prints the value.
  `cargo clippy --fix` suggests a crate-relative path such as
  `tree::NodeId` that is not in scope, so these were applied by hand.
- Return `*token != Token::Eof` directly at the end of
  `should_use_foreign_content_rules`.

No behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jonwiggins

Copy link
Copy Markdown
Owner

Thanks so much for this, @dkam, and for taking the time to track down the clippy 1.100 findings! It turns out these exact lints were fixed on main in 45959dc (lint: fix clippy 1.100 assert_is_empty and needless_bool findings), which shipped in 0.5.1 — the changes are essentially identical to yours. Since that's already landed, I'm closing this one as superseded, but I really appreciate the contribution and would welcome more.

@jonwiggins jonwiggins closed this Nov 20, 2026
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.

2 participants