-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
resolve: Mark items under exported ambiguous imports as exported #150491
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
base: main
Are you sure you want to change the base?
Conversation
|
These commits modify Please ensure that if you've changed the output:
|
|
cc @obi1kenobi #149195 (comment) From the Not marking items accessible through ambiguous imports as exported can cause errors like "missing optimized MIR" or linking errors, but I'm not sure if it can cause ICEs. |
|
Thanks for the tag. I read the contents of this PR and also the description at #147984 (comment) and I still have a few questions. #147984 (comment) mentioned the desire to make both local and cross-crate ambiguous errors behave consistently, which makes sense to me. But is that change limited solely to improving errors only? Or is it possible that a Rust program that previously would have failed to compile now is able to compile without errors, even if some lints had to be allowed? cargo-semver-checks currently treats ambiguity as "attempting to use either item is an error." I'm attempting to determine if that's ever not correct, including with lints, so we can raise the right diagnostic with full and accurate info. Right now I'm worried that I don't know how to model the case of "one of the items is made available but it isn't defined which one". |
That's the main problem, the compiler cannot define it either - it depends on internal unstable details that we don't want to expose, like specific expansion and import resolution order. If this is reported as a deprecation lint and not an error, the specific compiler's choice can be visible from the the effective visibility tables - the chosen alternative will be marked as exported, and the other alternatives will not.
It's a language change, not just diagnostics, more names appear in modules and they may cause more names to appear in other modules through imports, and may cause more name conflicts. In case of glob conflicts new programs will be able to compile under deprecation lints, some programs that previously compiled will report deprecation lints and will stop compiling in the future, in corner cases some compiling programs even start reporting hard errors like in the examples from #147984 (comment). |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
cc0952f to
a6c32d3
Compare
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
a6c32d3 to
6ada0d2
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
ping @yaahc, it's been 2 weeks |
|
Hey, sorry for the delay. I took a look at it and it looks fine to me but to be honest, I don't have any prior familiarity with rustc_resolve/src/effective_visibilities.rs. I haven't had to dig into it for the reference documentation work so far so this is my first time exploring it that I can recall. I did my best to go through this and try to understand what it does. I'm going to try to summarize it as I understand the logic and, assuming my summary is effectively correct, consider this an approval for r=me, but if my summary has any clear misunderstandings in it please help me correct them before merging. I'm starting with
After this change, these updates are treated as orthogonal, If there is ambiguity on a re-exported import, that gets tracked as before, but now even if there is ambiguity the effective visibility information about that import still gets propagated into the resolver's effective_visibilities struct. The changes to To try to put it into simpler terms, it looks like previously we'd track only the effective visibility of non-ambiguous imports and defs, we'd separately track any ambiguous re-exports, but only the outermost import in the chain, nothing deeper was tracked if it was only reachable through the ambiguity. Now we ignore ambiguity completely for the purposes of tracking effective visibility while still separately tracking which of those imports is ambiguous. On the surface this looks like a nice simplification of existing logic. Let me know if I got that all right. Also, thank you for splitting the test out into an earlier commit so I could see the diff in the error before and after the change. |
|
Your comment summarizes the logic quite well.
Yeah, the effective visibility tables are not supposed to have a direct effect on language, because they are not necessarily precise (they can conservatively mark things as more reexported/reachable). In particular, the impreciseness and conservativeness allows us to mark slightly more things as exported in this PR. E.g. technically we only need to export things if the ambiguous reexport eventually reaches the crate boundary, because locally it's usually an error rather than a lint. But in practice crate-local parts of the effvis tables are not used much, so we just avoid all the complexity by marking the whole chains reexported. I think eventually, when all cases of |
|
@bors r+ |
resolve: Mark items under exported ambiguous imports as exported After rust-lang#147984 one of the imports in an ambiguous import set becomes accessible under a deny-by-default deprecation lint. So if it points to something, that something needs to be marked as exported, so its MIR is encoded into metadata, its symbol is not lost from object files, etc. The added test shows an example. This fixes around 10-20 crater regressions found in rust-lang#149195 (comment). Unblocks rust-lang#149195.
|
looks like a test failed in #151710 (comment) |
|
@bors r- |
|
Commit 6ada0d2 has been unapproved. |
After #147984 one of the imports in an ambiguous import set becomes accessible under a deny-by-default deprecation lint.
So if it points to something, that something needs to be marked as exported, so its MIR is encoded into metadata, its symbol is not lost from object files, etc.
The added test shows an example.
This fixes around 10-20 crater regressions found in #149195 (comment).
Unblocks #149195.