Mehdi Akiki

Posts tagged "compilers"

  • Published on

    Investigation · Part 2 of 10 · Types under the hood

    Does a Type Exist at Runtime? Following One Value From Source to Register

    I followed one u8 through the four stages of the Rust compiler: HIR, MIR, LLVM IR, and assembly. The type is a word, then a field, then a width, then nothing. The u8 and u32 versions of the same function compile to the same two instructions, and the one check a type does produce is the debug overflow guard.
  • Published on

    Article · Through the layers

    DefId vs HirId in the Rust Compiler

    Two identifiers, two different jobs. DefId names a definition across the whole compiler pipeline and across crates. HirId points to a node in the syntax tree of the current crate. Mixing them up is the first stumbling block when reading rustc source code.