-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
item_like_imports: Can "ambiguity error" items be reexported? #36837
Comments
My opinion so far is that reexported |
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 |
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.
} |
resolve: re-export ambiguity as warning Fixes rust-lang#36837 Expose these ambiguous bindings as warnings instead of simply concealing them. This change introduces potential breaking alterations. For instance, code that previously compiled successfully may now fail to compile as expected: ```rs // lib.rs mod a { pub type C = i8; } mod b { pub type C = i16; } pub use a::*; pub use b::*; // main.rs extern crate lib; mod a { pub type C = i32; } use lib::*; use a::*; fn main() { let _: C = 1; // it will throw an ambiguity error but previous it will not. } ``` r? `@petrochenkov`
Cross-crate encoding for reexported ambiguities was implemented in #114682 but not merged. Issue "Tracking Issue for |
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 ambiguous
error.If
merge
is 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::A
unambiguously meansty1::A
.Supposedly, local and cross-crate behavior should be the same.
cc @jseyfried @nrc
The text was updated successfully, but these errors were encountered: