Imports of legacy modules with numeric constants do not get flagged as unused when the corresponding type is used in the code
Open
Nobody has claimed this yet.
A-diagnostics
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
use std::usize;
fn main() {
let x: usize = 1;
println!("{}", x);
}
Current output
Desired output
warning: unused import: `std::usize`
--> src/main.rs:1:5
|
1 | use std::usize;
| ^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
Rationale and extra context
No response
Other cases
No response
Rust Version
$ rustc --version --verbose
rustc 1.79.0-beta.1 (6b544f5ff 2024-04-28)
binary: rustc
commit-hash: 6b544f5ff8d45221d61962651a5f5ab9fe535e16
commit-date: 2024-04-28
host: x86_64-unknown-linux-gnu
release: 1.79.0-beta.1
LLVM version: 18.1.4
Anything else?
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
Reproduce the report with the Rust code shown in src/main.rs and the listed rustc version, then compare the current diagnostics with the desired unused_imports warning. Done means the legacy std::usize import is reported as unused even when the usize type is used.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100