]> git.lizzy.rs Git - rust.git/blob - src/librustc/lib.rs
Rollup merge of #54244 - kzys:search-box, r=GuillaumeGomez
[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(const_fn))]
46 #![cfg_attr(not(stage0), feature(min_const_fn))]
47 #![feature(core_intrinsics)]
48 #![feature(drain_filter)]
49 #![cfg_attr(windows, feature(libc))]
50 #![cfg_attr(stage0, feature(macro_vis_matcher))]
51 #![feature(never_type)]
52 #![feature(exhaustive_patterns)]
53 #![feature(extern_types)]
54 #![cfg_attr(not(stage0), feature(nll))]
55 #![feature(non_exhaustive)]
56 #![feature(proc_macro_internals)]
57 #![feature(quote)]
58 #![feature(optin_builtin_traits)]
59 #![feature(refcell_replace_swap)]
60 #![feature(rustc_diagnostic_macros)]
61 #![feature(rustc_attrs)]
62 #![cfg_attr(stage0, feature(attr_literals))]
63 #![feature(slice_patterns)]
64 #![feature(slice_sort_by_cached_key)]
65 #![feature(specialization)]
66 #![feature(unboxed_closures)]
67 #![feature(trace_macros)]
68 #![feature(trusted_len)]
69 #![feature(vec_remove_item)]
70 #![feature(step_trait)]
71 #![feature(integer_atomics)]
72 #![feature(test)]
73 #![cfg_attr(not(stage0), feature(impl_header_lifetime_elision))]
74 #![feature(in_band_lifetimes)]
75 #![feature(macro_at_most_once_rep)]
76 #![feature(crate_in_paths)]
77 #![feature(crate_visibility_modifier)]
78
79 #![recursion_limit="512"]
80
81 extern crate arena;
82 #[macro_use] extern crate bitflags;
83 extern crate core;
84 extern crate fmt_macros;
85 extern crate getopts;
86 extern crate graphviz;
87 #[macro_use] extern crate lazy_static;
88 #[macro_use] extern crate scoped_tls;
89 #[cfg(windows)]
90 extern crate libc;
91 extern crate polonius_engine;
92 extern crate rustc_target;
93 #[macro_use] extern crate rustc_data_structures;
94 extern crate serialize;
95 extern crate parking_lot;
96 extern crate rustc_errors as errors;
97 extern crate rustc_rayon as rayon;
98 extern crate rustc_rayon_core as rayon_core;
99 #[macro_use] extern crate log;
100 #[macro_use] extern crate syntax;
101 extern crate syntax_pos;
102 extern crate jobserver;
103 extern crate proc_macro;
104 extern crate chalk_engine;
105 extern crate rustc_fs_util;
106
107 extern crate serialize as rustc_serialize; // used by deriving
108
109 extern crate rustc_apfloat;
110 extern crate byteorder;
111 extern crate backtrace;
112
113 #[macro_use]
114 extern crate smallvec;
115
116 // Note that librustc doesn't actually depend on these crates, see the note in
117 // `Cargo.toml` for this crate about why these are here.
118 #[allow(unused_extern_crates)]
119 extern crate flate2;
120 #[allow(unused_extern_crates)]
121 extern crate test;
122
123 #[macro_use]
124 mod macros;
125
126 // NB: This module needs to be declared first so diagnostics are
127 // registered before they are used.
128 pub mod diagnostics;
129
130 pub mod cfg;
131 pub mod dep_graph;
132 pub mod hir;
133 pub mod ich;
134 pub mod infer;
135 pub mod lint;
136
137 pub mod middle {
138     pub mod allocator;
139     pub mod borrowck;
140     pub mod expr_use_visitor;
141     pub mod cstore;
142     pub mod dead;
143     pub mod dependency_format;
144     pub mod entry;
145     pub mod exported_symbols;
146     pub mod free_region;
147     pub mod intrinsicck;
148     pub mod lib_features;
149     pub mod lang_items;
150     pub mod liveness;
151     pub mod mem_categorization;
152     pub mod privacy;
153     pub mod reachable;
154     pub mod region;
155     pub mod recursion_limit;
156     pub mod resolve_lifetime;
157     pub mod stability;
158     pub mod weak_lang_items;
159 }
160
161 pub mod mir;
162 pub mod session;
163 pub mod traits;
164 pub mod ty;
165
166 pub mod util {
167     pub mod captures;
168     pub mod common;
169     pub mod ppaux;
170     pub mod nodemap;
171     pub mod time_graph;
172     pub mod profiling;
173     pub mod bug;
174 }
175
176 // A private module so that macro-expanded idents like
177 // `::rustc::lint::Lint` will also work in `rustc` itself.
178 //
179 // `libstd` uses the same trick.
180 #[doc(hidden)]
181 mod rustc {
182     pub use lint;
183 }
184
185 // FIXME(#27438): right now the unit tests of librustc don't refer to any actual
186 //                functions generated in librustc_data_structures (all
187 //                references are through generic functions), but statics are
188 //                referenced from time to time. Due to this bug we won't
189 //                actually correctly link in the statics unless we also
190 //                reference a function, so be sure to reference a dummy
191 //                function.
192 #[test]
193 fn noop() {
194     rustc_data_structures::__noop_fix_for_27438();
195 }
196
197
198 // Build the diagnostics array at the end so that the metadata includes error use sites.
199 __build_diagnostic_array! { librustc, DIAGNOSTICS }