Skip to content

resolve: Evaluate private visibilities eagerly in eff vis computation#156185

Open
petrochenkov wants to merge 1 commit intorust-lang:mainfrom
petrochenkov:queffvis
Open

resolve: Evaluate private visibilities eagerly in eff vis computation#156185
petrochenkov wants to merge 1 commit intorust-lang:mainfrom
petrochenkov:queffvis

Conversation

@petrochenkov
Copy link
Copy Markdown
Contributor

@petrochenkov petrochenkov commented May 5, 2026

It's cheaper to evaluate them now when Declarations keep their parent modules.

View all comments

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 5, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 5, 2026

r? @folkertdev

rustbot has assigned @folkertdev.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 19 candidates

@petrochenkov
Copy link
Copy Markdown
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 5, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request May 5, 2026
resolve: Try removing questionable optimizations in eff vis computation
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-perf Status: Waiting on a perf run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-perf Status: Waiting on a perf run to be completed. labels May 5, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 5, 2026

☀️ Try build successful (CI)
Build commit: b88d160 (b88d160c3a88b6a02a3856463a035a8b334c6f57, parent: 4feb7221f4d445120a5061b16ce7222adbfdf6f6)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (b88d160): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@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)
1.3% [0.2%, 5.4%] 22
Regressions ❌
(secondary)
1.0% [0.1%, 4.4%] 30
Improvements ✅
(primary)
-0.3% [-0.3%, -0.2%] 8
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.8% [-0.3%, 5.4%] 30

Max RSS (memory usage)

Results (primary 1.7%, secondary -0.1%)

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

mean range count
Regressions ❌
(primary)
2.6% [1.5%, 3.2%] 4
Regressions ❌
(secondary)
1.2% [1.0%, 1.5%] 3
Improvements ✅
(primary)
-2.1% [-2.1%, -2.1%] 1
Improvements ✅
(secondary)
-2.2% [-2.2%, -2.2%] 2
All ❌✅ (primary) 1.7% [-2.1%, 3.2%] 5

Cycles

Results (primary 3.5%, secondary 1.1%)

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

mean range count
Regressions ❌
(primary)
4.7% [2.5%, 6.0%] 5
Regressions ❌
(secondary)
2.2% [0.7%, 3.7%] 4
Improvements ✅
(primary)
-2.2% [-2.2%, -2.2%] 1
Improvements ✅
(secondary)
-0.5% [-0.6%, -0.4%] 3
All ❌✅ (primary) 3.5% [-2.2%, 6.0%] 6

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 495.518s -> 495.363s (-0.03%)
Artifact size: 394.42 MiB -> 394.49 MiB (0.02%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels May 5, 2026
@rustbot

This comment has been minimized.

@petrochenkov
Copy link
Copy Markdown
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 5, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request May 5, 2026
resolve: Try removing questionable optimizations in eff vis computation
@rust-log-analyzer

This comment has been minimized.

@petrochenkov
Copy link
Copy Markdown
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (71f45f1): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

@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
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.3% [-8.6%, -0.2%] 12
Improvements ✅
(secondary)
-1.6% [-2.5%, -0.3%] 14
All ❌✅ (primary) -2.3% [-8.6%, -0.2%] 12

Max RSS (memory usage)

Results (primary 1.0%, secondary 0.1%)

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

mean range count
Regressions ❌
(primary)
4.4% [4.4%, 4.4%] 1
Regressions ❌
(secondary)
1.8% [0.4%, 2.4%] 4
Improvements ✅
(primary)
-2.4% [-2.4%, -2.4%] 1
Improvements ✅
(secondary)
-2.2% [-2.7%, -1.5%] 3
All ❌✅ (primary) 1.0% [-2.4%, 4.4%] 2

Cycles

Results (primary -7.8%, secondary -7.8%)

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.6% [0.5%, 7.4%] 6
Improvements ✅
(primary)
-7.8% [-9.1%, -6.8%] 3
Improvements ✅
(secondary)
-11.1% [-27.5%, -0.6%] 19
All ❌✅ (primary) -7.8% [-9.1%, -6.8%] 3

Binary size

Results (secondary 0.0%)

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.0% [0.0%, 0.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Bootstrap: 499.128s -> 500.469s (0.27%)
Artifact size: 395.02 MiB -> 395.00 MiB (-0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 7, 2026
@petrochenkov
Copy link
Copy Markdown
Contributor Author

What's going on with cycles for tt-muncher though.

Now tt-muncher cycles are very green instead, seems like it's just unreliable.

@petrochenkov
Copy link
Copy Markdown
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 8, 2026
rust-bors Bot pushed a commit that referenced this pull request May 8, 2026
resolve: Evaluate private visibilities eagerly in eff vis computation
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 8, 2026

☀️ Try build successful (CI)
Build commit: e3104ed (e3104edd514605f22290761b3e65b7eb51c2d9a0, parent: 63b1dfc0e00fd6f8ad7cd8817fc712e7d9b7be59)

@rust-timer

This comment has been minimized.

@rust-timer

This comment was marked as outdated.

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 8, 2026
@petrochenkov petrochenkov added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label May 8, 2026
@rustbot

This comment has been minimized.

@petrochenkov
Copy link
Copy Markdown
Contributor Author

@rustbot ready

@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 May 8, 2026
@folkertdev
Copy link
Copy Markdown
Contributor

@rustbot reroll

@rustbot rustbot assigned oli-obk and unassigned folkertdev May 9, 2026
@petrochenkov
Copy link
Copy Markdown
Contributor Author

cc @mu001999

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request May 9, 2026
resolve: Set correct parent and expansion for `self` declarations

Follow up to rust-lang#146972 and rust-lang#154313.

The `parent` seems to not be used yet, it will ICE if used (rust-lang#156185 uses it).
The `expn_id` is only relevant to macros 2.0, I won't bother coming up with a test.
jhpratt added a commit to jhpratt/rust that referenced this pull request May 9, 2026
resolve: Set correct parent and expansion for `self` declarations

Follow up to rust-lang#146972 and rust-lang#154313.

The `parent` seems to not be used yet, it will ICE if used (rust-lang#156185 uses it).
The `expn_id` is only relevant to macros 2.0, I won't bother coming up with a test.
// Set the given effective visibility level to `Level::Direct` and
// sets the rest of the `use` chain to `Level::Reexported` until
// we hit the actual exported item.
let orig_private_vis = self.current_private_vis;
Copy link
Copy Markdown
Member

@mu001999 mu001999 May 9, 2026

Choose a reason for hiding this comment

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

Could we pass self.current_private_vis as an explicit parameter like private_vis: Visibility in the parts other than visit_item? That way, we wouldn’t need to save and restore self.current_private_vis.

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We have to keep current_private_vis in the visitor at least in some cases because in AST visitor when visiting e.g. a struct we don't know it's parent module.
a1d65ae shows how it looks if private visibility is always passed when possible.

main...petrochenkov:rust:queffvis2 shows how it looks if private visibility is only passed to update_(import,def).
It may actually be slightly nicer than the PR version.

Comment thread compiler/rustc_resolve/src/effective_visibilities.rs
@rust-bors

This comment has been minimized.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 9, 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.

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

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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