Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
Lexing and parsing The very first thing the compiler does is take the program (in UTF-8 Unicode text) and turn it into a data format the compiler can work with more conveniently than strings. This happens in two stages: Lexing and Parsing....
rustc-dev-guide.rust-lang.org Guide to Rustc Development Book 2024-01-01 ~2 min read
Macro expansion Rust has a very powerful macro system. In the previous chapter, we saw how the parser sets aside macros to be expanded (using temporary placeholders). This chapter is about the process of expanding those macros iteratively u...
rustc-dev-guide.rust-lang.org Guide to Rustc Development Book 2024-01-01 ~16 min read
Name resolution In the previous chapters, we saw how the Abstract Syntax Tree (AST) is built with all macros expanded. We saw how doing that requires doing some name resolution to resolve imports and macro names. In this chapter, we show ho...
rustc-dev-guide.rust-lang.org Guide to Rustc Development Book 2024-01-01 ~6 min read
Attributes Attributes come in two types: inert (or built-in) and active (non-builtin). Builtin/inert attributes These attributes are defined in the compiler itself, in compiler/rustc_feature/src/builtin_attrs.rs and in the attribute parsers...
rustc-dev-guide.rust-lang.org Guide to Rustc Development Book 2024-01-01 ~1 min read
The #[test] attribute Many Rust programmers rely on a built-in attribute called #[test]. All you have to do is mark a function and include some asserts like so: #[test] fn my_test() { assert!(2+2 == 4); } When this program is compiled using...
rustc-dev-guide.rust-lang.org Guide to Rustc Development Book 2024-01-01 ~3 min read
Panicking in Rust Step 1: Invocation of the panic! macro. There are actually two panic macros - one defined in core, and one defined in std. This is due to the fact that code in core can panic. core is built before std, but we want panics t...
rustc-dev-guide.rust-lang.org Guide to Rustc Development Book 2024-01-01 ~3 min read
AST validation AST validation is a separate AST pass that visits each item in the tree and performs simple checks. This pass doesn't perform any complex analysis, type checking or name resolution. Before performing any validation, the compi...
rustc-dev-guide.rust-lang.org Guide to Rustc Development Book 2024-01-01 ~1 min read
Feature Gate Checking For the how-to steps to add, remove, rename, or stabilize feature gates, see Feature gates. Feature gates prevent usage of unstable language and library features without a nightly-only #![feature(...)] opt-in. This cha...
rustc-dev-guide.rust-lang.org Guide to Rustc Development Book 2024-01-01 ~3 min read
Lang items The compiler has certain pluggable operations; that is, functionality that isn't hard-coded into the language, but is implemented in libraries, with a special marker to tell the compiler it exists. The marker is the attribute #[l...
rustc-dev-guide.rust-lang.org Guide to Rustc Development Book 2024-01-01 ~2 min read
The HIR The HIR – "High-Level Intermediate Representation" – is the primary IR used in most of rustc. It is a compiler-friendly representation of the abstract syntax tree (AST) that is generated after parsing, macro expansion, and name reso...
rustc-dev-guide.rust-lang.org Guide to Rustc Development Book 2024-01-01 ~4 min read
AST lowering The AST lowering step converts AST to HIR. This means many structures are removed if they are irrelevant for type analysis or similar syntax-agnostic analyses. Examples of such structures include but are not limited to • Parent...
rustc-dev-guide.rust-lang.org Guide to Rustc Development Book 2024-01-01 ~2 min read
Attribute Parsing Attributes come in two types: inert (or built-in) and active (non-builtin). Inert attributes are parsed during AST lowering to the HIR, while active attributes are expanded during expansion. For more information about the...
rustc-dev-guide.rust-lang.org Guide to Rustc Development Book 2024-01-01 ~4 min read
HIR Debugging Use the -Z unpretty=hir flag to produce a human-readable representation of the HIR. For cargo projects this can be done with cargo rustc -- -Z unpretty=hir. This output is useful when you need to see at a glance how your code...
rustc-dev-guide.rust-lang.org Guide to Rustc Development Book 2024-01-01 ~1 min read
Ambig/Unambig Types and Consts Types and Consts args in the AST/HIR can be in two kinds of positions ambiguous (ambig) or unambiguous (unambig). Ambig positions are where it would be valid to parse either a type or a const, unambig position...
rustc-dev-guide.rust-lang.org Guide to Rustc Development Book 2024-01-01 ~4 min read
The THIR The THIR ("Typed High-Level Intermediate Representation"), previously called HAIR for "High-Level Abstract IR", is another IR used by rustc that is generated after type checking. It is (as of January 2024) used for MIR construction...
rustc-dev-guide.rust-lang.org Guide to Rustc Development Book 2024-01-01 ~4 min read
The MIR (Mid-level IR) MIR is Rust's Mid-level Intermediate Representation. It is constructed from HIR. MIR was introduced in RFC 1211. It is a radically simplified form of Rust that is used for certain flow-sensitive safety checks – notabl...
rustc-dev-guide.rust-lang.org Guide to Rustc Development Book 2024-01-01 ~10 min read
MIR construction The lowering of HIR to MIR occurs for the following (probably incomplete) list of items: • Function and closure bodies • Initializers of static and const items • Initializers of enum discriminants • Glue and shims of any ki...
rustc-dev-guide.rust-lang.org Guide to Rustc Development Book 2024-01-01 ~4 min read
MIR visitor The MIR visitor is a convenient tool for traversing the MIR and either looking for things or making changes to it. The visitor traits are defined in the rustc_middle::mir::visit module – there are two of them, generated via a si...
rustc-dev-guide.rust-lang.org Guide to Rustc Development Book 2024-01-01 ~1 min read
MIR queries and passes If you would like to get the MIR: • for a function - you can use the optimized_mir query (typically used by codegen) or the mir_for_ctfe query (typically used by compile time function evaluation, i.e., CTFE); • for a...
rustc-dev-guide.rust-lang.org Guide to Rustc Development Book 2024-01-01 ~5 min read
Inline assembly Overview Inline assembly in rustc mostly revolves around taking an asm! macro invocation and plumbing it through all of the compiler layers down to LLVM codegen. Throughout the various stages, an InlineAsm generally consists...
rustc-dev-guide.rust-lang.org Guide to Rustc Development Book 2024-01-01 ~5 min read
"At last, I can name my unsafe functions appropriately. `unsafe fn e͙̤͎̪͒x̲͓̞̤͍̻̺̂͗͛͆͡t̜̣͊̓ͩ̍̑e̩͖͙͎̼̖͉ͮṇ̨͖̎̓ͅdͫ..."

Search tips

Type anything to search across articles, videos (including conference talks), podcasts, and research. These operators give you finer control — click an example to try it.

Find pages containing all your words. Pages where the words appear together rank higher.
Quote part of your query to keep those words together as an exact phrase within a larger search.
Wrap the whole query in quotes for a verbatim search that matches text exactly, punctuation and all — perfect for Rust syntax. Needs at least 3 characters.
Limit results to a single site. Works on its own () too. One site: per search.

Use the tabs and filters above the results to narrow by content type, publication year, and sort order.