Description
I tried this code:
use module::*;
mod module {
pub enum B {}
impl B { pub const ASSOC: bool = true; } // used to distinguish the `B`s
}
#[derive()]
pub enum B {}
impl B { pub const ASSOC: bool = false; }
fn main() {
let it = {
use self::*;
B::ASSOC
};
assert_eq!(
it,
{
use self::*;
B::ASSOC
},
);
}
I expected to see this happen: the assertion passing, since { use self::*; B::ASSOC }
should have a consistent value/meaning within main
's fn body
where no other items are defined.
Instead, this happened: the assertion fails!
Meta
Extra comments
-
The key element playing a role here, beyond the blob imports, is the
#[derive()]
slapped ontoB
. This seems to allow for the blob-importedmodule::B
to somehow gain priority over the clearly-definedcrate::B
type withinfn main
's blob import. -
I did not expect the "moving of
{ use self::*; B::ASSOC }
block" to alter this quirk (I was initially writing the MRE asassert_eq!(B::ASSSOC, { use … })
when I ran into this extra bug). -
Could resolve: Remove artificial import ambiguity errors #112086 be relevant? cc @petrochenkov -
Initially discovered on Discord by user
@kyuuhachi
@rustbot modify labels: +regression-from-stable-to-stable