]> git.lizzy.rs Git - rust.git/blob - src/librustc/lib.rs
Auto merge of #61741 - Centril:rollup-fgro5kz, r=Centril
[rust.git] / src / librustc / 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". Some prominent examples (note that each of these modules
4 //! has their own README with further details).
5 //!
6 //! - **HIR.** The "high-level (H) intermediate representation (IR)" is
7 //!   defined in the `hir` module.
8 //! - **MIR.** The "mid-level (M) intermediate representation (IR)" is
9 //!   defined in the `mir` module. This module contains only the
10 //!   *definition* of the MIR; the passes that transform and operate
11 //!   on MIR are found in `librustc_mir` crate.
12 //! - **Types.** The internal representation of types used in rustc is
13 //!   defined in the `ty` module. This includes the **type context**
14 //!   (or `tcx`), which is the central context during most of
15 //!   compilation, containing the interners and other things.
16 //! - **Traits.** Trait resolution is implemented in the `traits` module.
17 //! - **Type inference.** The type inference code can be found in the `infer` module;
18 //!   this code handles low-level equality and subtyping operations. The
19 //!   type check pass in the compiler is found in the `librustc_typeck` crate.
20 //!
21 //! For more information about how rustc works, see the [rustc guide].
22 //!
23 //! [rustc guide]: https://rust-lang.github.io/rustc-guide/
24 //!
25 //! # Note
26 //!
27 //! This API is completely unstable and subject to change.
28
29 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
30
31 #![deny(rust_2018_idioms)]
32 #![deny(internal)]
33 #![deny(unused_lifetimes)]
34 #![allow(explicit_outlives_requirements)]
35
36 #![feature(arbitrary_self_types)]
37 #![feature(box_patterns)]
38 #![feature(box_syntax)]
39 #![feature(core_intrinsics)]
40 #![feature(drain_filter)]
41 #![feature(inner_deref)]
42 #![cfg_attr(windows, feature(libc))]
43 #![feature(never_type)]
44 #![feature(exhaustive_patterns)]
45 #![feature(overlapping_marker_traits)]
46 #![feature(extern_types)]
47 #![feature(nll)]
48 #![feature(non_exhaustive)]
49 #![feature(proc_macro_internals)]
50 #![feature(optin_builtin_traits)]
51 #![feature(range_is_empty)]
52 #![feature(rustc_diagnostic_macros)]
53 #![feature(rustc_attrs)]
54 #![feature(slice_patterns)]
55 #![feature(specialization)]
56 #![feature(unboxed_closures)]
57 #![feature(thread_local)]
58 #![feature(trace_macros)]
59 #![feature(trusted_len)]
60 #![feature(vec_remove_item)]
61 #![feature(step_trait)]
62 #![feature(stmt_expr_attributes)]
63 #![feature(integer_atomics)]
64 #![feature(test)]
65 #![feature(in_band_lifetimes)]
66 #![feature(crate_visibility_modifier)]
67 #![feature(proc_macro_hygiene)]
68 #![feature(log_syntax)]
69
70 #![recursion_limit="512"]
71
72 #[macro_use] extern crate bitflags;
73 extern crate getopts;
74 #[macro_use] extern crate lazy_static;
75 #[macro_use] extern crate scoped_tls;
76 #[cfg(windows)]
77 extern crate libc;
78 #[macro_use] extern crate rustc_macros;
79 #[macro_use] extern crate rustc_data_structures;
80
81 #[macro_use] extern crate log;
82 #[macro_use] extern crate syntax;
83
84 // FIXME: This import is used by deriving `RustcDecodable` and `RustcEncodable`. Removing this
85 // results in a bunch of "failed to resolve" errors. Hopefully, the compiler moves to serde or
86 // something, and we can get rid of this.
87 #[allow(rust_2018_idioms)]
88 extern crate serialize as rustc_serialize;
89
90 #[macro_use] extern crate smallvec;
91
92 // Note that librustc doesn't actually depend on these crates, see the note in
93 // `Cargo.toml` for this crate about why these are here.
94 #[allow(unused_extern_crates)]
95 extern crate flate2;
96 #[allow(unused_extern_crates)]
97 extern crate test;
98
99 #[macro_use]
100 mod macros;
101
102 // N.B., this module needs to be declared first so diagnostics are
103 // registered before they are used.
104 pub mod error_codes;
105
106 #[macro_use]
107 pub mod query;
108
109 #[macro_use]
110 pub mod arena;
111 pub mod cfg;
112 pub mod dep_graph;
113 pub mod hir;
114 pub mod ich;
115 pub mod infer;
116 pub mod lint;
117
118 pub mod middle {
119     pub mod allocator;
120     pub mod borrowck;
121     pub mod expr_use_visitor;
122     pub mod cstore;
123     pub mod dead;
124     pub mod dependency_format;
125     pub mod entry;
126     pub mod exported_symbols;
127     pub mod free_region;
128     pub mod intrinsicck;
129     pub mod lib_features;
130     pub mod lang_items;
131     pub mod liveness;
132     pub mod mem_categorization;
133     pub mod privacy;
134     pub mod reachable;
135     pub mod region;
136     pub mod recursion_limit;
137     pub mod resolve_lifetime;
138     pub mod stability;
139     pub mod weak_lang_items;
140 }
141
142 pub mod mir;
143 pub mod session;
144 pub mod traits;
145 pub mod ty;
146
147 pub mod util {
148     pub mod captures;
149     pub mod common;
150     pub mod nodemap;
151     pub mod profiling;
152     pub mod bug;
153 }
154
155 // Allows macros to refer to this crate as `::rustc`
156 extern crate self as rustc;
157
158 // FIXME(#27438): right now the unit tests of librustc don't refer to any actual
159 //                functions generated in librustc_data_structures (all
160 //                references are through generic functions), but statics are
161 //                referenced from time to time. Due to this bug we won't
162 //                actually correctly link in the statics unless we also
163 //                reference a function, so be sure to reference a dummy
164 //                function.
165 #[test]
166 fn noop() {
167     rustc_data_structures::__noop_fix_for_27438();
168 }
169
170
171 // Build the diagnostics array at the end so that the metadata includes error use sites.
172 __build_diagnostic_array! { librustc, DIAGNOSTICS }