Skip to content

New lint suggestion Error impl Error #11101

Closed
@JonathanWoollett-Light

Description

@JonathanWoollett-Light

What it does

Warns on types which implement std::error::Error being named Error.

Advantage

Removes needing to document against using this common pattern.
The reasons against this pattern is that it can reduce readability and requires error types be renamed when imported (which can further reduce readability).

When you have 20 types named Error in your project it can become annoying.

Drawbacks

Adds an additional lint to clippy.

Example

#[derive(Debug, thiserror::Error)]
pub enum Error { /* ... */ }

Could be written as:

#[derive(Debug, thiserror::Error)]
pub enum MySpecificError { /* ... */ }
#[derive(Debug)]
pub enum Error { /* ... */}
impl std::error::Error for Error { /* ... */ }

Could be written as:

#[derive(Debug)]
pub enum MySpecificError { /* ... */}
impl std::error::Error for Error { /* ... */ }

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions