]> git.lizzy.rs Git - rust.git/blob - src/librustc/lib.rs
Specify output filenames for compatibility with Windows
[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(copy_closures, clone_closures)]
48 #![feature(core_intrinsics)]
49 #![feature(drain_filter)]
50 #![feature(dyn_trait)]
51 #![feature(from_ref)]
52 #![feature(fs_read_write)]
53 #![feature(i128)]
54 #![feature(i128_type)]
55 #![feature(inclusive_range)]
56 #![feature(inclusive_range_syntax)]
57 #![cfg_attr(windows, feature(libc))]
58 #![feature(macro_vis_matcher)]
59 #![feature(match_default_bindings)]
60 #![feature(never_type)]
61 #![feature(nonzero)]
62 #![feature(quote)]
63 #![feature(refcell_replace_swap)]
64 #![feature(rustc_diagnostic_macros)]
65 #![feature(slice_patterns)]
66 #![feature(specialization)]
67 #![feature(unboxed_closures)]
68 #![feature(underscore_lifetimes)]
69 #![feature(trace_macros)]
70 #![feature(catch_expr)]
71 #![feature(test)]
72
73 #![recursion_limit="512"]
74
75 extern crate arena;
76 #[macro_use] extern crate bitflags;
77 extern crate core;
78 extern crate fmt_macros;
79 extern crate getopts;
80 extern crate graphviz;
81 #[cfg(windows)]
82 extern crate libc;
83 extern crate rustc_back;
84 #[macro_use] extern crate rustc_data_structures;
85 extern crate serialize;
86 extern crate rustc_const_math;
87 extern crate rustc_errors as errors;
88 #[macro_use] extern crate log;
89 #[macro_use] extern crate syntax;
90 extern crate syntax_pos;
91 extern crate jobserver;
92
93 extern crate serialize as rustc_serialize; // used by deriving
94
95 extern crate rustc_apfloat;
96 extern crate byteorder;
97 extern crate backtrace;
98
99 // Note that librustc doesn't actually depend on these crates, see the note in
100 // `Cargo.toml` for this crate about why these are here.
101 #[allow(unused_extern_crates)]
102 extern crate flate2;
103 #[allow(unused_extern_crates)]
104 extern crate test;
105
106 #[macro_use]
107 mod macros;
108
109 // NB: This module needs to be declared first so diagnostics are
110 // registered before they are used.
111 pub mod diagnostics;
112
113 pub mod cfg;
114 pub mod dep_graph;
115 pub mod hir;
116 pub mod ich;
117 pub mod infer;
118 pub mod lint;
119
120 pub mod middle {
121     pub mod allocator;
122     pub mod borrowck;
123     pub mod expr_use_visitor;
124     pub mod const_val;
125     pub mod cstore;
126     pub mod dataflow;
127     pub mod dead;
128     pub mod dependency_format;
129     pub mod entry;
130     pub mod exported_symbols;
131     pub mod free_region;
132     pub mod intrinsicck;
133     pub mod lang_items;
134     pub mod liveness;
135     pub mod mem_categorization;
136     pub mod privacy;
137     pub mod reachable;
138     pub mod region;
139     pub mod recursion_limit;
140     pub mod resolve_lifetime;
141     pub mod stability;
142     pub mod weak_lang_items;
143 }
144
145 pub mod mir;
146 pub mod session;
147 pub mod traits;
148 pub mod ty;
149
150 pub mod util {
151     pub mod common;
152     pub mod ppaux;
153     pub mod nodemap;
154     pub mod fs;
155 }
156
157 // A private module so that macro-expanded idents like
158 // `::rustc::lint::Lint` will also work in `rustc` itself.
159 //
160 // `libstd` uses the same trick.
161 #[doc(hidden)]
162 mod rustc {
163     pub use lint;
164 }
165
166 // FIXME(#27438): right now the unit tests of librustc don't refer to any actual
167 //                functions generated in librustc_data_structures (all
168 //                references are through generic functions), but statics are
169 //                referenced from time to time. Due to this bug we won't
170 //                actually correctly link in the statics unless we also
171 //                reference a function, so be sure to reference a dummy
172 //                function.
173 #[test]
174 fn noop() {
175     rustc_data_structures::__noop_fix_for_27438();
176 }
177
178
179 // Build the diagnostics array at the end so that the metadata includes error use sites.
180 #[cfg(not(stage0))] // remove after the next snapshot
181 __build_diagnostic_array! { librustc, DIAGNOSTICS }