Skip to content

Conversation

@yaahc
Copy link
Member

@yaahc yaahc commented Dec 15, 2025

The second half of this boolean or expression should not be possible with the current visitation implementation.

Reasoning:

  • Innermost res will always be the first candidate visited.
  • the first scopes visited are derive_helper candidates, followed by a single step at derive_helper_compat: https://github.com/rust-lang/rust/blob/ee447067/compiler/rustc_resolve/src/ident.rs#L180-L192
    • if there are candidates for both kinds the derive_helper candidate will always be innermost
    • there can only be one derive_helper_compat candidate
  • The first branch handles cases where the first candidate is a derive_helper_compat
  • if the first candidate is not a derive_helper_compat (as enforced by the first branch) and it is not a derive_helper (as enforced by the end of the second boolean expression) then then the first candidate and all subsequent candidates must be from later scope types, res cannot possibly be a derive_helper_compat

r? @petrochenkov

@yaahc yaahc added the A-resolve Area: Name/path resolution done by `rustc_resolve` specifically label Dec 15, 2025
@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 Dec 15, 2025
@yaahc yaahc force-pushed the derive-helper-ambig-assert branch from 42ecd46 to 72c84a6 Compare December 15, 2025 19:11
@petrochenkov
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Dec 15, 2025

📌 Commit 72c84a6 has been approved by petrochenkov

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 Dec 15, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Dec 16, 2025
…r=petrochenkov

assert impossible branch is impossible

The second half of this boolean or expression should not be possible with the current visitation implementation.

Reasoning:

- Innermost res will always be the first candidate visited.
- the first scopes visited are `derive_helper` candidates, followed by a single step at `derive_helper_compat`: https://github.com/rust-lang/rust/blob/ee447067/compiler/rustc_resolve/src/ident.rs#L180-L192
  - if there are candidates for both kinds the derive_helper candidate will always be innermost
  - there can only be one derive_helper_compat candidate
- The first branch handles cases where the first candidate is a `derive_helper_compat`
- if the first candidate is not a `derive_helper_compat` (as enforced by the first branch) and it is not a `derive_helper` (as enforced by the end of the second boolean expression) then then the first candidate and all subsequent candidates must be from later scope types, res cannot possibly be a `derive_helper_compat`

r? `@petrochenkov`
bors added a commit that referenced this pull request Dec 16, 2025
Rollup of 14 pull requests

Successful merges:

 - #148756 (Warn on codegen attributes on required trait methods)
 - #148790 (Add new Tier-3 target: riscv64im-unknown-none-elf)
 - #149271 (feat: dlopen Enzyme)
 - #149459 (std: sys: fs: uefi: Implement set_times and set_perm)
 - #149771 (bootstrap readme: make easy to read when editor wrapping is not enabled)
 - #149856 (Provide an extended framework for type visit, for use in rust-analyzer)
 - #149950 (Simplify how inline asm handles `MaybeUninit`)
 - #150014 (Metadata loader cleanups)
 - #150021 (document that mpmc channels deliver an item to (at most) one receiver)
 - #150022 (Generate macro expansion for rust compiler crates docs)
 - #150029 (Update books)
 - #150031 (assert impossible branch is impossible)
 - #150034 (do not add `I-prioritize` when `F-*` labels are present)
 - #150036 (Use the embeddable filename for coverage artifacts)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Dec 16, 2025
Rollup of 13 pull requests

Successful merges:

 - #148756 (Warn on codegen attributes on required trait methods)
 - #148790 (Add new Tier-3 target: riscv64im-unknown-none-elf)
 - #149271 (feat: dlopen Enzyme)
 - #149459 (std: sys: fs: uefi: Implement set_times and set_perm)
 - #149771 (bootstrap readme: make easy to read when editor wrapping is not enabled)
 - #149856 (Provide an extended framework for type visit, for use in rust-analyzer)
 - #149950 (Simplify how inline asm handles `MaybeUninit`)
 - #150014 (Metadata loader cleanups)
 - #150021 (document that mpmc channels deliver an item to (at most) one receiver)
 - #150029 (Update books)
 - #150031 (assert impossible branch is impossible)
 - #150034 (do not add `I-prioritize` when `F-*` labels are present)
 - #150036 (Use the embeddable filename for coverage artifacts)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 06bc79b into rust-lang:main Dec 16, 2025
11 checks passed
@rustbot rustbot added this to the 1.94.0 milestone Dec 16, 2025
rust-timer added a commit that referenced this pull request Dec 16, 2025
Rollup merge of #150031 - yaahc:derive-helper-ambig-assert, r=petrochenkov

assert impossible branch is impossible

The second half of this boolean or expression should not be possible with the current visitation implementation.

Reasoning:

- Innermost res will always be the first candidate visited.
- the first scopes visited are `derive_helper` candidates, followed by a single step at `derive_helper_compat`: https://github.com/rust-lang/rust/blob/ee447067/compiler/rustc_resolve/src/ident.rs#L180-L192
  - if there are candidates for both kinds the derive_helper candidate will always be innermost
  - there can only be one derive_helper_compat candidate
- The first branch handles cases where the first candidate is a `derive_helper_compat`
- if the first candidate is not a `derive_helper_compat` (as enforced by the first branch) and it is not a `derive_helper` (as enforced by the end of the second boolean expression) then then the first candidate and all subsequent candidates must be from later scope types, res cannot possibly be a `derive_helper_compat`

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

Labels

A-resolve Area: Name/path resolution done by `rustc_resolve` specifically 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.

4 participants