]> git.lizzy.rs Git - rust.git/blob - src/librustc_codegen_utils/lib.rs
introduce Guard enum
[rust.git] / src / librustc_codegen_utils / lib.rs
1 // Copyright 2017 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 //! # Note
12 //!
13 //! This API is completely unstable and subject to change.
14
15 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
16       html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
17       html_root_url = "https://doc.rust-lang.org/nightly/")]
18
19 #![feature(box_patterns)]
20 #![feature(box_syntax)]
21 #![feature(custom_attribute)]
22 #![cfg_attr(not(stage0), feature(nll))]
23 #![allow(unused_attributes)]
24 #![feature(quote)]
25 #![feature(rustc_diagnostic_macros)]
26
27 #![recursion_limit="256"]
28
29 extern crate flate2;
30 #[macro_use]
31 extern crate log;
32
33 #[macro_use]
34 extern crate rustc;
35 extern crate rustc_target;
36 extern crate rustc_mir;
37 extern crate rustc_incremental;
38 extern crate syntax;
39 extern crate syntax_pos;
40 #[macro_use] extern crate rustc_data_structures;
41 extern crate rustc_metadata_utils;
42
43 use rustc::ty::TyCtxt;
44
45 pub mod link;
46 pub mod codegen_backend;
47 pub mod symbol_names;
48 pub mod symbol_names_test;
49
50 /// check for the #[rustc_error] annotation, which forces an
51 /// error in codegen. This is used to write compile-fail tests
52 /// that actually test that compilation succeeds without
53 /// reporting an error.
54 pub fn check_for_rustc_errors_attr(tcx: TyCtxt) {
55     if let Some((id, span, _)) = *tcx.sess.entry_fn.borrow() {
56         let main_def_id = tcx.hir.local_def_id(id);
57
58         if tcx.has_attr(main_def_id, "rustc_error") {
59             tcx.sess.span_fatal(span, "compilation successful");
60         }
61     }
62 }
63
64 __build_diagnostic_array! { librustc_codegen_utils, DIAGNOSTICS }