Skip to content

New lint: Manual assert #7645

Closed
Closed
@camsteffen

Description

@camsteffen

What it does

Detects if-then-panic! that can be replaced with assert!

Categories (optional)

  • Kind: style

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

It is simpler

Drawbacks

None.

Example

if !sad_people.is_empty() {
    panic!("there are sad people: {:?}", sad_people);
}

Could be written as:

assert!(sad_people.is_empty(), "there are sad people: {:?}", sad_people);

Lint name: manual_assert or if_then_panic

Metadata

Metadata

Assignees

Labels

A-lintArea: New lintsE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.L-styleLint: Belongs in the style lint group

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions