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 upitem_like_imports: Can "ambiguity error" items be reexported? #36837
Comments
This comment has been minimized.
This comment has been minimized.
|
My opinion so far is that reexported |
This comment has been minimized.
This comment has been minimized.
|
I agree that ideally your example would be valid, but I don't think that's possible to implement, at least not without introducing a lot of ambiguous imports ("deadlocking") in code that compiles today. For example, if we resolve If we couldn't assume that the resolution of |
This comment has been minimized.
This comment has been minimized.
|
More specifically, if we wanted to support that example then we wouldn't be able to glob-import a name unless we knew that the name would never become ambiguous in the glob-imported module. Thus, we wouldn't be able to support the following, which compiles today: mod foo {
pub mod quux {}
}
mod bar {
pub use foo::*;
pub use baz::quux::*; // We need to resolve this to deduce that `bar::quux` isn't ambiguous,
}
mod baz {
pub use bar::*; // but that requires importing `quux` here, which we wouldn't be able to do until we have deduced that `quux` isn't ambiguous.
} |
petrochenkov commentedSep 29, 2016
•
edited
Is the next code well formed or not?
Currently the behavior of this code depends on whether the "merge" step is done in the same crate or in some other crate.
In a single crate scenario the snippet above fails to compile with
A is ambiguouserror.If
mergeis moved to another crate, then all erroneous resolutions are filtered away and are not represented in metadata,pub use ambig::*becomes an empty import andmerge::Aunambiguously meansty1::A.Supposedly, local and cross-crate behavior should be the same.
cc @jseyfried @nrc