-
Notifications
You must be signed in to change notification settings - Fork 13.4k
absolute path names are not correct for crates not in root namespace #1920
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
assigning this to @nikomatsakis since you seem to be the author of the relevant code :-) |
@nikomatsakis can you clarify this, possibly with a broken test case? I don't quite understand the description. |
Triage bump. |
Visiting for triage. Presumably still an issue. |
@nikomatsakis , I share @cmr's lack of understanding of what the issue actually is here. And it's been a loooong time. So, without some code to reproduce, I'm giving this a close. |
I get this now, seeing if I can repro. |
Repro:
|
(note that there is a fixme in the code, as suggested by the issue description) |
👍 ❤️ |
Another related issue here is that we have no way to take into account re-exports -- see the reference to |
(Handling re-exports may require some sort of annotations though.) |
ps I remember filing this bug and can hardly believe it's still a thing. ;) |
This changes the current behaviour for two cases (that I know of) ```rust mod foo { extern crate bar; } // `bar::` changes to `foo::bar::` ``` ```rust extern crate bar as quux; // `bar::` changes to `quux::` ``` For example: ```rust mod foo { extern crate core; } fn assert_clone<T>() where T : Clone { } fn main() { assert_clone::<foo::core::atomic::AtomicBool>(); // error: the trait `core::clone::Clone` is not implemented for the type `core::atomic::AtomicBool` [E0277] // changes to // error: the trait `foo::core::clone::Clone` is not implemented for the type `foo::core::atomic::AtomicBool` [E0277] } ``` Notably the following test case broke: ```rust #[bench] fn bar(x: isize) { } //~^ ERROR mismatched types //~| expected `fn(&mut test::Bencher)` // changed to //~| expected `fn(&mut __test::test::Bencher)` ``` If a crate is linked multiple times the path with the least segments is stored. Partially addresses #1920. (this doesn't solve the issue raised about re-exports) r? @nikomatsakis
(Hi, I'm trying to help make E-easy issues more accessible to newcomers 😸) Yup, the failing test case above is still reproducible, although I no longer see a fixme anywhere near I'm not at all clear on what would need to be changed about |
Hmm. There was an effort to fix this. Not sure why it is not handling that test case.I will investigate. |
There is a compile-fail test for this case, so this should work, though this change is not in stable rust yet. |
mod foo {
extern crate core;
}
fn assert_clone<T>() where T : Clone { }
fn main() {
assert_clone::<foo::core::sync::atomic::AtomicBool>();
} Still reproducible on the current nightly (2015-10-27) |
But it looks correct?
The nightly is fine, stable isn't, so this looks fixed. |
Closing as fixed, thanks! |
@jonas-schievink oops sorry, you're right, this is fixed. |
Right now, if you get the absolute path of an item using the
ty::item_path()
function, and that item is an external cratex
, you always get a path likex::foo::bar
wherefoo::bar
is the path to the item within the cratex
. This is usually right but not always, because it is possible that the cratex
is not linked into the root namespace.For example, you might have:
in which case the right path would be
local_mod::x::foo::bar
.To fix this, we ought to store some valid path to the crate along with the crate metadata (preferably a shortest path [there could be more than one shortest path]). We can then prepend this path. The function
csearch.rs:get_item_path()
would be the primary one to change.The text was updated successfully, but these errors were encountered: