Skip to content

Add ASSERTIONS_ON_COLLECTION_EMPTINESS lint#17320

Open
MihirMohapatra wants to merge 4 commits into
rust-lang:masterfrom
MihirMohapatra:assert-on-emptiness
Open

Add ASSERTIONS_ON_COLLECTION_EMPTINESS lint#17320
MihirMohapatra wants to merge 4 commits into
rust-lang:masterfrom
MihirMohapatra:assert-on-emptiness

Conversation

@MihirMohapatra

@MihirMohapatra MihirMohapatra commented Jun 29, 2026

Copy link
Copy Markdown

Add ASSERTIONS_ON_COLLECTION_EMPTINESS lint

Suggests replacing assert!(x.is_empty()) and assert!(!x.is_empty())
with assert_eq!(x, []) / assert_ne!(x, []) (or assert_eq!(x, "") /
assert_ne!(x, "") for String types), so the collection contents are
shown on failure.

changelog: Added [assertions_on_collection_emptiness] to nursery

Suggests replacing �ssert!(x.is_empty()) and �ssert!(!x.is_empty())
with �ssert_eq!(x, []) / �ssert_ne!(x, []) (or �ssert_eq!(x, "") /
�ssert_ne!(x, "") for String types), so the collection contents are
shown on failure.
@rustbot rustbot added needs-fcp PRs that add, remove, or rename lints and need an FCP S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Jun 29, 2026
@rustbot

rustbot commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @dswij (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: 8 candidates
  • 8 candidates expanded to 8 candidates
  • Random selection from Jarcho, dswij, llogiq, samueltardieu

@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown

Lintcheck changes for 9e5ec15

Lint Added Removed Changed
clippy::assertions_on_collection_emptiness 66 0 0

This comment will be updated if you push new changes

@dswij

dswij commented Jul 2, 2026

Copy link
Copy Markdown
Member

r? clippy

@rustbot rustbot assigned llogiq and unassigned dswij Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-fcp PRs that add, remove, or rename lints and need an FCP S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants