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.

@petrochenkov
Copy link
Contributor

petrochenkov commented Dec 3, 2025

We should be able to land this after merging #147984 and #149596 (and maybe also #149058).

@LorrensP-2158466
Copy link
Contributor Author

Did you also want this to include the parallelisation of the algorithm in this pr? If so, I can start looking into it while waiting on those pr's.

@petrochenkov
Copy link
Contributor

petrochenkov commented Dec 3, 2025

Did you also want this to include the parallelisation of the algorithm in this pr?

No, of course not, it is nontrivial and will also take at least weeks, if not more.
(But it would certainly be good to look into it in advance.)

@LorrensP-2158466
Copy link
Contributor Author

No, of course not, it is nontrivial and will also take at least weeks, if not more.
(But it would certainly be good to look into it in advance.)

Yeah, that's what I thought 😅. Will look into it!

bors added a commit that referenced this pull request Dec 9, 2025
resolve: Preserve ambiguous glob reexports in crate metadata

So in cross-crate scenarios they can work in the same way as in crate-local scenarios.

Change Description: #147984 (comment)

Resurrection of #114682.
One of unblocking steps for #145108.
Fixes #36837.
Kobzol pushed a commit to Kobzol/rustc_codegen_gcc that referenced this pull request Dec 21, 2025
…r=petrochenkov

Resolve the prelude import in `build_reduced_graph`

This pr tries to resolve the prelude import at the `build_reduced_graph` stage.
Part of batched import resolution in rust-lang/rust#145108 (cherry picked commit) and maybe needed for rust-lang/rust#139493.

r? petrochenkov
Kobzol pushed a commit to Kobzol/rustc_codegen_cranelift that referenced this pull request Dec 29, 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`
Kobzol pushed a commit to Kobzol/rustc_codegen_cranelift that referenced this pull request Dec 29, 2025
…chenkov

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/rust#145108.

r? `@petrochenkov`
@LorrensP-2158466 LorrensP-2158466 force-pushed the batched-import-resolution branch from 88b3daf to 4632f09 Compare January 13, 2026 18:30
@rustbot

This comment has been minimized.

@LorrensP-2158466
Copy link
Contributor Author

LorrensP-2158466 commented Jan 13, 2026

I finally rebased... should have done that way sooner, but it went well. The only problem is that imports/ambiguous-9.rs is panicking:

thread 'rustc' (16848976) panicked at compiler/rustc_resolve/src/imports.rs:328:9:
assertion failed: !d1.warn_ambiguity.get()
stack backtrace:

Luckily I'm following issues/pr's made to the resolver, so I remembered it was related to #150927 and fixed in #150939. I removed it for now, couldn't find another clean way to ignore it. When that pr is merged I can just remove the commit.

Also the RustEmbed hack can be removed, right? Because of the conflicting importsvisibilities of the imported derive macro.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 13, 2026
@rust-log-analyzer

This comment has been minimized.

@petrochenkov
Copy link
Contributor

Also the RustEmbed hack can be removed, right? Because of the conflicting importsvisibilities of the imported derive macro.

IIRC, the hack changed the resolution priorities to avoid breakage, while #149596 only adds a warning for the conflicting visibilities, so the hack will still be needed in some form.

@petrochenkov
Copy link
Contributor

Although if a new patch version of rust-embed is published, and the issue doesn't occur in other known crates, then maybe it won't be needed. We'll run crater on this PR in any case, once all the blocking PRs are merged.

@LorrensP-2158466
Copy link
Contributor Author

Although if a new patch version of rust-embed is published

The patch was published a while back as rust-embed/8.8.0. The latest version is 8.10.0. Though this error happens in dependencies, everything works fine crate-local.

and the issue doesn't occur in other known crates, then maybe it won't be needed

IIRC, rust-embed was the only crate which had this pattern and caused problems for downstream crates.

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 14, 2026

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

@LorrensP-2158466 LorrensP-2158466 force-pushed the batched-import-resolution branch from 4632f09 to 0f6b71c Compare January 14, 2026 17:39
@rustbot
Copy link
Collaborator

rustbot commented Jan 14, 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

Had to rebase again, in the last commit the test tests/ui/imports/ambiguous-panic-globvsglob.rs is changed because of the mismatched stderr output. I don't really see if it's still correct.

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

failures:

---- names/name-resolution.md - Name_resolution::Expansion_time_name_resolution::Imports::Ambiguities (line 269) stdout ----
##[error]error: internal compiler error: compiler/rustc_middle/src/middle/privacy.rs:187:21: DefId(0:10 ~ rust_out[9c1d]::m3::{use#1}): reachable Restricted(DefId(0:0 ~ rust_out[9c1d])) > nominal Restricted(DefId(0:8 ~ rust_out[9c1d]::m3))
   --> names/name-resolution.md:285:9
    |
285 |     use super::m2::*;
    |         ^^^^^^^^^


thread 'rustc' (37218) panicked at compiler/rustc_middle/src/middle/privacy.rs:187:21:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   2: <rustc_errors::DiagCtxtHandle>::span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
   3: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   5: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   6: rustc_middle::util::bug::span_bug_fmt::<rustc_span::span_encoding::Span>
   7: <rustc_middle::middle::privacy::EffectiveVisibilities>::check_invariants
   8: rustc_privacy::effective_visibilities
      [... omitted 2 frames ...]
   9: std::panicking::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#0}::{closure#1}::{closure#0}>>
  10: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#0}>
  11: rustc_interface::passes::analysis
      [... omitted 2 frames ...]
  12: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::ty::context::GlobalCtxt>::enter<rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}, core::option::Option<rustc_interface::queries::Linker>>::{closure#1}, core::option::Option<rustc_interface::queries::Linker>>::{closure#0}, core::option::Option<rustc_interface::queries::Linker>>
  13: <rustc_middle::ty::context::TyCtxt>::create_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}>
  14: <rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core::ops::function::FnOnce<(&rustc_session::session::Session, rustc_middle::ty::context::CurrentGcx, alloc::sync::Arc<rustc_data_structures::jobserver::Proxy>, &std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  15: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
  16: std::panicking::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}::{closure#0}>>
  17: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}, ()>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

---

note: compiler flags: --crate-type bin

query stack during panic:
#0 [effective_visibilities] checking effective visibilities
#1 [analysis] running analysis passes on crate `rust_out`
end of query stack
error: aborting due to 1 previous error

Couldn't compile the test.

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 15, 2026

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

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