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(assert_matches))]
31#![cfg_attr(doc, feature(intra_doc_pointers))]
32#![feature(allocator_api)]
33#![feature(associated_type_defaults)]
34#![feature(box_as_ptr)]
35#![feature(box_patterns)]
36#![feature(closure_track_caller)]
37#![feature(const_default)]
38#![feature(const_trait_impl)]
39#![feature(core_intrinsics)]
40#![feature(debug_closure_helpers)]
41#![feature(decl_macro)]
42#![feature(discriminant_kind)]
43#![feature(extern_types)]
44#![feature(file_buffered)]
45#![feature(gen_blocks)]
46#![feature(if_let_guard)]
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(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(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;
84pub mod verify_ich;
85
86#[macro_use]
87pub mod query;
88#[macro_use]
89pub mod queries;
90#[macro_use]
91pub mod dep_graph;
92
93// Allows macros to refer to this crate as `::rustc_middle`
94extern crate self as rustc_middle;