-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when using cross-crate static methods exported from a private module via pub use
#4202
Comments
I just tested and it's also a problem for public modules as well. ie:
|
I'm hitting this too trying to update |
Not critical for 0.6; de-milestoning |
Updated reproduction for rust incoming as of May 5th 2013: https://gist.github.com/thomaslee/5522568 Going to see if I can fix this ... |
Looks like I'll keep going down the rabbit hole tomorrow night -- I think the prime suspect atm is a parser bug. |
Alright, I haven't fully proven it yet, but it seems that after more investigation it looks like we may be skipping over some encoding work for the trait we're trying to expose via "pub use". Here's some debug output from building
And the output relating to
We never see the explicit items that we saw decoded for our "good" trait. I'm still figuring out the metadata encoding/decoding stuff, but I have a strong suspicion this is at least related to the original gremlin. |
Looking closer at the code, I suspect the "reexported item: Foo" we're seeing in the log output may relate to sub_foo rather than our "pub use". |
Okay, lots of time lost on various rabbit holes, but I think I understand what's happening here now: Basically we compile foo.rs & see the following explicit symbols exposed by the
Note that the "outer" module has no reference to the static method
|
Have what I believe is a working fix for this that exposes static trait methods by including them in the reexport table iff the reexported trait has a path that differs from the path of the module in which is being reexported from. Will put together a test or two & submit a pull request. |
This fixes the issue described in #4202. From what I understood of the code, when we reexport a trait in a submodule using e.g. "pub use foo::SomeTrait", we were not previously making an effort to reexport the static methods on that trait. I'm new to the Rust code base (and the Rust language itself) so my approach may not be kosher, but this patch works by changing the encoder to include the static methods associated with traits. I couldn't see any tests for this area of the code, so I didn't really have any examples to go by. If tests are needed, I'm happy to work through that if I can get some assistance to do so.
My earlier fix for #4202 would not work correctly if the trait being exported was a top-level item relative to the module from which it was being exported. An example that would not work correctly with the original patch: // foo.rs pub use Foo = self::Bar; pub trait Bar { pub fn bar() -> Self; } impl Bar for int { pub fn bar() -> int { 42 } } // bar.rs fn main() { foo::Foo::bar() } This is now supported. I believe this change will allow the GenericPath trait to be exported from core::path as Path in such a manner, which should allow #5389 to move forward.
confirmed fixed after updating original test case. |
This fixes #6745, which itself relates to #4202. Slightly ham-fisted -- feel particularly funny about using the typeck phase to gather the base -> impl mapping, and the separate code paths for traits vs. "real" bases feels like it could be avoided -- but it seems to work. As always, open to suggestions if there's a better way to accomplish what I'm trying to do. @catamorphism r?
(commented-keywords below are copied over from original bug report.)
foo.rs
bar.rs
The text was updated successfully, but these errors were encountered: