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#![feature(allocator_api)]
31#![feature(assert_matches)]
32#![feature(associated_type_defaults)]
33#![feature(box_as_ptr)]
34#![feature(box_patterns)]
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(discriminant_kind)]
42#![feature(extern_types)]
43#![feature(file_buffered)]
44#![feature(gen_blocks)]
45#![feature(if_let_guard)]
46#![feature(intra_doc_pointers)]
47#![feature(min_specialization)]
48#![feature(negative_impls)]
49#![feature(never_type)]
50#![feature(ptr_alignment_type)]
51#![feature(range_bounds_is_empty)]
52#![feature(rustc_attrs)]
53#![feature(sized_hierarchy)]
54#![feature(try_blocks)]
55#![feature(try_trait_v2)]
56#![feature(try_trait_v2_residual)]
57#![feature(try_trait_v2_yeet)]
58#![feature(type_alias_impl_trait)]
59#![feature(unwrap_infallible)]
60#![feature(yeet_expr)]
61#![recursion_limit = "256"]
62// tidy-alphabetical-end
63
64#[cfg(test)]
65mod tests;
66
67#[macro_use]
68mod macros;
69
70#[macro_use]
71pub mod arena;
72pub mod error;
73pub mod hir;
74pub mod hooks;
75pub mod infer;
76pub mod lint;
77pub mod metadata;
78pub mod middle;
79pub mod mir;
80pub mod thir;
81pub mod traits;
82pub mod ty;
83pub mod util;
84
85#[macro_use]
86pub mod query;
87#[macro_use]
88pub mod queries;
89#[macro_use]
90pub mod dep_graph;
91
92// Allows macros to refer to this crate as `::rustc_middle`
93extern crate self as rustc_middle;