Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint assert! without message #6207

Closed
HMPerson1 opened this issue Oct 23, 2020 · 1 comment · Fixed by #10362
Closed

Lint assert! without message #6207

HMPerson1 opened this issue Oct 23, 2020 · 1 comment · Fixed by #10362
Assignees
Labels
A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-restriction Lint: Belongs in the restriction lint group T-macros Type: Issues with macros and macro expansion

Comments

@HMPerson1
Copy link
Contributor

HMPerson1 commented Oct 23, 2020

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);
@HMPerson1 HMPerson1 added the A-lint Area: New lints label Oct 23, 2020
@camsteffen camsteffen added good-first-issue These issues are a good way to get started with Clippy T-macros Type: Issues with macros and macro expansion L-pedantic Lint: Belongs in the pedantic lint group L-restriction Lint: Belongs in the restriction lint group and removed L-pedantic Lint: Belongs in the pedantic lint group labels Feb 7, 2021
@unexge
Copy link
Contributor

unexge commented Feb 16, 2023

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-restriction Lint: Belongs in the restriction lint group T-macros Type: Issues with macros and macro expansion
Projects
None yet
3 participants