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