`unused_qualifications` lint confused by `pub use Foo::*`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried enabling unused_qualifications for the compiler itself. It mostly works, but gets confused by pub use Foo::* forms.
Here's an example from compiler/rustc_ast/src/token.rs, which has this:
pub use LitKind::*;
followed by this:
pub enum LitKind {
Bool, // AST only, must never appear in a `Token`
Byte,
Char,
Integer, // e.g. `1`, `1u8`, `1f32`
Float, // e.g. `1.`, `1.0`, `1e3f32`
Str,
StrRaw(u8), // raw string delimited by `n` hash symbols
ByteStr,
ByteStrRaw(u8), // raw byte string delimited by `n` hash symbols
CStr,
CStrRaw(u8),
Err(ErrorGuaranteed),
}
It emits a bogus error for every variant of the enum. Here's one example:
error: unnecessary qualification
--> compiler/rustc_ast/src/token.rs:160:10
|
160 | pub enum LitKind {
| __________^
161 | | Bool, // AST only, must never appear in a `Token`
162 | | Byte,
163 | | Char,
164 | | Integer, // e.g. `1`, `1u8`, `1f32`
| |___________^
|
help: remove the unnecessary path segments
|
160 - pub enum LitKind {
161 - Bool, // AST only, must never appear in a `Token`
162 - Byte,
163 - Char,
164 - Integer, // e.g. `1`, `1u8`, `1f32`
160 + pub enum Integer, // e.g. `1`, `1u8`, `1f32`
|
There is no qualification present, and the help suggestion is nonsense.
I was unable to reproduce this behaviour in a standalone test case.
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 reported case is in compiler/rustc_ast/src/token.rs, around pub use LitKind::* and the LitKind enum. Start by reproducing the unused_qualifications diagnostic with this example, then trace how the glob re-export affects the reported span and suggestion. Done means the example produces no bogus qualification error or nonsensical help text.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100