Skip to content

Should we deeply normalize during writeback, or at the post-typeck places that need a "structurally resolved" type? #3

Closed
@compiler-errors

Description

@compiler-errors
fn foo(x: [u8; 4]) {
    match x[2] {
        b' ' | 0x9..=0xd8 => {
            panic!()
        }
        _ => {}
    }
}

This code currently ICEs with:

error: internal compiler error: broken MIR in DefId(0:3 ~ test[3886]::foo) (Le((*_2), const 216_u8)): unexpected comparison types <usize as std::slice::SliceIndex<[u8]>>::Output and u8
 --> /home/gh-compiler-errors/test.rs:3:16
  |
3 |         b' ' | 0x9..=0xd8 => {
  |                ^^^^^^^^^^
  |

This is because we expect for the types in the writeback results to have been normalized deeply, and other code (e.g. MIR build, MIR validation, late lints, reachability and dead code analysis) expect that Ty::kind calls "just work" without any further normalization.


We can either:

  1. Deeply normalize during writeback (e.g. compiler-errors/rust@b0600ae), or
  2. Normalize at every site that relies on a "structurally resolved" type mentioned above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions