Skip to content

resolve: Split extern prelude into two scopes #144793

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

Merged
merged 3 commits into from
Aug 14, 2025

Conversation

petrochenkov
Copy link
Contributor

@petrochenkov petrochenkov commented Aug 1, 2025

One scope for extern crate items and another for --extern options, with the former shadowing the latter.

If in a single scope some things can overwrite other things, especially with ad hoc restrictions like MacroExpandedExternCrateCannotShadowExternArguments, then it's not really a single scope.
So this PR splits Scope::ExternPrelude into two cleaner scopes.

This is similar to how #144131 splits module scope into two scopes for globs and non-globs, but simpler.

@rustbot
Copy link
Collaborator

rustbot commented Aug 1, 2025

r? @davidtwco

rustbot has assigned @davidtwco.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot

This comment was marked as resolved.

@rustbot
Copy link
Collaborator

rustbot commented Aug 1, 2025

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@petrochenkov
Copy link
Contributor Author

Blocked on #144746.
@rustbot blocked

@petrochenkov
Copy link
Contributor Author

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Aug 1, 2025

⌛ Trying commit 4d377d2 with merge 7203fa8

To cancel the try build, run the command @bors try cancel.

rust-bors bot added a commit that referenced this pull request Aug 1, 2025
resolve: Split extern prelude into two scopes
@rustbot
Copy link
Collaborator

rustbot commented Aug 1, 2025

Unknown labels: S-waiting-on-perf

@rust-log-analyzer

This comment has been minimized.

@Urgau Urgau added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 1, 2025
@rust-bors
Copy link

rust-bors bot commented Aug 1, 2025

☀️ Try build successful (CI)
Build commit: 7203fa8 (7203fa84a1f9a0aa515efc5f680f761ea01d95fc, parent: 4b55fe199cfe9c710555a5af7f2a49491ad38254)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (7203fa8): comparison URL.

Overall result: ❌ regressions - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.1% [0.1%, 0.2%] 5
Regressions ❌
(secondary)
0.1% [0.0%, 0.2%] 12
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [0.1%, 0.2%] 5

Max RSS (memory usage)

Results (primary 2.0%, secondary -3.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.0% [2.0%, 2.0%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.3% [-4.2%, -2.4%] 2
All ❌✅ (primary) 2.0% [2.0%, 2.0%] 1

Cycles

Results (secondary 0.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.9% [2.9%, 4.4%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.1% [-5.2%, -3.0%] 2
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 467.125s -> 467.279s (0.03%)
Artifact size: 376.83 MiB -> 376.88 MiB (0.01%)

@rustbot rustbot added the perf-regression Performance regression. label Aug 1, 2025
@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 4, 2025
@petrochenkov
Copy link
Contributor Author

The error on CI is basically from this case:

// main.rs
extern crate std as something;

fn main() {
    something::println!();
}

// command line
rustc --extern something=/path/to/nowhere main.rs

Previously we didn't try to load something from --extern because it was shadowed, now we try and fail.
(Except on CI the loading succeeds and results in duplicate lang items later, but the root reason is the same.)

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment was marked as resolved.

petrochenkov added a commit to petrochenkov/rust that referenced this pull request Aug 8, 2025
I.e. do not mark them as used, or non-speculative loaded, or similar.
Previously they were sometimes finalized during early resolution, causing issues like rust-lang#144793 (comment).
@petrochenkov
Copy link
Contributor Author

The error on CI is basically from this case:

// main.rs
extern crate std as something;

fn main() {
    something::println!();
}

// command line
rustc --extern something=/path/to/nowhere main.rs

Previously we didn't try to load something from --extern because it was shadowed, now we try and fail. (Except on CI the loading succeeds and results in duplicate lang items later, but the root reason is the same.)

Addressed in #145113.
@rustbot blocked

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Aug 8, 2025
petrochenkov added a commit to petrochenkov/rust that referenced this pull request Aug 11, 2025
I.e. do not mark them as used, or non-speculative loaded, or similar.
Previously they were sometimes finalized during early resolution, causing issues like rust-lang#144793 (comment).
petrochenkov added a commit to petrochenkov/rust that referenced this pull request Aug 11, 2025
I.e. do not mark them as used, or non-speculative loaded, or similar.
Previously they were sometimes finalized during early resolution, causing issues like rust-lang#144793 (comment).
petrochenkov added a commit to petrochenkov/rust that referenced this pull request Aug 11, 2025
I.e. do not mark them as used, or non-speculative loaded, or similar.
Previously they were sometimes finalized during early resolution, causing issues like rust-lang#144793 (comment).
petrochenkov added a commit to petrochenkov/rust that referenced this pull request Aug 11, 2025
I.e. do not mark them as used, or non-speculative loaded, or similar.
Previously they were sometimes finalized during early resolution, causing issues like rust-lang#144793 (comment).
petrochenkov added a commit to petrochenkov/rust that referenced this pull request Aug 12, 2025
I.e. do not mark them as used, or non-speculative loaded, or similar.
Previously they were sometimes finalized during early resolution, causing issues like rust-lang#144793 (comment).
@petrochenkov
Copy link
Contributor Author

I've included a piece of #145113 only affecting --extern flags into this PR.
@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 Aug 13, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the T-clippy Relevant to the Clippy team. label Aug 13, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 13, 2025

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

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

LGTM if there aren't more changes you want to make and CI is passing

@petrochenkov
Copy link
Contributor Author

@bors r=davidtwco

@bors
Copy link
Collaborator

bors commented Aug 13, 2025

📌 Commit 9aa6cb5 has been approved by davidtwco

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 13, 2025
@bors
Copy link
Collaborator

bors commented Aug 13, 2025

⌛ Testing commit 9aa6cb5 with merge 8e77954...

@bors
Copy link
Collaborator

bors commented Aug 14, 2025

☀️ Test successful - checks-actions
Approved by: davidtwco
Pushing 8e77954 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 14, 2025
@bors bors merged commit 8e77954 into rust-lang:master Aug 14, 2025
11 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 14, 2025
Copy link
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 3672a55 (parent) -> 8e77954 (this PR)

Test differences

Show 22 test diffs

Stage 1

  • [ui] tests/ui/resolve/extern-prelude-speculative.rs: [missing] -> pass (J1)

Stage 2

  • [ui] tests/ui/resolve/extern-prelude-speculative.rs: [missing] -> pass (J0)

Additionally, 20 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 8e7795415acaa9471b5eeb2301915d6996d289ec --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-x86_64-apple: 11797.7s -> 18031.9s (52.8%)
  2. dist-aarch64-linux: 8640.0s -> 6005.8s (-30.5%)
  3. aarch64-apple: 6841.8s -> 5245.9s (-23.3%)
  4. aarch64-msvc-1: 7552.7s -> 6718.1s (-11.1%)
  5. x86_64-apple-2: 7080.6s -> 7840.2s (10.7%)
  6. dist-apple-various: 5541.7s -> 5039.5s (-9.1%)
  7. x86_64-gnu-llvm-20-1: 3393.3s -> 3698.2s (9.0%)
  8. dist-x86_64-netbsd: 5005.2s -> 4591.3s (-8.3%)
  9. aarch64-gnu-debug: 4973.0s -> 4669.2s (-6.1%)
  10. dist-i686-msvc: 8237.1s -> 7746.4s (-6.0%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (8e77954): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.2% [0.2%, 0.2%] 2
Regressions ❌
(secondary)
0.7% [0.3%, 1.9%] 4
Improvements ✅
(primary)
-0.4% [-0.7%, -0.2%] 5
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.2% [-0.7%, 0.2%] 7

Max RSS (memory usage)

Results (primary -7.3%, secondary 2.9%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.9% [2.9%, 2.9%] 1
Improvements ✅
(primary)
-7.3% [-7.3%, -7.3%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -7.3% [-7.3%, -7.3%] 1

Cycles

Results (secondary 1.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.6% [1.6%, 1.6%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

Results (secondary -0.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.4% [-0.8%, -0.1%] 6
All ❌✅ (primary) - - 0

Bootstrap: 468.653s -> 469.796s (0.24%)
Artifact size: 377.36 MiB -> 377.36 MiB (-0.00%)

petrochenkov added a commit to petrochenkov/rust that referenced this pull request Aug 14, 2025
I.e. do not mark them as used, or non-speculative loaded, or similar.
Previously they were sometimes finalized during early resolution, causing issues like rust-lang#144793 (comment).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-clippy Relevant to the Clippy team. 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.

7 participants