Skip to content
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

DiscriminantKind assembly is wrong for placeholders #14

Closed
compiler-errors opened this issue Mar 29, 2023 · 0 comments · Fixed by rust-lang/rust#109748
Closed

DiscriminantKind assembly is wrong for placeholders #14

compiler-errors opened this issue Mar 29, 2023 · 0 comments · Fixed by rust-lang/rust#109748
Labels
has-fix A fix is up

Comments

@compiler-errors
Copy link
Owner

fn foo<T>(x: T) {
    std::mem::discriminant(&x);
}

ICEs with:

error: internal compiler error: compiler/rustc_middle/src/ty/sty.rs:2256:17: `discriminant_ty` applied to unexpected type: Placeholder(Placeholder { universe: U0, name: Anon(0) })

We probably shouldn't be assembling a builtin discriminant candidate for placeholders at all -- that is, we shouldn't fix it by just assembling <!0t as DiscriminantKind>::Discriminant like the Ty::discriminant_ty impl is doing, but instead treat it as Err(NoSolution) to avoid ambiguity.

https://github.com/rust-lang/rust/blob/f98598c6cd34947efa9e3977338e9bce62d1997c/compiler/rustc_middle/src/ty/sty.rs#L2223

@compiler-errors compiler-errors added needs-fix An easy fix needs to be put up and applied has-fix A fix is up and removed needs-fix An easy fix needs to be put up and applied labels Mar 30, 2023
JohnTitor added a commit to JohnTitor/rust that referenced this issue Mar 30, 2023
…ind-ice, r=lcnr

Don't ICE on `DiscriminantKind` projection in new solver

As title says, since we now actually call `Ty::discriminant_kind` on placeholder types 😃

Also drive-by simplify `Pointee::Metadata` projection logic, and fix the UI test because the `<T as Pointee>::Metadata` tests weren't actually exercising the new projection logic, since we still eagerly normalize (which hits `project.rs` in the old solver) in HIR typeck.

r? `@lcnr` tho feel free to re-roll, this pr is very low-priority and not super specific to the new trait solver.

Fixes compiler-errors/next-solver-hir-issues#14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has-fix A fix is up
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant