I tried this code:
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 test1() {
// Create an ambiguous import for `Trait` in one order
use m1::*;
use m2::*;
0u8.method1(); // OK
0u8.method2(); // ERROR no method named `method2` found for type `u8` in the current scope
}
fn test2() {
// Create an ambiguous import for `Trait` in another order
use m2::*;
use m1::*;
0u8.method1(); // ERROR no method named `method1` found for type `u8` in the current scope
0u8.method2(); // OK
}
fn main() {}
I expected to see this happen: either none of the Traits is in scope, or both of them are in scope.
Instead, this happened: the resolution depends on glob import order, which is supposed to never happen.
Meta
rustc --version --verbose:
rustc 1.92.0-nightly (f04e3dfc8 2025-10-19)
binary: rustc
commit-hash: f04e3dfc87d7e2b6ad53e7a52253812cd62eba50
commit-date: 2025-10-19
host: x86_64-pc-windows-gnu
release: 1.92.0-nightly
LLVM version: 21.1.3
I tried this code:
I expected to see this happen: either none of the
Traits is in scope, or both of them are in scope.Instead, this happened: the resolution depends on glob import order, which is supposed to never happen.
Meta
rustc --version --verbose: