Skip to content

Resolver: Batched Import Resolution#145108

Open
LorrensP-2158466 wants to merge 3 commits intorust-lang:mainfrom
LorrensP-2158466:batched-import-resolution
Open

Resolver: Batched Import Resolution#145108
LorrensP-2158466 wants to merge 3 commits intorust-lang:mainfrom
LorrensP-2158466:batched-import-resolution

Conversation

@LorrensP-2158466
Copy link
Contributor

@LorrensP-2158466 LorrensP-2158466 commented Aug 8, 2025

View all comments

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.

@rust-bors

This comment has been minimized.

@craterbot
Copy link
Collaborator

🎉 Experiment pr-145108-2 is completed!
📊 161 regressed and 1 fixed (821749 total)
📊 2472 spurious results on the retry-regressed-list.txt, consider a retry1 if this is a significant amount.
📰 Open the summary report.

⚠️ If you notice any spurious failure please add them to the denylist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

Footnotes

  1. re-run the experiment with crates=https://crater-reports.s3.amazonaws.com/pr-145108-2/retry-regressed-list.txt

@petrochenkov
Copy link
Contributor

Looks like rust-embed is still a problem.
Could you rebase, squash commits and re-apply the rust-embed hack commit on top of the other changes?
@rustbot author

@rustbot

This comment has been minimized.

@LorrensP-2158466
Copy link
Contributor Author

Fixed conflicts, squashed and re-applied rust-embed fix. @rustbot ready

@rust-bors

This comment has been minimized.

Import resolution now happens in 2 phases:
1. We resolve all undetermined and collect their resolutions
2. Write all resolutions to the Resolver state.

Repeat this untill we reach a fix point.

+ Bless tests
@rustbot
Copy link
Collaborator

rustbot commented Mar 8, 2026

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.

@LorrensP-2158466
Copy link
Contributor Author

LorrensP-2158466 commented Mar 8, 2026

Rebased to fix the conflicts.

The rustembed hack is a bit more generic, than just checking for RustEmbed.

@rustbot ready

@petrochenkov
Copy link
Contributor

petrochenkov commented Mar 8, 2026

The rustembed hack is a bit more generic, than just checking for RustEmbed.

Here we need to address a specific set of regressions caused by one specific crate, not bend the language rules in general, the smaller the scope of the hack is the better.
The ambiguous_import_visibilities lint is the more generic solution.

@LorrensP-2158466
Copy link
Contributor Author

Yes, that's right, I forgot to make myself clear why I made it generic. I couldn't exactly find a way to these 2 points:

  • X is from macro_use_prelude and has name RustEmbed
  • module has a macro namespace binding Y with name RustEmbed in it

I couldn't exactly find a way to check exactly with the name RustEmbed. So I wanted to ask how I can search for a binding with identifier RustEmbed or check that X has such an identifier. Sorry

@LorrensP-2158466
Copy link
Contributor Author

Didn't know I could just add a new symbol, thanks!

@rustbot ready

@petrochenkov
Copy link
Contributor

@bors try

@rust-bors

This comment has been minimized.

@petrochenkov
Copy link
Contributor

TODO: @craterbot check p=1 crates=https://crater-reports.s3.amazonaws.com/pr-145108-2/retry-regressed-list.txt

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 11, 2026

☀️ Try build successful (CI)
Build commit: 0799524 (0799524677c1163b7afa649c7b4006f3d351a1c1, parent: b2fabe39bde5174e8d728bb85f2b8d0572c35b74)

@petrochenkov
Copy link
Contributor

@craterbot
Copy link
Collaborator

👌 Experiment pr-145108-3 created and queued.
🤖 Automatically detected try build 0799524
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🚧 Experiment pr-145108-3 is now running

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🎉 Experiment pr-145108-3 is completed!
📊 31 regressed and 0 fixed (2551 total)
📊 179 spurious results on the retry-regressed-list.txt, consider a retry1 if this is a significant amount.
📰 Open the summary report.

⚠️ If you notice any spurious failure please add them to the denylist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

Footnotes

  1. re-run the experiment with crates=https://crater-reports.s3.amazonaws.com/pr-145108-3/retry-regressed-list.txt

@petrochenkov
Copy link
Contributor

Need regression analysis, each of the regressions need to fall under one of the deprecation lints we've merged recently.
I'll do it myself in a few days.

@petrochenkov
Copy link
Contributor

petrochenkov commented Mar 16, 2026

Analysis:

ambiguous_glob_imported_traits - 22 regressions

  • neivv.animosity.895eaccfc1ba49a5815799e25041926df23bd46b
  • iceoryx2-0.8.1
  • youngday.easy_example.a90b81e8df86e42bea2b46995041f9fbfba8dae0 (iceoryx2-0.8.0)
  • cu-iceoryx2-sink-0.12.0 (iceoryx2-0.8.0)
  • cu-iceoryx2-src-0.12.0 (iceoryx2-0.8.0)
  • 2mauis.iox2_gsml_time_sync.e92fb4e8fbf57da0e14fcb734fb1249eba450b5a (iceoryx2-0.8.1)
  • cu-iceoryx2-bridge-0.13.0 (iceoryx2-0.8.1)
  • iceoryx2-conformance-tests-0.8.1 (iceoryx2-0.8.1)
  • iceoryx2-services-discovery-0.8.1 (iceoryx2-0.8.1)
  • iceoryx2-tunnel-backend-0.8.1 (iceoryx2-0.8.1)
  • iceoryx2-tunnel-conformance-tests-0.8.1 (iceoryx2-0.8.1)
  • iceoryx2-tunnel-zenoh-0.8.1 (iceoryx2-0.8.1)
  • iceoryx2-tunnel-0.8.1 (iceoryx2-0.8.1)
  • iceoryx2-userland-record-and-replay-0.8.1 (iceoryx2-0.8.1)
  • asenetcky.api-testing.9d3c89857a5aaf205ef15237a321e4f861180bed (polars-plan-0.49.1)
  • charles-turner-1.pqdump.d8d0356c5b10f18cab13975543c5a9a57bcf8ac8 (polars-plan-0.51.0)
  • italoag.rfb-rs.95b747eaa7b0d5ad1347366cc77addf3b92ea5f3 (polars-plan-0.51.0)
  • anndata-hdf5-0.5.2 (polars-plan-0.51.0)
  • anndata-memory-1.0.7 (polars-plan-0.51.0)
  • anndata-0.6.2 (polars-plan-0.51.0)
  • parqeye-0.0.2 (polars-plan-0.51.0)
  • pyanndata-0.6.0 (polars-plan-0.51.0)

ambiguous_import_visibilities - 4 regressions

  • contextgeneric.hypershell.4a5e50ccfcd954cb1182c834d1fafab0b54d1a63
  • informalsystems.cgp.3f33054faa225acdb8aa0744e9b40f7c8027b78e
  • cgp-tests-0.7.0
  • hypershell-0.1.0

unused_imports + deny(warnings) - 5 (not really) regressions

  • binggan-0.15.3
  • coasys_juniper_subscriptions-0.17.0
  • juniper_subscriptions_puff-0.17.0-dev
  • measurements-0.11.1
  • mockall_derive-0.14.0

@petrochenkov
Copy link
Contributor

@LorrensP-2158466
Could you fix the issue in iceoryx2-0.8.1 and ask them to make a patch release?
In the latest version of polars-plan the issue is already fixed.

@petrochenkov
Copy link
Contributor

petrochenkov commented Mar 16, 2026

This is not exactly a language change, but I'm going to nominate this for lang team because of the breakage.

Change description for lang team

This change effectively turns some instances of import ambiguity deprecation lints ambiguous_glob_imported_traits and ambiguous_import_visibilities into hard errors (see the list from crater - #145108 (comment)).

The goal of these lints is to catch cases in which results of name resolution are unpredictable and depend on internal details of the name resolution implementation.
This PR actually changes those internal details in preparation for import resolution parallelization, which makes some ambiguous code change its interpretation and report errors.
If those lints completed their life cycle and turned into hard errors, this PR wouldn't cause any breakage.

@LorrensP-2158466
Copy link
Contributor Author

Could you fix the issue in iceoryx2-0.8.1 and ask them to make a patch release?

I just checked and it seems that it's fixed but not yet released? I verified it by running this version of the compiler on both the latest changes and on iceoryx@0.8.1 using cargo clone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

I-lang-nominated Nominated for discussion during a lang team meeting. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. S-waiting-on-t-lang Status: Awaiting decision from T-lang 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.

9 participants