rust-lang / rust-lang/rust-clippy
Misleading code example for `wrong_pub_self_convention` lint
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
The wrong_pub_self_convention example from documentation is kind of misleading to me.
The example for this lint is:
# struct X;
impl<'a> X {
pub fn as_str(self) -> &'a str {
"foo"
}
}
On playground, it fires wrong_self_convention (instead wrong_pub_self_convention), so the example or the lint needs to be reworked.
The difference with wrong_self_convention example is mainly the pub keyword on the method as_str, but the lint doesn't use the function visibility as condition to choose which lint to fire (in fact it uses the visibility of the impl item).
As proposed in #6316, it would probably make sense to also look into the history of the lints, what were the reasons to split them (if that was the case)?
It seems there are no tests for the pub variant.
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
Start with the wrong_pub_self_convention and wrong_self_convention examples in clippy_lints/src/methods/mod.rs, then reproduce the playground behavior described in the issue. Review the history and rationale referenced in rust-clippy#6316, and check how lint tests are organized; done means the example and lint behavior agree and the pub variant is covered if its behavior remains distinct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100