Skip to content

Resolve: refactor define into define_local and define_extern #143884

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

LorrensP-2158466
Copy link
Contributor

@LorrensP-2158466 LorrensP-2158466 commented Jul 13, 2025

Follow up on #143550 and part of #gsoc > Project: Parallel Macro Expansion.

Split up define into define_local and define_extern. Refactor usages of define into either one where it's "correct" (idk if everything is correct atm). Big part of this is that resolution can now take a &Resolver instead of a mutable one.

Needed the module changes of #143550. Review will probably be easier when viewing my first commit instead of all the changes.

r? @petrochenkov

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 13, 2025
@bors

This comment was marked as resolved.

@LorrensP-2158466
Copy link
Contributor Author

LorrensP-2158466 commented Jul 13, 2025

Conflicts must be resolved in Petrochenkov's PRs, I think. I can then rebase off that.

@petrochenkov
Copy link
Contributor

Blocked on #143550.
@rustbot blocked

@rustbot rustbot added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 14, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 17, 2025
resolve: Use interior mutability for extern module map

Module map for extern modules is a lazily populated cache, it's not *significantly* mutable.
If some logic in name resolver is parallelized, then this cache can be populated from any thread, and without affecting results of any speculative resolution.

Unblocks rust-lang#143884.
This is a part of [#gsoc > Project: Parallel Macro Expansion](https://rust-lang.zulipchat.com/#narrow/channel/421156-gsoc/topic/Project.3A.20Parallel.20Macro.20Expansion/with/527348747).
cc `@LorrensP-2158466`
rust-timer added a commit that referenced this pull request Jul 17, 2025
Rollup merge of #143550 - petrochenkov:lessmutres, r=lcnr

resolve: Use interior mutability for extern module map

Module map for extern modules is a lazily populated cache, it's not *significantly* mutable.
If some logic in name resolver is parallelized, then this cache can be populated from any thread, and without affecting results of any speculative resolution.

Unblocks #143884.
This is a part of [#gsoc > Project: Parallel Macro Expansion](https://rust-lang.zulipchat.com/#narrow/channel/421156-gsoc/topic/Project.3A.20Parallel.20Macro.20Expansion/with/527348747).
cc `@LorrensP-2158466`
@rust-log-analyzer

This comment has been minimized.

@LorrensP-2158466
Copy link
Contributor Author

I couldn't find any more &mut Resolver that I could turn into &Resolver. Everything now either has finalize codepaths and/or lints/errors getting added to their respective collections.

@LorrensP-2158466 LorrensP-2158466 marked this pull request as ready for review July 17, 2025 19:57
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 17, 2025
@LorrensP-2158466 LorrensP-2158466 changed the title [WIP] Resolve: refactor define into define_local and define_extern Resolve: refactor define into define_local and define_extern Jul 17, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 18, 2025
resolve: Make disambiguators for underscore bindings module-local

Disambiguators attached to underscore name bindings (like `const _: u8 = something;`) do not need to be globally unique, they just need to be unique inside the module in which they live, because the bindings in a module are basically kept as `Map<BindingKey, SomeData>`.

Also, the specific values of the disambiguators are not important, so a glob import of `const _` may have a different disambiguator than the original `const _` itself.

So in this PR the disambiguator is just set to the current number of bindings in the module.
This removes one more piece of global mutable state from resolver and unblocks rust-lang#143884.
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jul 18, 2025
resolve: Use interior mutability for extern module map

Module map for extern modules is a lazily populated cache, it's not *significantly* mutable.
If some logic in name resolver is parallelized, then this cache can be populated from any thread, and without affecting results of any speculative resolution.

Unblocks rust-lang/rust#143884.
This is a part of [#gsoc > Project: Parallel Macro Expansion](https://rust-lang.zulipchat.com/#narrow/channel/421156-gsoc/topic/Project.3A.20Parallel.20Macro.20Expansion/with/527348747).
cc `@LorrensP-2158466`
@petrochenkov
Copy link
Contributor

Blocked on #144013.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 18, 2025
resolve: Make disambiguators for underscore bindings module-local

Disambiguators attached to underscore name bindings (like `const _: u8 = something;`) do not need to be globally unique, they just need to be unique inside the module in which they live, because the bindings in a module are basically kept as `Map<BindingKey, SomeData>`.

Also, the specific values of the disambiguators are not important, so a glob import of `const _` may have a different disambiguator than the original `const _` itself.

So in this PR the disambiguator is just set to the current number of bindings in the module.
This removes one more piece of global mutable state from resolver and unblocks rust-lang#143884.
@petrochenkov petrochenkov removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 18, 2025
rust-timer added a commit that referenced this pull request Jul 18, 2025
Rollup merge of #144013 - petrochenkov:disambunder, r=oli-obk

resolve: Make disambiguators for underscore bindings module-local

Disambiguators attached to underscore name bindings (like `const _: u8 = something;`) do not need to be globally unique, they just need to be unique inside the module in which they live, because the bindings in a module are basically kept as `Map<BindingKey, SomeData>`.

Also, the specific values of the disambiguators are not important, so a glob import of `const _` may have a different disambiguator than the original `const _` itself.

So in this PR the disambiguator is just set to the current number of bindings in the module.
This removes one more piece of global mutable state from resolver and unblocks #143884.
@bors
Copy link
Collaborator

bors commented Jul 18, 2025

☔ The latest upstream changes (presumably #144130) made this pull request unmergeable. Please resolve the merge conflicts.

@LorrensP-2158466
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Jul 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants