Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up2018 path clarity: When path lookup fails because of shadowed crate, provide hint #52209
Comments
memoryruins
added
the
A-diagnostics
label
Sep 15, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
alercah commentedJul 10, 2018
•
edited
In Rust 2018, the new path system allows a local name to shadow a crate name:
The error is because
numrefers to the local name of thenummodule imported on the first line, sonum::BigIntfails to look inside the crate. This can be avoided by usingextern::num::BigInt, which explicitly refers to the crate (note that @aturon proposed here to make::num::BigIntbe 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 "
numrefers to the name declared here; thenumcrate containsBigInt, useextern::num::BigIntto 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.