rust-lang / rust-lang/rust-clippy

Lint idea: error handling code that ignores or only logs the error

Open
#1,269 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-lint E-medium L-correctness T-middle
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

This might not be the best idea. It also might not be easy to implement. But I wanted to put it here as food for thought. I got the idea from this paper, which says that one of the signs that there might be a problem is "Error handlers that ignore errors (or just contain a log statement)".

So perhaps if there's this code:

match something {
    Ok(stuff) => { 
        // happy path stuff
    },
    Err(e) => {
        error!("logging this error");
    },
}

Or without anything in the Err arm, just Err(e) => {}, then this proposed lint would point these out?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points. First clarify the intended behavior for empty Err arms and arms that only log an error, then determine the scope of a Clippy lint from the existing project structure. Done means the lint's behavior and implementation approach are agreed, with coverage for the proposed examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.