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