]> git.lizzy.rs Git - rust.git/blob - src/librustc/lib.rs
Auto merge of #59987 - saleemjaffer:refactor_adjust_castkinds, r=oli-obk
[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 #![allow(explicit_outlives_requirements)]
34
35 #![feature(arbitrary_self_types)]
36 #![feature(box_patterns)]
37 #![feature(box_syntax)]
38 #![feature(core_intrinsics)]
39 #![feature(drain_filter)]
40 #![cfg_attr(windows, feature(libc))]
41 #![feature(never_type)]
42 #![feature(exhaustive_patterns)]
43 #![feature(overlapping_marker_traits)]
44 #![feature(extern_types)]
45 #![feature(nll)]
46 #![feature(non_exhaustive)]
47 #![feature(proc_macro_internals)]
48 #![feature(optin_builtin_traits)]
49 #![feature(range_is_empty)]
50 #![feature(rustc_diagnostic_macros)]
51 #![feature(rustc_attrs)]
52 #![feature(slice_patterns)]
53 #![feature(specialization)]
54 #![feature(unboxed_closures)]
55 #![feature(thread_local)]
56 #![feature(trace_macros)]
57 #![feature(trusted_len)]
58 #![feature(vec_remove_item)]
59 #![feature(step_trait)]
60 #![feature(stmt_expr_attributes)]
61 #![feature(integer_atomics)]
62 #![feature(test)]
63 #![feature(in_band_lifetimes)]
64 #![feature(crate_visibility_modifier)]
65 #![feature(proc_macro_hygiene)]
66 #![feature(log_syntax)]
67
68 #![recursion_limit="512"]
69
70 #[macro_use] extern crate bitflags;
71 extern crate getopts;
72 #[macro_use] extern crate lazy_static;
73 #[macro_use] extern crate scoped_tls;
74 #[cfg(windows)]
75 extern crate libc;
76 #[macro_use] extern crate rustc_macros;
77 #[macro_use] extern crate rustc_data_structures;
78
79 #[macro_use] extern crate log;
80 #[macro_use] extern crate syntax;
81
82 // FIXME: This import is used by deriving `RustcDecodable` and `RustcEncodable`. Removing this
83 // results in a bunch of "failed to resolve" errors. Hopefully, the compiler moves to serde or
84 // something, and we can get rid of this.
85 #[allow(rust_2018_idioms)]
86 extern crate serialize as rustc_serialize;
87
88 #[macro_use] extern crate smallvec;
89
90 // Note that librustc doesn't actually depend on these crates, see the note in
91 // `Cargo.toml` for this crate about why these are here.
92 #[allow(unused_extern_crates)]
93 extern crate flate2;
94 #[allow(unused_extern_crates)]
95 extern crate test;
96
97 #[macro_use]
98 mod macros;
99
100 // N.B., this module needs to be declared first so diagnostics are
101 // registered before they are used.
102 pub mod error_codes;
103
104 #[macro_use]
105 pub mod query;
106
107 #[macro_use]
108 pub mod arena;
109 pub mod cfg;
110 pub mod dep_graph;
111 pub mod hir;
112 pub mod ich;
113 pub mod infer;
114 pub mod lint;
115
116 pub mod middle {
117     pub mod allocator;
118     pub mod borrowck;
119     pub mod expr_use_visitor;
120     pub mod cstore;
121     pub mod dead;
122     pub mod dependency_format;
123     pub mod entry;
124     pub mod exported_symbols;
125     pub mod free_region;
126     pub mod intrinsicck;
127     pub mod lib_features;
128     pub mod lang_items;
129     pub mod liveness;
130     pub mod mem_categorization;
131     pub mod privacy;
132     pub mod reachable;
133     pub mod region;
134     pub mod recursion_limit;
135     pub mod resolve_lifetime;
136     pub mod stability;
137     pub mod weak_lang_items;
138 }
139
140 pub mod mir;
141 pub mod session;
142 pub mod traits;
143 pub mod ty;
144
145 pub mod util {
146     pub mod captures;
147     pub mod common;
148     pub mod nodemap;
149     pub mod profiling;
150     pub mod bug;
151 }
152
153 // Allows macros to refer to this crate as `::rustc`
154 extern crate self as rustc;
155
156 // FIXME(#27438): right now the unit tests of librustc don't refer to any actual
157 //                functions generated in librustc_data_structures (all
158 //                references are through generic functions), but statics are
159 //                referenced from time to time. Due to this bug we won't
160 //                actually correctly link in the statics unless we also
161 //                reference a function, so be sure to reference a dummy
162 //                function.
163 #[test]
164 fn noop() {
165     rustc_data_structures::__noop_fix_for_27438();
166 }
167
168
169 // Build the diagnostics array at the end so that the metadata includes error use sites.
170 __build_diagnostic_array! { librustc, DIAGNOSTICS }