]> git.lizzy.rs Git - rust.git/blob - src/librustc_codegen_utils/lib.rs
Rollup merge of #58145 - taiki-e:poll, r=cramertj
[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 #![feature(in_band_lifetimes)]
16
17 #![recursion_limit="256"]
18
19 extern crate flate2;
20 #[macro_use]
21 extern crate log;
22
23 #[macro_use]
24 extern crate rustc;
25 extern crate rustc_target;
26 extern crate rustc_metadata;
27 extern crate rustc_mir;
28 extern crate rustc_incremental;
29 extern crate syntax;
30 extern crate syntax_pos;
31 #[macro_use] extern crate rustc_data_structures;
32
33 use rustc::ty::TyCtxt;
34 use rustc::hir::def_id::LOCAL_CRATE;
35
36 pub mod link;
37 pub mod codegen_backend;
38 pub mod symbol_names;
39 pub mod symbol_names_test;
40
41 /// check for the #[rustc_error] annotation, which forces an
42 /// error in codegen. This is used to write compile-fail tests
43 /// that actually test that compilation succeeds without
44 /// reporting an error.
45 pub fn check_for_rustc_errors_attr(tcx: TyCtxt) {
46     if let Some((def_id, _)) = tcx.entry_fn(LOCAL_CRATE) {
47         if tcx.has_attr(def_id, "rustc_error") {
48             tcx.sess.span_fatal(tcx.def_span(def_id), "compilation successful");
49         }
50     }
51 }