Skip to content

Do not use effective_visibilities query for Adt types of a local trait while proving a where-clause #145642

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 1 commit into from
Aug 21, 2025

Conversation

xizheyin
Copy link
Member

@xizheyin xizheyin commented Aug 20, 2025

Partially fix #145611, but we should do something make cycle in this situation ICE.

Instead of using a query, call &tcx.resolutions(()).effective_visibilities.

r? @lcnr

cc @compiler-errors

@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 Aug 20, 2025
@@ -2878,7 +2878,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
// we check if `TraitB` can be reachable from `S`
// to determine whether to note `TraitA` is sealed trait.
if let ty::Adt(adt, _) = ty.kind() {
let visibilities = tcx.effective_visibilities(());
let visibilities = &tcx.resolutions(()).effective_visibilities;
Copy link
Contributor

Choose a reason for hiding this comment

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

okay 🤔 what does the effective_visibilities query actually do with the effective_visibilities computed by by nameres? I generally feel like it should have some more comments somewhere.

cc @petrochenkov maybe?

Copy link
Member Author

@xizheyin xizheyin Aug 20, 2025

Choose a reason for hiding this comment

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

I noticed that in versions prior to #143431, &tcx.resolutions(()).effective_visibilities was used in this way. As for what exactly it does, I'm not quite sure. At the time, I used this API as suggested.🤔

https://github.com/rust-lang/rust/pull/143431/files#diff-c712eee556d0df70dfc5c8c66c34fa13fc94a30853854f632f5dd84acfd9c973L2778

Copy link
Contributor

Choose a reason for hiding this comment

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

okay 🤔 what does the effective_visibilities query actually do with the effective_visibilities computed by by nameres?

Actually calculates them.
Name resolutions can only fill the "directly public" and "exported" levels, based on modules, reexports and nominal visibility.
The query uses type information and calculates the remaining "reachable" levels too.

Copy link
Contributor

Choose a reason for hiding this comment

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

Here we are only checking Level::Reexported so it's ok to use the incomplete effective visibilities from name resolver.

@lcnr
Copy link
Contributor

lcnr commented Aug 20, 2025

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Aug 20, 2025

📌 Commit 885fecd has been approved by lcnr

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 20, 2025
@lcnr
Copy link
Contributor

lcnr commented Aug 20, 2025

@bors r- (forgot I've had a nit)

r=me after nit @bors delegate+

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 20, 2025
@lcnr lcnr added beta-nominated Nominated for backporting to the compiler in the beta channel. 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 20, 2025
…t while proving a where-clause

Signed-off-by: xizheyin <[email protected]>
@xizheyin
Copy link
Member Author

Added some comments for the test, waiting for CI green...

// This test is for regression of issue #145611
// There should not be cycle error in effective_visibilities query.

@xizheyin
Copy link
Member Author

@bors r=lcnr

@bors
Copy link
Collaborator

bors commented Aug 20, 2025

@xizheyin: 🔑 Insufficient privileges: Not in reviewers

@xizheyin
Copy link
Member Author

Unfortunately, bors did not recognize the delegate instruction. 🤔

@lcnr
Copy link
Contributor

lcnr commented Aug 20, 2025

oh fun

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Aug 20, 2025

📌 Commit 27e6726 has been approved by lcnr

It is now in the queue for this repository.

jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 20, 2025
Do not use effective_visibilities query for Adt types of a local trait while proving a where-clause

Partially fix rust-lang#145611, but we should do something make cycle in this situation ICE.

Instead of using a query, call `&tcx.resolutions(()).effective_visibilities`.

r? `@lcnr`

cc `@compiler-errors`
bors added a commit that referenced this pull request Aug 20, 2025
Rollup of 12 pull requests

Successful merges:

 - #143383 (stabilize `const_array_each_ref`)
 - #144443 (Make target pointer width in target json an integer)
 - #144758 ([Doc] Add links to the various collections)
 - #144915 (Defer tail call ret ty equality to check_tail_calls)
 - #145256 (Add new `--test-codegen-backend` bootstrap option)
 - #145415 (std_detect: RISC-V: implement implication to "C")
 - #145573 (Add an experimental unsafe(force_target_feature) attribute.)
 - #145642 (Do not use effective_visibilities query for Adt types of a local trait while proving a where-clause)
 - #145650 (Fix JS search scripts path)
 - #145654 (Download CI GCC into the correct directory)
 - #145662 (Enforce correct number of arguments for `"x86-interrupt"` functions)
 - #145674 (Enable triagebot `[review-changes-since]` feature)

Failed merges:

 - #145647 (miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 20, 2025
Do not use effective_visibilities query for Adt types of a local trait while proving a where-clause

Partially fix rust-lang#145611, but we should do something make cycle in this situation ICE.

Instead of using a query, call `&tcx.resolutions(()).effective_visibilities`.

r? ``@lcnr``

cc ``@compiler-errors``
bors added a commit that referenced this pull request Aug 20, 2025
Rollup of 14 pull requests

Successful merges:

 - #143383 (stabilize `const_array_each_ref`)
 - #144443 (Make target pointer width in target json an integer)
 - #144758 ([Doc] Add links to the various collections)
 - #144915 (Defer tail call ret ty equality to check_tail_calls)
 - #145137 (Consolidate panicking functions in `slice/index.rs`)
 - #145256 (Add new `--test-codegen-backend` bootstrap option)
 - #145297 (fix(debuginfo): handle false positives in overflow check)
 - #145415 (std_detect: RISC-V: implement implication to "C")
 - #145642 (Do not use effective_visibilities query for Adt types of a local trait while proving a where-clause)
 - #145650 (Fix JS search scripts path)
 - #145654 (Download CI GCC into the correct directory)
 - #145662 (Enforce correct number of arguments for `"x86-interrupt"` functions)
 - #145674 (Enable triagebot `[review-changes-since]` feature)
 - #145678 (Fix typo in docstring)

r? `@ghost`
`@rustbot` modify labels: rollup
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 21, 2025
Do not use effective_visibilities query for Adt types of a local trait while proving a where-clause

Partially fix rust-lang#145611, but we should do something make cycle in this situation ICE.

Instead of using a query, call `&tcx.resolutions(()).effective_visibilities`.

r? ```@lcnr```

cc ```@compiler-errors```
bors added a commit that referenced this pull request Aug 21, 2025
Rollup of 15 pull requests

Successful merges:

 - #143383 (stabilize `const_array_each_ref`)
 - #144758 ([Doc] Add links to the various collections)
 - #144915 (Defer tail call ret ty equality to check_tail_calls)
 - #145137 (Consolidate panicking functions in `slice/index.rs`)
 - #145256 (Add new `--test-codegen-backend` bootstrap option)
 - #145297 (fix(debuginfo): handle false positives in overflow check)
 - #145415 (std_detect: RISC-V: implement implication to "C")
 - #145590 (Prevent impossible combinations in `ast::ModKind`.)
 - #145621 (Fix some doc typos)
 - #145642 (Do not use effective_visibilities query for Adt types of a local trait while proving a where-clause)
 - #145650 (Fix JS search scripts path)
 - #145654 (Download CI GCC into the correct directory)
 - #145662 (Enforce correct number of arguments for `"x86-interrupt"` functions)
 - #145674 (Enable triagebot `[review-changes-since]` feature)
 - #145678 (Fix typo in docstring)

r? `@ghost`
`@rustbot` modify labels: rollup
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 21, 2025
Do not use effective_visibilities query for Adt types of a local trait while proving a where-clause

Partially fix rust-lang#145611, but we should do something make cycle in this situation ICE.

Instead of using a query, call `&tcx.resolutions(()).effective_visibilities`.

r? ````@lcnr````

cc ````@compiler-errors````
bors added a commit that referenced this pull request Aug 21, 2025
Rollup of 19 pull requests

Successful merges:

 - #143383 (stabilize `const_array_each_ref`)
 - #144758 ([Doc] Add links to the various collections)
 - #144915 (Defer tail call ret ty equality to check_tail_calls)
 - #145256 (Add new `--test-codegen-backend` bootstrap option)
 - #145297 (fix(debuginfo): handle false positives in overflow check)
 - #145390 (Shorten some dependency chains in the compiler)
 - #145415 (std_detect: RISC-V: implement implication to "C")
 - #145525 (stdlib: Replace typedef -> type alias in doc comment)
 - #145590 (Prevent impossible combinations in `ast::ModKind`.)
 - #145593 (UnsafePinned::raw_get: sync signature with get)
 - #145621 (Fix some doc typos)
 - #145627 (Unconditionally-const supertraits are considered not dyn compatible)
 - #145642 (Do not use effective_visibilities query for Adt types of a local trait while proving a where-clause)
 - #145650 (Fix JS search scripts path)
 - #145654 (Download CI GCC into the correct directory)
 - #145662 (Enforce correct number of arguments for `"x86-interrupt"` functions)
 - #145673 (Add flock support for cygwin)
 - #145674 (Enable triagebot `[review-changes-since]` feature)
 - #145678 (Fix typo in docstring)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 0af35f6 into rust-lang:master Aug 21, 2025
10 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 21, 2025
rust-timer added a commit that referenced this pull request Aug 21, 2025
Rollup merge of #145642 - xizheyin:145611, r=lcnr

Do not use effective_visibilities query for Adt types of a local trait while proving a where-clause

Partially fix #145611, but we should do something make cycle in this situation ICE.

Instead of using a query, call `&tcx.resolutions(()).effective_visibilities`.

r? `````@lcnr`````

cc `````@compiler-errors`````
@apiraino
Copy link
Contributor

Beta backport accepted as per compiler team on Zulip. A backport PR will be authored by the release team at the end of the current development cycle. Backport labels handled by them.

@rustbot label +beta-accepted

@rustbot rustbot added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Aug 21, 2025
@cuviper cuviper mentioned this pull request Aug 21, 2025
@cuviper cuviper modified the milestones: 1.91.0, 1.90.0 Aug 21, 2025
@cuviper cuviper removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Aug 21, 2025
bors added a commit that referenced this pull request Aug 21, 2025
[beta] backports

- Gate const trait syntax #144956
- Demote x86_64-apple-darwin to Tier 2 with host tools #145252
- Do not use effective_visibilities query for Adt types of a local trait while proving a where-clause #145642

r? cuviper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

selection error diagnostics results in a query cycle
7 participants