rust-lang / rust-lang/rust

Robustify the `TyKind` ambig/unambig layout compatibility tests

Open
#135,944 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-enhancement T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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 https://github.com/rust-lang/rust/issues/135272#issuecomment-2610594323

#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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in compiler/rustc_hir/src/lib.rs by reading the existing layout compatibility test for hir::TyKind<()> and hir::TyKind<!>. Extend the test coverage for the ambig/unambig representations and verify that the compatibility checks still pass; the issue does not specify additional cases or a test command.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, testing-qa
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.