Skip to content

Fix ICE when projecting DiscriminantKind through unsafe binders#158856

Open
lapla-cogito wants to merge 1 commit into
rust-lang:mainfrom
lapla-cogito:issue_158839
Open

Fix ICE when projecting DiscriminantKind through unsafe binders#158856
lapla-cogito wants to merge 1 commit into
rust-lang:mainfrom
lapla-cogito:issue_158839

Conversation

@lapla-cogito

@lapla-cogito lapla-cogito commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Ty::discriminant_ty already forwards through UnsafeBinder to the erased inner type (see 35693778e81). The old and new trait solvers still hit todo!s when assembling/normalizing <unsafe<> T as DiscriminantKind>::Discriminant.

Fixes #158839

@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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Jul 6, 2026
@rustbot

rustbot commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

r? @fee1-dead

rustbot has assigned @fee1-dead.
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 75 candidates
  • Random selection from 20 candidates

@rust-log-analyzer

This comment has been minimized.

ty::Coroutine(_, args) => args.as_coroutine().discr_ty(tcx),

ty::Param(_) | ty::Alias(..) | ty::Infer(ty::TyVar(_)) => {
ty::Param(_) | ty::Placeholder(_) | ty::Alias(..) | ty::Infer(ty::TyVar(_)) => {

@fee1-dead fee1-dead Jul 9, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm. Is this needed and correct? The UnsafeBinder arm below just instantiates with erased. Placeholders have discriminants question mark? cc @rust-lang/types

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.

Note that this is for the next solver. IIUC, placeholders don't have a known concrete discriminant type, so we return <!0 as DiscriminantKind>::Discriminant rather than inventing u8. Same pattern as other unknown types in this function.

@lcnr lcnr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we are instantiating the binder with erased regions here, which feels wrong in the trait solver 🤔

we probably want to instantiate them with placeholders?

It's also weird to me that discriminant_ty for unsafe binders doesn't just return instantiated_inner_ty::DiscriminantKind and instead recursively call discriminant_ty.

do we ever encounter the ty::Param(_) | ty::Alias(..) | ty::Infer(ty::TyVar(_)) branch of discriminant_ty outside of the trait solver? Because if so, I would prefer to change it to a panic and have both the old and new solver handle that branch manually.

View changes since this review

@rust-bors

rust-bors Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #159246) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

@fee1-dead fee1-dead 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 Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ICE]: discr subgoal

5 participants