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