]> git.lizzy.rs Git - rust.git/blob - src/librustc_codegen_utils/lib.rs
1f590d46ed8c657bb18b48b173ce8c2b06a75366
[rust.git] / src / librustc_codegen_utils / lib.rs
1 //! # Note
2 //!
3 //! This API is completely unstable and subject to change.
4
5 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
6       html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
7       html_root_url = "https://doc.rust-lang.org/nightly/")]
8
9 #![feature(box_patterns)]
10 #![feature(box_syntax)]
11 #![feature(custom_attribute)]
12 #![feature(nll)]
13 #![allow(unused_attributes)]
14 #![feature(rustc_diagnostic_macros)]
15
16 #![recursion_limit="256"]
17
18 extern crate flate2;
19 #[macro_use]
20 extern crate log;
21
22 #[macro_use]
23 extern crate rustc;
24 extern crate rustc_target;
25 extern crate rustc_metadata;
26 extern crate rustc_mir;
27 extern crate rustc_incremental;
28 extern crate syntax;
29 extern crate syntax_pos;
30 #[macro_use] extern crate rustc_data_structures;
31
32 use rustc::ty::TyCtxt;
33 use rustc::hir::def_id::LOCAL_CRATE;
34
35 pub mod link;
36 pub mod codegen_backend;
37 pub mod symbol_names;
38 pub mod symbol_names_test;
39
40 /// check for the #[rustc_error] annotation, which forces an
41 /// error in codegen. This is used to write compile-fail tests
42 /// that actually test that compilation succeeds without
43 /// reporting an error.
44 pub fn check_for_rustc_errors_attr(tcx: TyCtxt) {
45     if let Some((def_id, _)) = tcx.entry_fn(LOCAL_CRATE) {
46         if tcx.has_attr(def_id, "rustc_error") {
47             tcx.sess.span_fatal(tcx.def_span(def_id), "compilation successful");
48         }
49     }
50 }