]> git.lizzy.rs Git - rust.git/blob - src/librustc_trans_utils/lib.rs
Merge branch 'incr_attr_queries' of https://github.com/wesleywiser/rust into update...
[rust.git] / src / librustc_trans_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 #![deny(warnings)]
19
20 #![feature(box_patterns)]
21 #![feature(box_syntax)]
22 #![feature(custom_attribute)]
23 #![allow(unused_attributes)]
24 #![feature(i128_type)]
25 #![feature(quote)]
26 #![feature(rustc_diagnostic_macros)]
27 #![feature(slice_patterns)]
28 #![feature(conservative_impl_trait)]
29
30 extern crate ar;
31 extern crate flate2;
32 #[macro_use]
33 extern crate log;
34
35 #[macro_use]
36 extern crate rustc;
37 extern crate rustc_back;
38 extern crate rustc_mir;
39 extern crate rustc_incremental;
40 extern crate syntax;
41 extern crate syntax_pos;
42 #[macro_use] extern crate rustc_data_structures;
43
44 pub extern crate rustc as __rustc;
45
46 use rustc::ty::TyCtxt;
47
48 pub mod link;
49 pub mod trans_crate;
50 pub mod symbol_names;
51 pub mod symbol_names_test;
52
53 /// check for the #[rustc_error] annotation, which forces an
54 /// error in trans. This is used to write compile-fail tests
55 /// that actually test that compilation succeeds without
56 /// reporting an error.
57 pub fn check_for_rustc_errors_attr(tcx: TyCtxt) {
58     if let Some((id, span)) = *tcx.sess.entry_fn.borrow() {
59         let main_def_id = tcx.hir.local_def_id(id);
60
61         if tcx.has_attr(main_def_id, "rustc_error") {
62             tcx.sess.span_fatal(span, "compilation successful");
63         }
64     }
65 }
66
67 __build_diagnostic_array! { librustc_trans_utils, DIAGNOSTICS }