-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
resolve: Factor out and document the glob binding overwriting logic #150502
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
Conversation
This comment has been minimized.
This comment has been minimized.
c476e22 to
11cf5db
Compare
This comment has been minimized.
This comment has been minimized.
|
r? @yaahc maybe |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still reviewing. I'm struggling to fully understand what this does and how it works. I might need a more in-depth explanation in order to feel comfortable approving but I'm not done reviewing this yet and plan to pick it up tomorrow so I'll let you know if I get stuck and need said help understanding.
| // - A glob binding is overwritten by its clone after setting ambiguity in it. | ||
| // FIXME: avoid this by removing `warn_ambiguity`, or by triggering glob re-fetch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
confirming, this is the case with this PR right, not just before it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, previously these cases fell under a slightly different FIXME ("avoid this by putting NameBindingData::ambiguity under a cell and updating it in place").
| // - A glob binding is overwritten by its clone after setting ambiguity in it. | ||
| // FIXME: avoid this by removing `warn_ambiguity`, or by triggering glob re-fetch | ||
| // with the same binding in some way. | ||
| // - A glob binding is overwritten by a glob binding re-fetching an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
struggling to understand what this means and how it interacts w/ the 55884 testcase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So suppose we have a glob g1 importing from module m1, and m1 has another glob g2 importing from module m2.
What this says is that when something in m2 changes, we are re-fetching not only g2, but g1 as well.
And g1 will re-fetch updated bindings from g2.
(And of course there also may be more than 2 globs referring to each other in this chain.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is the case that applies to the diagnostic change in tests/ui/imports/issue-55884-1.rs.
(The diagnostic change itself looks right, not sure why it wasn't reported before, maybe due to the deduplication from matches_previous_ambiguity_error, I'll check.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests/ui/imports/issue-55884-1.rs change is not due to the deduplication.
Previously use m::S recorded the outdated resolution of m::S that is not yet ambiguous, and S {} used it.
(Import validation later observed the updated ambiguous resolution though, and reported an error.)
Now the resolution is updated in place, so S {} sees it too, and reports the ambiguity error on use too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What this says is that when something in m2 changes, we are re-fetching not only g2, but g1 as well.
Aah, I think I understand, and when you say "when something in m2 changes" you mean "a macro gets expanded or an import gets materialized", not anything related to incremental compilation.
|
FWIW, this was tested with crater as a part of #149195 (without the update in place part). |
This comment has been minimized.
This comment has been minimized.
|
(Now after #149681 this should be a bit simpler.) |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I think I understand and it seems to make sense.
I'm not 100% sure I understand this well enough to say "Would I be able to spot non-obvious side effects?"1, but I'm also not confident there's anyone else on t-compiler that would be better suited to approve this so given it's already been cratered I'm going to go ahead and say r=me when conflicts are fixed.
View changes since this review
Footnotes
instead of creating fresh bindings.
instead of overwriting bindings in modules.
Do not overwrite unless necessary, and combine both globs instead of losing the first one.
instead of creating fresh bindings, except in one case.
|
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. |
|
@bors r=yaahc |
|
@bors rollup=never |
This comment has been minimized.
This comment has been minimized.
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 2b82e05 (parent) -> 1b9ae9e (this PR) Test differencesNo test diffs found Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 1b9ae9eddcbd3b0105a0828e323c6db5f1e6ad0c --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (1b9ae9e): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary 2.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 474.298s -> 472.721s (-0.33%) |
Also, avoid creating fresh name declarations and overwriting declarations in modules to update some fields in
DeclData, when possible.Instead, change the fields directly in
DeclDatausing cells.Unblocks #149195.