Skip to main content

rustc_middle/
lib.rs

1//! The "main crate" of the Rust compiler. This crate contains common
2//! type definitions that are used by the other crates in the rustc
3//! "family". The following are some prominent examples.
4//!
5//! - **HIR.** The "high-level (H) intermediate representation (IR)" is
6//!   defined in the [`hir`] module.
7//! - **THIR.** The "typed high-level (H) intermediate representation (IR)"
8//!   is defined in the [`thir`] module.
9//! - **MIR.** The "mid-level (M) intermediate representation (IR)" is
10//!   defined in the [`mir`] module. This module contains only the
11//!   *definition* of the MIR; the passes that transform and operate
12//!   on MIR are found in `rustc_const_eval` crate.
13//! - **Types.** The internal representation of types used in rustc is
14//!   defined in the [`ty`] module. This includes the
15//!   [**type context**][ty::TyCtxt] (or `tcx`), which is the central
16//!   context during most of compilation, containing the interners and
17//!   other things.
18//!
19//! For more information about how rustc works, see the [rustc dev guide].
20//!
21//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/
22//!
23//! # Note
24//!
25//! This API is completely unstable and subject to change.
26
27// tidy-alphabetical-start
28#![allow(internal_features)]
29#![allow(rustc::direct_use_of_rustc_type_ir)]
30#![cfg_attr(bootstrap, feature(allocator_api))]
31#![cfg_attr(bootstrap, feature(never_type))]
32#![cfg_attr(doc, feature(intra_doc_pointers))]
33#![cfg_attr(not(bootstrap), feature(allocator_ext))]
34#![feature(associated_type_defaults)]
35#![feature(closure_track_caller)]
36#![feature(const_default)]
37#![feature(const_trait_impl)]
38#![feature(core_intrinsics)]
39#![feature(debug_closure_helpers)]
40#![feature(decl_macro)]
41#![feature(default_field_values)]
42#![feature(deref_patterns)]
43#![feature(discriminant_kind)]
44#![feature(extern_types)]
45#![feature(file_buffered)]
46#![feature(gen_blocks)]
47#![feature(min_specialization)]
48#![feature(negative_impls)]
49#![feature(option_into_flat_iter)]
50#![feature(ptr_alignment_type)]
51#![feature(range_bounds_is_empty)]
52#![feature(rustc_attrs)]
53#![feature(sized_hierarchy)]
54#![feature(trait_alias)]
55#![feature(try_blocks)]
56#![feature(try_trait_v2)]
57#![feature(try_trait_v2_residual)]
58#![feature(try_trait_v2_yeet)]
59#![feature(type_alias_impl_trait)]
60#![feature(variant_count)]
61#![feature(yeet_expr)]
62#![recursion_limit = "256"]
63// tidy-alphabetical-end
64
65#[cfg(test)]
66mod tests;
67
68#[macro_use]
69mod macros;
70
71#[macro_use]
72pub mod arena;
73
74pub mod dep_graph;
75pub mod diagnostics;
76pub mod hir;
77pub mod hooks;
78pub mod ich;
79pub mod infer;
80pub mod lint;
81pub mod middle;
82pub mod mir;
83pub mod mono;
84pub mod ptrauth;
85pub mod queries;
86pub mod query;
87pub mod thir;
88pub mod traits;
89pub mod ty;
90pub mod util;
91pub mod verify_ich;
92
93// Allows macros to refer to this crate as `::rustc_middle`
94extern crate self as rustc_middle;