rust-lang / rust-lang/rust-clippy
Lint to detect hardcoded doc links in macro generated methods that should not be hardcoded
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
What it does
It is a somewhat common pattern to use macros to define identical methods on multiple types (the standard library does this with integer types).
One possible mistake might be writing the docs for one of these methods in a way that only makes sense for one of those types.
Advantage
Removes confusing docs
Drawbacks
There may be legitimate reasons to mentioning a type in this way (thus this would likely need to be a restriction lint, and additionally it should probably check that the type is not mentioned in another location in the method's signature).
Example
struct Foo;
struct Bar;
macro_rules! impl_stuff {
($Type:ty) => {
impl $Type {
/// frobs the [`Bar`]
fn frob(&self) {}
}
}
}
impl_stuff!(Foo);
impl_stuff!(Bar);
Could be written as:
struct Foo;
struct Bar;
macro_rules! impl_stuff {
($Type:ty) => {
impl $Type {
#[doc = concat!("frobs the [`", $Type, "`]")]
fn frob(&self) {}
}
}
}
impl_stuff!(Foo);
impl_stuff!(Bar);
Comparison with existing lints
No response
Additional Context
No response
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 from the macro example in the issue and investigate how Clippy handles documentation links in macro-generated methods. Define the proposed restriction lint's scope, including legitimate type mentions and signature references; the issue names no files or tests, so its completion criteria are not yet established.
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
- Needs clarification
- Newbie friendliness
- 25/100