-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Resolve anon const's parent predicates to direct parent instead of opaque's parent #125501
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 24, 2024
compiler-errors
changed the title
Resolve anon const's parent generics to opaque's parent
Resolve anon const's parent predicates to opaque's origin, not direct parent
May 24, 2024
compiler-errors
force-pushed
the
opaque-opaque-anon-ct
branch
from
May 24, 2024 17:16
0c46d8c
to
de517b7
Compare
@bors r+ |
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
May 24, 2024
BoxyUwU
changed the title
Resolve anon const's parent predicates to opaque's origin, not direct parent
Resolve anon const's parent predicates to direct parent instead of opaque's parent
May 24, 2024
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
May 24, 2024
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#125467 (Only suppress binop error in favor of semicolon suggestion if we're in an assignment statement) - rust-lang#125483 (compiler: validate.rs belongs next to what it validates) - rust-lang#125485 (Migrate `run-make/rustdoc-with-output-dir-option` to `rmake.rs`) - rust-lang#125497 (Fix some SIMD intrinsics documentation) - rust-lang#125501 (Resolve anon const's parent predicates to direct parent instead of opaque's parent) - rust-lang#125503 (rustdoc-json: Add test for keywords with `--document-private-items`) - rust-lang#125519 (tag more stuff with `WG-trait-system-refactor`) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
May 24, 2024
Rollup merge of rust-lang#125501 - compiler-errors:opaque-opaque-anon-ct, r=BoxyUwU Resolve anon const's parent predicates to direct parent instead of opaque's parent When an anon const is inside of an opaque, rust-lang#99801 added a hack to resolve the anon const's parent predicates *not* to the opaque's predicates, but to the opaque's *parent's* predicates. This is insufficient when considering nested opaques. This means that the `predicates_of` an anon const might reference duplicated lifetimes (installed by `compute_bidirectional_outlives_predicates`) when computing known outlives in MIR borrowck, leading to these ICEs: Fixes rust-lang#121574 Fixes rust-lang#118403 ~~Instead, we should be using the `OpaqueTypeOrigin` to acquire the owner item (fn/type alias/etc) of the opaque, whose predicates we're fine to mention.~~ ~~I think it's a bit sketchy that we're doing this at all, tbh; I think it *should* be fine for the anon const to inherit the predicates of the opaque it's located inside. However, that would also mean that we need to make sure the `generics_of` that anon const line up in the same way.~~ ~~None of this is important to solve right now; I just want to fix these ICEs so we can land rust-lang#125468, which accidentally fixes these issues in a different and unrelated way.~~ edit: We don't need this special case anyways because we install the right parent item in `generics_of` anyways: https://github.com/rust-lang/rust/blob/213ad10c8f0fc275648552366275dc4e07f97462/compiler/rustc_hir_analysis/src/collect/generics_of.rs#L150 r? `@BoxyUwU`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When an anon const is inside of an opaque, #99801 added a hack to resolve the anon const's parent predicates not to the opaque's predicates, but to the opaque's parent's predicates. This is insufficient when considering nested opaques.
This means that the
predicates_of
an anon const might reference duplicated lifetimes (installed bycompute_bidirectional_outlives_predicates
) when computing known outlives in MIR borrowck, leading to these ICEs:Fixes #121574
Fixes #118403
Instead, we should be using theOpaqueTypeOrigin
to acquire the owner item (fn/type alias/etc) of the opaque, whose predicates we're fine to mention.I think it's a bit sketchy that we're doing this at all, tbh; I think it should be fine for the anon const to inherit the predicates of the opaque it's located inside. However, that would also mean that we need to make sure thegenerics_of
that anon const line up in the same way.None of this is important to solve right now; I just want to fix these ICEs so we can land #125468, which accidentally fixes these issues in a different and unrelated way.edit: We don't need this special case anyways because we install the right parent item in
generics_of
anyways:rust/compiler/rustc_hir_analysis/src/collect/generics_of.rs
Line 150 in 213ad10
r? @BoxyUwU