Skip to content

Conversation

@ada4a
Copy link
Contributor

@ada4a ada4a commented Nov 4, 2025

Resolves #13252
Resurrection of #13333

changelog: [manual_assert_eq]: new lint

@rustbot rustbot added needs-fcp S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Nov 4, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 4, 2025

r? @Alexendoo

rustbot has assigned @Alexendoo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@github-actions
Copy link

github-actions bot commented Nov 4, 2025

Lintcheck changes for ada768b

Lint Added Removed Changed
clippy::manual_assert_eq 140 0 0

This comment will be updated if you push new changes

@ada4a ada4a force-pushed the manual_assert_eq branch 5 times, most recently from 5856d0e to 7ae07b6 Compare November 4, 2025 13:38
Copy link
Member

@samueltardieu samueltardieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suggestion is only valid if the types being compared implement Debug.

View changes since this review

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Nov 5, 2025
@ada4a
Copy link
Contributor Author

ada4a commented Nov 5, 2025

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties and removed S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Nov 5, 2025
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

#[expect(
clippy::manual_assert_eq,
reason = "the message contains `assert_eq!`-like formatting itself"
)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't lint if there is an assert message provided

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that the suggestion is unfortunate in this case, but in general, a provided assert message can often complement the default one from assert_eq

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe reduce the applicability in this case?

Comment on lines 57 to 61
#[allow(clippy::manual_assert_eq, reason = "tests `assert!` specifically")]
{
assert!(8 == (7 + 1));
//~^ assertions_on_constants
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The allows in this and other unrelated tests should go in the top level #![allow] like other lints, they don't need a reason

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my experience, putting such specific allows (and not things like no_effect, which one really wants to apply to the whole file) on the specific locations that trigger them helps keep the test suite clean, as it's easier to notice when a particular allow becomes unnecessary (this has happened to me more than once). Specifying a reason is also helpful for that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving to expects is something we might want to consider to know when we need to cleanup, though that comes with its own problems

But I think having irrelevant lints inline is a distraction personally

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine fine.. moved the allows to the top, switching to expect wherever possible

@Alexendoo Alexendoo added S-final-comment-period Status: final comment period it will be merged unless new objections are raised (~1 week) and removed needs-fcp S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Dec 2, 2025
@Alexendoo
Copy link
Member

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Jan 16, 2026

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-fcp S-final-comment-period Status: final comment period it will be merged unless new objections are raised (~1 week)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add lints to encourage use of specialized assert macros

4 participants