I think we probably should track some follow-up work with fleshing out the type layout test to make sure we don't accidentally start fucking up the transmute between Unambig = () and Unambig = !, though I also expect that that would end up causing segfaults in the compiler immediately. I'll file something for that.
Originally posted by @compiler-errors in #135272 (comment)
#135272 introduced a very interesting trick where we transmute between two variants of hir::TyKind<U> -- namely hir::TyKind<()> and hir::TyKind<!> -- to represent the presence or not of a variant of TyKind::Infer which is superseded in certain contexts by a more general infer kind that is shared between consts and types.
As of that PR landing, there's a test (compiler/rustc_hir/src/lib.rs) that exercises the layout compatibility between these TyKinds, but it could be fleshed out some more.
Originally posted by @compiler-errors in #135272 (comment)
#135272 introduced a very interesting trick where we transmute between two variants of
hir::TyKind<U>-- namelyhir::TyKind<()>andhir::TyKind<!>-- to represent the presence or not of a variant ofTyKind::Inferwhich is superseded in certain contexts by a more general infer kind that is shared between consts and types.As of that PR landing, there's a test (
compiler/rustc_hir/src/lib.rs) that exercises the layout compatibility between theseTyKinds, but it could be fleshed out some more.