Skip to content

Extend assert_is_empty for HashSet - #17960

Draft
chinzhening wants to merge 1 commit into
rust-lang:mainfrom
chinzhening:assert_is_empty_on_hashset
Draft

chinzhening wants to merge 1 commit into
rust-lang:mainfrom
chinzhening:assert_is_empty_on_hashset

Conversation

@chinzhening

@chinzhening chinzhening commented Oct 31, 2026 •

Copy link
Copy Markdown

Fixes #17937.

This will emit assert_eq!(hashset, hashset::default()) for assert!(hashset.is_empty()) if hashset implements the Default trait. The ::default() suggestion is preferred over ::new() because it also works for custom hashers that implement Default.

Tests for nested references and custom hashers are also added.

changelog: [assert_is_empty]: Extend assert_is_empty to HashSet

@github-actions

Copy link
Copy Markdown

Lintcheck changes for d95a870

Lint Added Removed Changed
clippy::assert_is_empty 2 0 0

This comment will be updated if you push new changes

This branch has not been deployed

No deployments
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.

assert_is_empty could catch HashSet

1 participant