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