Technical Notes & Knowledge Base

The path these notes are about is withdrawn. Nothing in the toolchain links rustc_private or builds a rustc_ast::Crate any more: a .nika file becomes Rust source text and rustc compiles it like any other Rust (ADR-004 D1). This page is kept as the notebook page it is — these were real findings about a real compiler, and a notebook is not edited when the experiment ends. ../CHANGELOG.md and withdrawn-one-way-down.md say what happened.

Rust Compiler Internals (Nightly 2026-01-01)

Integration with rustc_private revealed specific details about the internal AST structure which differs from older versions.

1. Structure of rustc_ast::Item

The Item struct does not store the identifier directly.

pub struct Item<K = ItemKind> {
    pub attrs: AttrVec,
    pub id: NodeId,
    pub span: Span,
    pub vis: Visibility,
    pub kind: K, // Identifier is stored inside specific K variants (e.g. Fn)
    pub tokens: Option<LazyAttrTokenStream>,
}

2. Structure of rustc_ast::Fn

The Fn struct does store the identifier.

pub struct Fn {
    pub defaultness: Defaultness,
    pub ident: Ident, // <--- Name is here
    pub generics: Generics,
    pub sig: FnSig,
    // ...
}

3. Smart Pointers

4. Literals (Lit)

5. Macro Arguments

6. Linkage Issues

This site is open source. Improve this page.