Skip to content

Lint assert! without message #6207

Closed

Description

What it does

Lint {debug_}assert{_eq,_ne}! without a custom panic message. (inspired by this tweet)

Categories (optional)

  • Kind: pedantic

What is the advantage of the recommended code over the original code

If the assertion fails, it might be easier to diagnose why.

Drawbacks

None.

Example

assert!(some_condition(foo));
debug_assert_eq(a, bar(b));

Could be written as:

assert!(some_condition(foo), "foo failed some condition: foo = {}", foo);
debug_assert_eq!(a, bar(b), "failed to find inverse of bar at {}", a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

A-lintArea: New lintsArea: New lintsL-restrictionLint: Belongs in the restriction lint groupLint: Belongs in the restriction lint groupT-macrosType: Issues with macros and macro expansionType: Issues with macros and macro expansiongood-first-issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions