Description
Let's say I've got the following module architecture, where I define in a sub-module a struct named GC
that I wand to use from another sub-module. Because m
is private, I use a pub use
to make it available
pub mod foo {
pub use self::m::GC;
mod m {
pub struct GC {
a: uint
}
}
}
mod bar {
use foo::GC;
}
fn main() {
}
The error message for this is absolutely weird :
main.rs:12:9: 12:16 error: unresolved import: there is no `GC` in `foo`
main.rs:12 use foo::GC;
^~~~~~~
main.rs:12:9: 12:16 error: failed to resolve import `foo::GC`
main.rs:12 use foo::GC;
^~~~~~~
error: aborting due to 2 previous errors
This bugs happens whenever the item I try to re-export is named like an item in the Prelude, say, GC
, Vec
, etc. but as long as I change it to something completely arbitrary, say Foo
, it works as expected.
I don't know if it's intended that it's impossible to "re-export" with pub use
names that are already in the prelude. I suspect it's not, but even if its, the error message is really not helpful, since it only points the place where the re-export is actually used, and not the pub use
itself. But it should definitively be possible to override names in the prelude, I think. It's possible with "normal" use
statements, so why not pub use
?
Also, I found this bug updating an old code base that was written something like 5-6 months ago (Rust was in 0.9 back then I believe), so I'm not absolutely sure but as this code hasn't changed except the changes I made to update it, I suspect that this worked before.