3 //! This API is completely unstable and subject to change.
5 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
6 #![feature(never_type)]
8 #![feature(in_band_lifetimes)]
9 #![recursion_limit = "256"]
14 use rustc::ty::query::Providers;
15 use rustc::ty::TyCtxt;
16 use rustc_hir::def_id::{DefId, LOCAL_CRATE};
17 use rustc_span::symbol::sym;
19 pub mod codegen_backend;
22 pub mod symbol_names_test;
24 pub fn trigger_delay_span_bug(tcx: TyCtxt<'_>, key: DefId) {
25 tcx.sess.delay_span_bug(
27 "delayed span bug triggered by #[rustc_error(delay_span_bug_from_inside_query)]",
31 /// check for the #[rustc_error] annotation, which forces an
32 /// error in codegen. This is used to write compile-fail tests
33 /// that actually test that compilation succeeds without
34 /// reporting an error.
35 pub fn check_for_rustc_errors_attr(tcx: TyCtxt<'_>) {
36 if let Some((def_id, _)) = tcx.entry_fn(LOCAL_CRATE) {
37 let attrs = &*tcx.get_attrs(def_id);
39 if attr.check_name(sym::rustc_error) {
40 match attr.meta_item_list() {
41 // check if there is a #[rustc_error(delayed)]
43 if list.iter().any(|list_item| {
44 list_item.ident().map(|i| i.name)
45 == Some(sym::delay_span_bug_from_inside_query)
47 tcx.ensure().trigger_delay_span_bug(def_id);
50 // bare #[rustc_error]
54 "fatal error triggered by #[rustc_error]",
63 pub fn provide(providers: &mut Providers<'_>) {
64 crate::symbol_names::provide(providers);
65 *providers = Providers { trigger_delay_span_bug, ..*providers };