rust-lang / rust-lang/rust-clippy
Force absolute path for some items
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
Lint absolute_paths (#10568) warns about items that use an absolute path instead of a use.
Clippy misses the opposite lint: warn about unqualified paths that are imported where they should not.
Advantage
An example is the log crate, which is often used as log::info! or log::error!. Unfortunately, newcomers may be tempted to import the macros from the log crate.
For consistency, it would be good to have an option to enforce the use of the full path with clippy.
Drawbacks
No response
Example
use log::error;
fn f() {
error!("fatal error in f");
}
Could be written as:
fn f() {
log::error!("fatal error in f");
}
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
The issue names the existing absolute_paths lint (#10568) and shows the desired log::error! form. Start by reviewing that lint and the surrounding Clippy lint conventions; determine the supported scope for unqualified imports and how the option should behave. Done means the requested lint is implemented with coverage for the shown examples and documented behavior.
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