Skip to content
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

2018 path clarity: When path lookup fails because of shadowed crate, provide hint #52209

Open
alercah opened this Issue Jul 10, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@alercah
Copy link
Contributor

alercah commented Jul 10, 2018

In Rust 2018, the new path system allows a local name to shadow a crate name:

use std::num;
struct Newtype(num::BigInt); // ERROR

The error is because num refers to the local name of the num module imported on the first line, so num::BigInt fails to look inside the crate. This can be avoided by using extern::num::BigInt, which explicitly refers to the crate (note that @aturon proposed here to make ::num::BigInt be the disambiguation syntax; this doesn't affect the feature request).

The compiler provides no hint of this, however. It could, upon path failure, provide an information along the lines of "num refers to the name declared here; the num crate contains BigInt, use extern::num::BigInt to refer to it" (except written more clearly).

EDIT: The same could apply to any other case where shadowing hides a name that's used as a prefix in a path, but crates seem like the most important.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.