Tracking Issue for future-incompatibility lint ambiguous_glob_imported_traits
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
The ambiguous_glob_imported_traits lint reports uses of traits that are
imported ambiguously via glob imports
Example
mod m1 {
pub trait Trait {
fn method1(&self) {}
}
impl Trait for u8 {}
}
mod m2 {
pub trait Trait {
fn method2(&self) {}
}
impl Trait for u8 {}
}
fn main() {
use m1::*; // Imports `m1::Trait`
use m2::*; // imports `m2::Trait`
0u8.method1();
0u8.method2();
}
Explanation
When multiple traits with the same name are brought into scope through glob imports, one trait becomes the "primary" one while the others are shadowed. Methods from the shadowed traits (e.g. method2) become inaccessible, while methods from the "primary" trait (e.g. method1) still resolve. Ideally, none of the ambiguous traits would be in scope, but we have to allow this for now because of backwards compatibility. This lint reports uses of these "primary" traits that are ambiguous.
Implementation history
- #149058 introduced the lint
- #159599 also made this lint against any ambiguity of the trait (not only trait vs trait)
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 with the example and read the implementation history in #149058 and #159599. The issue names no source files or tests, so a contribution first needs a concrete follow-up scope and an agreed, testable outcome for the lint.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100