From b5b015b49e0631dcde1ff85f31c471f28c8368b1 Mon Sep 17 00:00:00 2001 From: Simon Olofsson Date: Thu, 1 Oct 2026 16:14:30 +0200 Subject: [PATCH 1/3] thir.md: update example output --- src/thir.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/thir.md b/src/thir.md index 8b80d0be16..21ca10ef35 100644 --- a/src/thir.md +++ b/src/thir.md @@ -59,7 +59,7 @@ fn main() { } ``` -Here is how that gets represented in THIR (as of Jul 2026): +Here is how that gets represented in THIR (as of October 2026): ```rust,no_run DefId(0:3 ~ main[26fd]::main): @@ -67,7 +67,7 @@ Thir { body_type: Fn( fn(), ), - attributes: {}, + loop_hint_attrs: {}, // no match arms arms: [], blocks: [ From bcd1c46c36c7ad8b8418250a37d6cc309a6ecf84 Mon Sep 17 00:00:00 2001 From: Simon Olofsson Date: Thu, 1 Oct 2026 16:25:56 +0200 Subject: [PATCH 2/3] thir.md: update date-check, add tail call checking --- src/thir.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/thir.md b/src/thir.md index 21ca10ef35..8234bb0c8c 100644 --- a/src/thir.md +++ b/src/thir.md @@ -2,13 +2,15 @@ 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], [exhaustiveness checking], and [unsafety checking]. +[type checking]. It is (as of October 2026) used for +[MIR construction], [exhaustiveness checking], [unsafety checking], and +[explicit tail call checking]. [type checking]: ./hir-typeck/summary.md [MIR construction]: ./mir/construction.md [exhaustiveness checking]: ./pat-exhaustive-checking.md [unsafety checking]: ./unsafety-checking.md +[explicit tail call checking]: https://github.com/rust-lang/rust/issues/112788 As the name might suggest, the THIR is a lowered version of the [HIR] where all the types have been filled in, which is possible after type checking has completed. From 02a66e19dfb318dd11c94d5bfa0fddac3ae629f1 Mon Sep 17 00:00:00 2001 From: Simon Olofsson Date: Thu, 1 Oct 2026 16:45:17 +0200 Subject: [PATCH 3/3] thir.md: thir_body is a query --- src/thir.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/thir.md b/src/thir.md index 8234bb0c8c..63679b50ec 100644 --- a/src/thir.md +++ b/src/thir.md @@ -41,12 +41,9 @@ But it has some other interesting features that distinguish it from the HIR: [`ExprId`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/thir/struct.ExprId.html [body owners]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/enum.BodyOwnerKind.html -The THIR lives in [`rustc_mir_build::thir`][thir-docs]. -To construct a [`thir::Expr`], -you can use the [`thir_body`] function, passing in the memory arena where the THIR -will be allocated. -Dropping this arena will result in the THIR being destroyed, -which is useful to keep peak memory in check. +The THIR lives in [`rustc_middle::thir`][thir-docs]. +To construct a [`thir::Expr`], you can use the [`thir_body`] query. +The THIR is freed after unsafety checking, to keep peak memory in check. Having a THIR representation of all bodies of a crate in memory at the same time would be very heavy. @@ -226,6 +223,6 @@ Thir { } ``` -[thir-docs]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir_build/thir/index.html +[thir-docs]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/thir/index.html [`thir::Expr`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/thir/struct.Expr.html [`thir_body`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.thir_body