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