I'm seeing a strange issue where a type is not being exported from a module if that module imports a type with the same name. Here is an example that demonstrates this issue:
mod abc {
pub struct Beeblebrox;
pub struct Zaphod;
}
mod foo {
pub mod bar {
use crate::abc::*;
#[derive(Debug)]
pub enum Zaphod {
Whale,
President,
}
}
pub use bar::*;
}
mod baz {
pub fn do_something() {
println!("{:?}", crate::foo::Zaphod::Whale);
}
}
fn main() {
baz::do_something();
}
In module bar, we're importing abc::Zaphod, and then defining a type of the same name. When exporting everything from bar via pub use bar::*, the Zaphod type is not exported. Is this expected behavior? It seems wrong to me.
I would have expected the type that's actually declared in bar to take precedence and be exported. Either that, or the compiler should emit a useful error describing the collision. At present, the type is silently omitted.
```
Compiling playground v0.0.1 (/playground)
error[[E0433]](https://doc.rust-lang.org/nightly/error-index.html#E0433): failed to resolve: could not find `Zaphod` in `foo`
--> src/main.rs:20:38
|
20 | println!("{:?}", crate::foo::Zaphod::Whale);
| ^^^^^^ could not find `Zaphod` in `foo`
warning: unused import: `crate::abc::*`
--> src/main.rs:8:13
|
8 | [use crate::abc::*;](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=1980019cec4c271a2bfddb14e2f016f0#)
| ^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
For more information about this error, try `rustc --explain E0433`.
warning: `playground` (bin "playground") generated 1 warning
error: could not compile `playground` due to previous error; 1 warning emitted
```
I'm seeing a strange issue where a type is not being exported from a module if that module imports a type with the same name. Here is an example that demonstrates this issue:
In module
bar
, we're importingabc::Zaphod
, and then defining a type of the same name. When exporting everything frombar
viapub use bar::*
, theZaphod
type is not exported. Is this expected behavior? It seems wrong to me.I would have expected the type that's actually declared in
bar
to take precedence and be exported. Either that, or the compiler should emit a useful error describing the collision. At present, the type is silently omitted.Meta
Backtrace
``` Compiling playground v0.0.1 (/playground) error[[E0433]](https://doc.rust-lang.org/nightly/error-index.html#E0433): failed to resolve: could not find `Zaphod` in `foo` --> src/main.rs:20:38 | 20 | println!("{:?}", crate::foo::Zaphod::Whale); | ^^^^^^ could not find `Zaphod` in `foo` warning: unused import: `crate::abc::*` --> src/main.rs:8:13 | 8 | [use crate::abc::*;](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=1980019cec4c271a2bfddb14e2f016f0#) | ^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default For more information about this error, try `rustc --explain E0433`. warning: `playground` (bin "playground") generated 1 warning error: could not compile `playground` due to previous error; 1 warning emitted ```