rust-lang / rust-lang/rust-clippy

doc: `same_functions_in_if_condition` example contradicts actual lint behavior

Open Beginner friendly
#17,259 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

The same_functions_in_if_condition lint is supposed to check that function is called several times in if conditions

But the "correct" example suggest the exact code that should trigger the lint:
https://github.com/rust-lang/rust-clippy/blob/d7246b03ea4761416cfba19d34708e4200fce604/clippy_lints/src/ifs/mod.rs#L120-L127

The whole doc for this lint looks like a copy-paste error to me.
I was just browsing clippy lints and this one confused me.

Not sure what the correct documentation should look like, therefore an issue.

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

Start in clippy_lints/src/ifs/mod.rs around lines 120-127 and compare the documented examples with the actual same_functions_in_if_condition behavior. Trace the lint's nearby implementation or checks to determine which example should trigger it. Done means the lint documentation clearly distinguishes the triggering and non-triggering code.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.