Skip to content

Lint assert! without message #6207

Closed
@HMPerson1

Description

@HMPerson1

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);

Metadata

Metadata

Assignees

Labels

A-lintArea: New lintsL-restrictionLint: Belongs in the restriction lint groupT-macrosType: Issues with macros and macro expansiongood first issueThese 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