]> git.lizzy.rs Git - rust.git/blob - src/librustc/lib.rs
d8defabd3fe6616f90802efe8d956f438952c158
[rust.git] / src / librustc / lib.rs
1 // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 //! The "main crate" of the Rust compiler. This crate contains common
12 //! type definitions that are used by the other crates in the rustc
13 //! "family". Some prominent examples (note that each of these modules
14 //! has their own README with further details).
15 //!
16 //! - **HIR.** The "high-level (H) intermediate representation (IR)" is
17 //!   defined in the `hir` module.
18 //! - **MIR.** The "mid-level (M) intermediate representation (IR)" is
19 //!   defined in the `mir` module. This module contains only the
20 //!   *definition* of the MIR; the passes that transform and operate
21 //!   on MIR are found in `librustc_mir` crate.
22 //! - **Types.** The internal representation of types used in rustc is
23 //!   defined in the `ty` module. This includes the **type context**
24 //!   (or `tcx`), which is the central context during most of
25 //!   compilation, containing the interners and other things.
26 //! - **Traits.** Trait resolution is implemented in the `traits` module.
27 //! - **Type inference.** The type inference code can be found in the `infer` module;
28 //!   this code handles low-level equality and subtyping operations. The
29 //!   type check pass in the compiler is found in the `librustc_typeck` crate.
30 //!
31 //! For more information about how rustc works, see the [rustc guide].
32 //!
33 //! [rustc guide]: https://rust-lang-nursery.github.io/rustc-guide/
34 //!
35 //! # Note
36 //!
37 //! This API is completely unstable and subject to change.
38
39 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
40        html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
41        html_root_url = "https://doc.rust-lang.org/nightly/")]
42
43 #![feature(box_patterns)]
44 #![feature(box_syntax)]
45 #![cfg_attr(stage0, feature(min_const_fn))]
46 #![feature(core_intrinsics)]
47 #![feature(drain_filter)]
48 #![cfg_attr(windows, feature(libc))]
49 #![feature(never_type)]
50 #![feature(exhaustive_patterns)]
51 #![feature(extern_types)]
52 #![feature(nll)]
53 #![feature(non_exhaustive)]
54 #![feature(proc_macro_internals)]
55 #![feature(quote)]
56 #![feature(optin_builtin_traits)]
57 #![feature(refcell_replace_swap)]
58 #![feature(rustc_diagnostic_macros)]
59 #![feature(rustc_attrs)]
60 #![feature(slice_patterns)]
61 #![feature(slice_sort_by_cached_key)]
62 #![feature(specialization)]
63 #![feature(unboxed_closures)]
64 #![feature(trace_macros)]
65 #![feature(trusted_len)]
66 #![feature(vec_remove_item)]
67 #![feature(step_trait)]
68 #![feature(integer_atomics)]
69 #![feature(test)]
70 #![cfg_attr(stage0, feature(impl_header_lifetime_elision))]
71 #![feature(in_band_lifetimes)]
72 #![feature(macro_at_most_once_rep)]
73 #![feature(crate_visibility_modifier)]
74 #![feature(transpose_result)]
75
76 #![recursion_limit="512"]
77
78 #![warn(elided_lifetimes_in_paths)]
79
80 extern crate arena;
81 #[macro_use] extern crate bitflags;
82 extern crate core;
83 extern crate fmt_macros;
84 extern crate getopts;
85 extern crate graphviz;
86 #[macro_use] extern crate lazy_static;
87 #[macro_use] extern crate scoped_tls;
88 #[cfg(windows)]
89 extern crate libc;
90 extern crate polonius_engine;
91 extern crate rustc_target;
92 #[macro_use] extern crate rustc_data_structures;
93 extern crate serialize;
94 extern crate parking_lot;
95 extern crate rustc_errors as errors;
96 extern crate rustc_rayon as rayon;
97 extern crate rustc_rayon_core as rayon_core;
98 #[macro_use] extern crate log;
99 #[macro_use] extern crate syntax;
100 extern crate syntax_pos;
101 extern crate jobserver;
102 extern crate proc_macro;
103 extern crate chalk_engine;
104 extern crate rustc_fs_util;
105
106 extern crate serialize as rustc_serialize; // used by deriving
107
108 extern crate rustc_apfloat;
109 extern crate byteorder;
110 extern crate backtrace;
111
112 #[macro_use]
113 extern crate smallvec;
114
115 // Note that librustc doesn't actually depend on these crates, see the note in
116 // `Cargo.toml` for this crate about why these are here.
117 #[allow(unused_extern_crates)]
118 extern crate flate2;
119 #[allow(unused_extern_crates)]
120 extern crate test;
121
122 #[macro_use]
123 mod macros;
124
125 // NB: This module needs to be declared first so diagnostics are
126 // registered before they are used.
127 pub mod diagnostics;
128
129 pub mod cfg;
130 pub mod dep_graph;
131 pub mod hir;
132 pub mod ich;
133 pub mod infer;
134 pub mod lint;
135
136 pub mod middle {
137     pub mod allocator;
138     pub mod borrowck;
139     pub mod expr_use_visitor;
140     pub mod cstore;
141     pub mod dead;
142     pub mod dependency_format;
143     pub mod entry;
144     pub mod exported_symbols;
145     pub mod free_region;
146     pub mod intrinsicck;
147     pub mod lib_features;
148     pub mod lang_items;
149     pub mod liveness;
150     pub mod mem_categorization;
151     pub mod privacy;
152     pub mod reachable;
153     pub mod region;
154     pub mod recursion_limit;
155     pub mod resolve_lifetime;
156     pub mod stability;
157     pub mod weak_lang_items;
158 }
159
160 pub mod mir;
161 pub mod session;
162 pub mod traits;
163 pub mod ty;
164
165 pub mod util {
166     pub mod captures;
167     pub mod common;
168     pub mod ppaux;
169     pub mod nodemap;
170     pub mod time_graph;
171     pub mod profiling;
172     pub mod bug;
173 }
174
175 // A private module so that macro-expanded idents like
176 // `::rustc::lint::Lint` will also work in `rustc` itself.
177 //
178 // `libstd` uses the same trick.
179 #[doc(hidden)]
180 mod rustc {
181     pub use lint;
182 }
183
184 // FIXME(#27438): right now the unit tests of librustc don't refer to any actual
185 //                functions generated in librustc_data_structures (all
186 //                references are through generic functions), but statics are
187 //                referenced from time to time. Due to this bug we won't
188 //                actually correctly link in the statics unless we also
189 //                reference a function, so be sure to reference a dummy
190 //                function.
191 #[test]
192 fn noop() {
193     rustc_data_structures::__noop_fix_for_27438();
194 }
195
196
197 // Build the diagnostics array at the end so that the metadata includes error use sites.
198 __build_diagnostic_array! { librustc, DIAGNOSTICS }