You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 {pubstructBeeblebrox;pubstructZaphod;}mod foo {pubmod bar {usecrate::abc::*;#[derive(Debug)]pubenumZaphod{Whale,President,}}pubuse bar::*;}mod baz {pubfndo_something(){println!("{:?}",crate::foo::Zaphod::Whale);}}fnmain(){
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
The text was updated successfully, but these errors were encountered:
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
The text was updated successfully, but these errors were encountered: