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 3b2e50e to 4efdee8 Compare August 21, 2025 15:08
@rustbot

This comment has been minimized.

@LorrensP-2158466
Copy link
Contributor Author

Original resolver errors are resolved, but...
Compiling libcore now fails where some traits are not implemented for some types, but the code does implement them. Most notable Copy, I have a feeling its derive macro is not being resolved correctly.

Collect side effects from the current set of undetermined imports and only
apply them at the end.
@LorrensP-2158466 LorrensP-2158466 force-pushed the batched-import-resolution branch from 4efdee8 to 8499dd2 Compare August 26, 2025 20:40
@rustbot
Copy link
Collaborator

rustbot commented Aug 26, 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.

@LorrensP-2158466
Copy link
Contributor Author

LorrensP-2158466 commented Aug 26, 2025

Some tests get different or duplicate errors on some lines. Not sure why this is yet.

@rust-log-analyzer

This comment was marked as resolved.

@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 27, 2025
@LorrensP-2158466
Copy link
Contributor Author

Had to bless/change a lot of tests, but they all look like duplicates; I didn't spot anything wrong going on.

@petrochenkov
Copy link
Contributor

Had to bless/change a lot of tests, but they all look like duplicates; I didn't spot anything wrong going on.

Answered on zulip about this.

@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 27, 2025
@LorrensP-2158466 LorrensP-2158466 force-pushed the batched-import-resolution branch from fe82c39 to c334245 Compare August 27, 2025 16:11
Comment on lines +1022 to +1024
// HACK: Use array of namespaces in the same order as `per_ns_mut`.
// We can't use `per_ns_cm` because of the invariance on CmResolver (RefOrMut).
for ns in [TypeNS, ValueNS, MacroNS] {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, the only way out.

@@ -23,6 +23,4 @@ fn main() {
date_range();
//~^ ERROR `date_range` is ambiguous
//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
//~| ERROR `date_range` is ambiguous
//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
Copy link
Contributor Author

Choose a reason for hiding this comment

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

First import not receiving the warning is the wrong part.

glob_conflict::glob::f(); //~ ERROR cannot find function `f` in module `glob_conflict::glob`
glob_conflict::glob::f();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also wrong, I believe. Should give an error or a warning.

@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-19-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
-   --> $DIR/shadowed-use-visibility.rs:15:10
+ error[E0603]: module import `bar` is private
+   --> $DIR/shadowed-use-visibility.rs:9:21
3    |
- LL | use bar::f::f;
-    |          ^ private module import
+ LL |     use crate::foo::bar::f as g;
+    |                     ^^^ private module import
6    |
- note: the module import `f` is defined here...
-   --> $DIR/shadowed-use-visibility.rs:11:9
+ note: the module import `bar` is defined here...
---
-   --> $DIR/shadowed-use-visibility.rs:9:21
+ error[E0603]: module import `f` is private
+   --> $DIR/shadowed-use-visibility.rs:15:10
20    |
- LL |     use crate::foo::bar::f as g;
-    |                     ^^^ private module import
+ LL | use bar::f::f;
+    |          ^ private module import
23    |
- note: the module import `bar` is defined here...
-   --> $DIR/shadowed-use-visibility.rs:4:9
+ note: the module import `f` is defined here...
+   --> $DIR/shadowed-use-visibility.rs:11:9
---
31    |

Note: some mismatched output was normalized before being compared
-   --> /checkout/tests/ui/shadowed/shadowed-use-visibility.rs:9:21
- LL |     use crate::foo::bar::f as g; //~ ERROR module import `bar` is private
-   --> /checkout/tests/ui/shadowed/shadowed-use-visibility.rs:4:9
-   --> /checkout/tests/ui/shadowed/shadowed-use-visibility.rs:15:10
- LL | use bar::f::f; //~ ERROR module import `f` is private
-   --> /checkout/tests/ui/shadowed/shadowed-use-visibility.rs:11:9
+ error[E0603]: module import `bar` is private
+   --> $DIR/shadowed-use-visibility.rs:9:21
+ LL |     use crate::foo::bar::f as g;
+    |                     ^^^ private module import
+ note: the module import `bar` is defined here...
+   --> $DIR/shadowed-use-visibility.rs:4:9
+ LL |     use crate::foo as bar;
+    |         ^^^^^^^^^^^^^^^^^
+ error[E0603]: module import `f` is private
+   --> $DIR/shadowed-use-visibility.rs:15:10
+ LL | use bar::f::f;
+    |          ^ private module import
+ note: the module import `f` is defined here...
+   --> $DIR/shadowed-use-visibility.rs:11:9
+ LL |     use crate::foo as f;
+    |         ^^^^^^^^^^^^^^^


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args shadowed/shadowed-use-visibility.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/shadowed/shadowed-use-visibility.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/shadowed/shadowed-use-visibility" "-A" "unused" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0603]: module import `bar` is private
##[error]  --> /checkout/tests/ui/shadowed/shadowed-use-visibility.rs:9:21
   |
LL |     use crate::foo::bar::f as g; //~ ERROR module import `bar` is private
   |                     ^^^ private module import
   |
note: the module import `bar` is defined here...
  --> /checkout/tests/ui/shadowed/shadowed-use-visibility.rs:4:9
   |
---

error[E0603]: module import `f` is private
##[error]  --> /checkout/tests/ui/shadowed/shadowed-use-visibility.rs:15:10
   |
LL | use bar::f::f; //~ ERROR module import `f` is private
   |          ^ private module import
   |
note: the module import `f` is defined here...
  --> /checkout/tests/ui/shadowed/shadowed-use-visibility.rs:11:9
   |
LL |     use crate::foo as f;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants