]> git.lizzy.rs Git - rust.git/blob - src/librustc_codegen_utils/lib.rs
Simplify SaveHandler trait
[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_root_url = "https://doc.rust-lang.org/nightly/")]
6
7 #![feature(arbitrary_self_types)]
8 #![feature(box_patterns)]
9 #![feature(box_syntax)]
10 #![feature(core_intrinsics)]
11 #![feature(never_type)]
12 #![feature(nll)]
13 #![allow(unused_attributes)]
14 #![feature(rustc_diagnostic_macros)]
15 #![feature(in_band_lifetimes)]
16
17 #![recursion_limit="256"]
18
19 #![deny(rust_2018_idioms)]
20 #![deny(unused_lifetimes)]
21
22 #[macro_use]
23 extern crate rustc;
24
25 use rustc::ty::TyCtxt;
26 use rustc::hir::def_id::LOCAL_CRATE;
27 use syntax::symbol::sym;
28
29 pub mod link;
30 pub mod codegen_backend;
31 pub mod symbol_names;
32 pub mod symbol_names_test;
33
34 /// check for the #[rustc_error] annotation, which forces an
35 /// error in codegen. This is used to write compile-fail tests
36 /// that actually test that compilation succeeds without
37 /// reporting an error.
38 pub fn check_for_rustc_errors_attr(tcx: TyCtxt<'_>) {
39     if let Some((def_id, _)) = tcx.entry_fn(LOCAL_CRATE) {
40         if tcx.has_attr(def_id, sym::rustc_error) {
41             tcx.sess.span_fatal(tcx.def_span(def_id), "compilation successful");
42         }
43     }
44 }