]> git.lizzy.rs Git - rust.git/blob - src/librustc/lib.rs
Auto merge of #45359 - arielb1:escaping-borrow, r=eddyb
[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 a deeper explanation of how the compiler works and is
32 //! organized, see the README.md file in this directory.
33 //!
34 //! # Note
35 //!
36 //! This API is completely unstable and subject to change.
37
38 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
39        html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
40        html_root_url = "https://doc.rust-lang.org/nightly/")]
41 #![deny(warnings)]
42
43 #![feature(box_patterns)]
44 #![feature(box_syntax)]
45 #![feature(conservative_impl_trait)]
46 #![feature(const_fn)]
47 #![feature(core_intrinsics)]
48 #![feature(i128_type)]
49 #![cfg_attr(windows, feature(libc))]
50 #![feature(never_type)]
51 #![feature(nonzero)]
52 #![feature(quote)]
53 #![feature(rustc_diagnostic_macros)]
54 #![feature(slice_patterns)]
55 #![feature(specialization)]
56 #![feature(unboxed_closures)]
57 #![feature(trace_macros)]
58 #![feature(test)]
59
60 #![cfg_attr(stage0, feature(const_fn))]
61 #![cfg_attr(not(stage0), feature(const_atomic_bool_new))]
62
63 #![recursion_limit="512"]
64
65 extern crate arena;
66 #[macro_use] extern crate bitflags;
67 extern crate core;
68 extern crate fmt_macros;
69 extern crate getopts;
70 extern crate graphviz;
71 #[cfg(windows)]
72 extern crate libc;
73 extern crate owning_ref;
74 extern crate rustc_back;
75 #[macro_use] extern crate rustc_data_structures;
76 extern crate serialize;
77 extern crate rustc_const_math;
78 extern crate rustc_errors as errors;
79 #[macro_use] extern crate log;
80 #[macro_use] extern crate syntax;
81 extern crate syntax_pos;
82 extern crate jobserver;
83
84 extern crate serialize as rustc_serialize; // used by deriving
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 // NB: 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 const_val;
112     pub mod cstore;
113     pub mod dataflow;
114     pub mod dead;
115     pub mod dependency_format;
116     pub mod entry;
117     pub mod exported_symbols;
118     pub mod free_region;
119     pub mod intrinsicck;
120     pub mod lang_items;
121     pub mod liveness;
122     pub mod mem_categorization;
123     pub mod privacy;
124     pub mod reachable;
125     pub mod region;
126     pub mod recursion_limit;
127     pub mod resolve_lifetime;
128     pub mod stability;
129     pub mod trans;
130     pub mod weak_lang_items;
131 }
132
133 pub mod mir;
134 pub mod session;
135 pub mod traits;
136 pub mod ty;
137
138 pub mod util {
139     pub mod common;
140     pub mod ppaux;
141     pub mod nodemap;
142     pub mod fs;
143 }
144
145 // A private module so that macro-expanded idents like
146 // `::rustc::lint::Lint` will also work in `rustc` itself.
147 //
148 // `libstd` uses the same trick.
149 #[doc(hidden)]
150 mod rustc {
151     pub use lint;
152 }
153
154 // FIXME(#27438): right now the unit tests of librustc don't refer to any actual
155 //                functions generated in librustc_data_structures (all
156 //                references are through generic functions), but statics are
157 //                referenced from time to time. Due to this bug we won't
158 //                actually correctly link in the statics unless we also
159 //                reference a function, so be sure to reference a dummy
160 //                function.
161 #[test]
162 fn noop() {
163     rustc_data_structures::__noop_fix_for_27438();
164 }
165
166
167 // Build the diagnostics array at the end so that the metadata includes error use sites.
168 __build_diagnostic_array! { librustc, DIAGNOSTICS }