rust-lang / rust-lang/rust-clippy

lint to check redundant propagation

Open
#8,760 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-lint
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

What it does

in a caller function that returns the same type as the called function, it checks if the caller function propagates the function and returns the Ok value the called function would return

Lint Name

redundant_propagation

Category

pedantic

Advantage
  • reduce code length to just a line
  • avoid possible overhead because of the implicit into call by ?
  • make the code more readable to read
Drawbacks
  • it may be a bit restrictive so maybe for that category
  • it is also realistically only useful for Results whose Ok variant is a unit, like Result<(), E>
Example
fn foo() -> Result<(), String> {
    Ok(())
}

fn bar() -> Result<(), String> {
    foo()?;
    Ok(())
}

Could be written as:

fn foo() -> Result<(), String> {
    Ok(())
}

fn bar() -> Result<(), String> {
    foo()
}

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

No file or test is named in the issue. Start by locating existing Clippy lint implementations and their tests, then compare the proposal with established lint patterns. Done means the lint identifies the shown redundant Result propagation case, including unit Ok results, while respecting the stated restrictions.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.