rust-lang / rust-lang/rust-clippy
lint to check redundant propagation
Open
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
intocall 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 whoseOkvariant is a unit, likeResult<(), 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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