rust-lang / rust-lang/rust-clippy
`std_instead_of_core` does not detect uses of non-fully qualified items
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
std_instead_of_core does not detect the use of, for example, the std::fmt::Display trait when it appears as fmt::Display accompanied by use std::fmt
Lint Name
clippy::std_instead_of_core
Reproducer
I tried this code:
#![deny(clippy::std_instead_of_core)]
use std::fmt;
struct S;
impl fmt::Display for S {
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
todo!()
}
}
I expected to see this happen: 3 warnings on fmt::Display, fmt::Formatter and fmt::Result
Instead, this happened: no warnings were produced
The lint is able to detect imported items and items qualified by absolute path:
#![deny(clippy::std_instead_of_core)]
use std::fmt::{self, Display};
struct S;
impl Display for S {
fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> fmt::Result {
todo!()
}
}
in this second version, both Display and Formatter are detected but fmt::Result is not.
Version
rustc 1.73.0-nightly (7bd81ee19 2023-07-13)
binary: rustc
commit-hash: 7bd81ee1902c049691d0a1f03be5558bee51d100
commit-date: 2023-07-13
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 16.0.5
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 by locating the implementation and tests for the clippy::std_instead_of_core lint, then reproduce the issue with the Rust examples in this report. The work is done when qualified uses such as fmt::Display, fmt::Formatter, and fmt::Result are detected consistently alongside imported and absolute-path uses.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 57/100