Skip to content

DiscriminantKind assembly is wrong for placeholders #14

Closed
rust-lang/rust
#109748
@compiler-errors

Description

@compiler-errors
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions