3 //! This API is completely unstable and subject to change.
5 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
7 #![feature(arbitrary_self_types)]
8 #![feature(box_patterns)]
9 #![feature(box_syntax)]
10 #![feature(core_intrinsics)]
11 #![feature(never_type)]
13 #![feature(in_band_lifetimes)]
15 #![recursion_limit="256"]
20 use rustc::ty::TyCtxt;
21 use rustc::ty::query::Providers;
22 use rustc::hir::def_id::{LOCAL_CRATE, DefId};
23 use syntax::symbol::sym;
26 pub mod codegen_backend;
28 pub mod symbol_names_test;
31 pub fn trigger_delay_span_bug(tcx: TyCtxt<'_>, key: DefId) {
32 tcx.sess.delay_span_bug(tcx.def_span(key), "compilation successful");
35 /// check for the #[rustc_error] annotation, which forces an
36 /// error in codegen. This is used to write compile-fail tests
37 /// that actually test that compilation succeeds without
38 /// reporting an error.
39 pub fn check_for_rustc_errors_attr(tcx: TyCtxt<'_>) {
40 if let Some((def_id, _)) = tcx.entry_fn(LOCAL_CRATE) {
41 let attrs = &*tcx.get_attrs(def_id);
43 if attr.check_name(sym::rustc_error) {
44 match attr.meta_item_list() {
45 // check if there is a #[rustc_error(delayed)]
47 if list.iter().any(|list_item| {
48 list_item.ident().map(|i| i.name) ==
49 Some(sym::delay_span_bug_from_inside_query)
51 tcx.ensure().trigger_delay_span_bug(def_id);
54 // bare #[rustc_error]
56 tcx.sess.span_fatal(tcx.def_span(def_id), "compilation successful");
64 pub fn provide(providers: &mut Providers<'_>) {
65 crate::symbol_names::provide(providers);
66 *providers = Providers {
67 trigger_delay_span_bug,