Skip to content

Conversation

@LorrensP-2158466
Copy link
Contributor

Transforms the current algorithm for resolving imports to a batched algorithm. Every import in the indeterminate_imports set is resolved in isolation. This is the only real difference from the current algorithm.

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 Aug 8, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@LorrensP-2158466 LorrensP-2158466 marked this pull request as ready for review August 11, 2025 08:37
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 11, 2025
@rust-log-analyzer

This comment has been minimized.

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 11, 2025
@LorrensP-2158466
Copy link
Contributor Author

LorrensP-2158466 commented Aug 11, 2025

Code looks a little better now and should be more correct than the previous commits, but I have yet to find a way to resolve the current test failures.

@rust-log-analyzer

This comment has been minimized.

@LorrensP-2158466
Copy link
Contributor Author

Okey, I did fix core not being built, but those other errors happened again. We now resolve the prelude import path when we create such an import at build_reduced_graph phase.

@LorrensP-2158466 LorrensP-2158466 force-pushed the batched-import-resolution branch from a3f8ae2 to 4a2a0dc Compare August 11, 2025 20:37
@rust-log-analyzer

This comment has been minimized.

@petrochenkov
Copy link
Contributor

Could you update the tests to make CI green, so I can see the difference?
(Even if the changes do not seem correct.)

@petrochenkov petrochenkov added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 12, 2025
@petrochenkov
Copy link
Contributor

Moving prelude_import processing to build_reduced_graph may also be necessary for #139493.

@LorrensP-2158466
Copy link
Contributor Author

I'll create a pr for it.

@LorrensP-2158466 LorrensP-2158466 force-pushed the batched-import-resolution branch from be968c5 to 9e951c9 Compare October 15, 2025 14:41
@rustbot
Copy link
Collaborator

rustbot commented Oct 15, 2025

This PR was rebased onto a different master 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.

@rust-log-analyzer

This comment has been minimized.

@LorrensP-2158466
Copy link
Contributor Author

I can reproduce that locally, but when I remove that import, everything compiles just fine. I'm guessing this has nothing to do with this pr, so I'll just wait.

@petrochenkov
Copy link
Contributor

Almost all regressions are due to the privacy error of RustEmbed or a indirect error because of that privacy error.

@LorrensP-2158466 Could you send a PR with a fix to the RustEmbed crate itself, so it reexports the macro properly?

@petrochenkov
Copy link
Contributor

petrochenkov commented Oct 15, 2025

I can reproduce that locally, but when I remove that import, everything compiles just fine. I'm guessing this has nothing to do with this pr, so I'll just wait.

If the import is legitimately unused, then it should be removed.
(This PR may potentially result in detecting more unused imports.)

@LorrensP-2158466
Copy link
Contributor Author

(This PR may potentially result in detecting more unused imports.)

Nice! I'll remove it.

@rustbot
Copy link
Collaborator

rustbot commented Oct 15, 2025

rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead.

cc @rust-lang/rust-analyzer

@rustbot rustbot added the T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue. label Oct 15, 2025
self.greatest_vis_map.get(&def_id).copied().unwrap_or(binding.vis);
// macros exported through `macro_export` are not placed in this map, so
// hack the hack and make sure we still keep the best visibility.
if !vis.is_at_least(binding.vis, self.tcx()) { binding.vis } else { vis }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hack has a chance to promote too many unrelated bindings to pub.

Unrelated public item with the same DefId in a different module? Promote to pub.
The glob import never shadows any #[macro_rules] and is never reexported? Nevermind, still promote to pub.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the hack doesn't actually track when a reexport glob shadows a #[macro_use] binding.

@LorrensP-2158466

This comment was marked as off-topic.

@petrochenkov
Copy link
Contributor

This is blocked on me doing some work, rather than reviewing (reexporting ambiguities to other crates, removing mutability from extern underscore disambiguators, finding better solution for the RustEmbed problem).
@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-review Status: Awaiting review from the assignee but also interested parties. labels Oct 15, 2025
@petrochenkov
Copy link
Contributor

@LorrensP-2158466 Could you send a PR with a fix to the RustEmbed crate itself, so it reexports the macro properly?

When clicking on the "repository" link in the crates-io page, I get "404 not found", link: https://git.sr.ht/~pyrossh/rust-embed.

Searching for it in "sourcehut" also doesn't work: https://sr.ht/projects?search=rust-embed&sort=longest-active.

I also can't find it on GitHub and GitLab

https://pyrossh.dev has the author's email.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 18, 2025
…, r=petrochenkov

use module_child index as disambiguator for external items

When defining the items of an external module, if that item is an underscore we use it's index as the disambiguator. This is needed for parallel import resolution, which is being worked on in rust-lang#145108.

r? `@petrochenkov`
rust-timer added a commit that referenced this pull request Oct 18, 2025
Rollup merge of #147805 - LorrensP-2158466:extern-mod-disamb, r=petrochenkov

use module_child index as disambiguator for external items

When defining the items of an external module, if that item is an underscore we use it's index as the disambiguator. This is needed for parallel import resolution, which is being worked on in #145108.

r? `@petrochenkov`
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Oct 18, 2025
…enkov

Resolve: (Ref)Cell wrappers to deny mutation during spec resolution.

Introduces wrappers around `Cell` and `RefCell` that only allow mutation when we are not in speculative resolution. This is preparatory work for rust-lang/rust#145108.

It would allow us to make `ImportData` and `ModuleData` sync and send safe.

r? ``@petrochenkov``
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Oct 18, 2025
…etrochenkov

Test: Ambigious bindings in same namespace with the same res

Add a test based on the discussion [here](https://rust-lang.zulipchat.com/#narrow/channel/421156-gsoc/topic/Project.3A.20Parallel.20Macro.20Expansion/near/542316157) and related to rust-lang/rust#145575 (comment).

This is the most reduced form I could create that passes on nightly but fails with rust-lang/rust#145108 (see [#gsoc > Project: Parallel Macro Expansion @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/421156-gsoc/topic/Project.3A.20Parallel.20Macro.20Expansion/near/542335131)).

Also not sure about the test names.

r? `@petrochenkov`
@LorrensP-2158466 LorrensP-2158466 force-pushed the batched-import-resolution branch from e3a3239 to 88b3daf Compare October 24, 2025 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

I-lang-radar Items that are on lang's radar and will need eventual work or consideration. S-blocked Status: Blocked on something else such as an RFC or other implementation work. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants