Skip to content

Lint ignored_map_err #42

@Veetaha

Description

@Veetaha

Lint explanation

Detect code that uses let _ = result.map_err(); pattern instead of if-let. The reasoning is that map_err is meant for changing the error type of the result, so it does more than just inspecting the error result. if-let intentionally ignores any values that don't match the pattern and is subjectively clearer, and objectively shorter.

Example code

Bad

let _ = do_something_fallible().map_err(|err| {
	// log the error
});

Good

if let Err(err) = do_something_fallible() {
	// log the error
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-user-storyArea: A user story or a related issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions