From 3c32c6aa8dceb0759df7f1aadb46fbd35e40b003 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 23 Sep 2017 18:15:58 +0200 Subject: [PATCH] Fix some tests with no llvm build --- src/librustc_trans/base.rs | 16 +--------------- src/librustc_trans_utils/lib.rs | 14 ++++++++++++++ src/librustc_trans_utils/trans_crate.rs | 5 +++++ 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index ec4cec331d0c4..b0d24670daeaa 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -94,7 +94,7 @@ use syntax::ast; use mir::lvalue::Alignment; -pub use rustc_trans_utils::find_exported_symbols; +pub use rustc_trans_utils::{find_exported_symbols, check_for_rustc_errors_attr}; pub struct StatRecorder<'a, 'tcx: 'a> { ccx: &'a CrateContext<'a, 'tcx>, @@ -661,20 +661,6 @@ pub fn set_link_section(ccx: &CrateContext, } } -// check for the #[rustc_error] annotation, which forces an -// error in trans. This is used to write compile-fail tests -// that actually test that compilation succeeds without -// reporting an error. -fn check_for_rustc_errors_attr(tcx: TyCtxt) { - if let Some((id, span)) = *tcx.sess.entry_fn.borrow() { - let main_def_id = tcx.hir.local_def_id(id); - - if tcx.has_attr(main_def_id, "rustc_error") { - tcx.sess.span_fatal(span, "compilation successful"); - } - } -} - /// Create the `main` function which will initialize the rust runtime and call /// users main function. fn maybe_create_entry_wrapper(ccx: &CrateContext) { diff --git a/src/librustc_trans_utils/lib.rs b/src/librustc_trans_utils/lib.rs index 1de3175e2fcd8..6873befd2bfca 100644 --- a/src/librustc_trans_utils/lib.rs +++ b/src/librustc_trans_utils/lib.rs @@ -52,6 +52,20 @@ use syntax::attr; pub mod link; pub mod trans_crate; +/// check for the #[rustc_error] annotation, which forces an +/// error in trans. This is used to write compile-fail tests +/// that actually test that compilation succeeds without +/// reporting an error. +pub fn check_for_rustc_errors_attr(tcx: TyCtxt) { + if let Some((id, span)) = *tcx.sess.entry_fn.borrow() { + let main_def_id = tcx.hir.local_def_id(id); + + if tcx.has_attr(main_def_id, "rustc_error") { + tcx.sess.span_fatal(span, "compilation successful"); + } + } +} + /// The context provided lists a set of reachable ids as calculated by /// middle::reachable, but this contains far more ids and symbols than we're /// actually exposing from the object file. This function will filter the set in diff --git a/src/librustc_trans_utils/trans_crate.rs b/src/librustc_trans_utils/trans_crate.rs index 26aa7b0204695..76a15920b2402 100644 --- a/src/librustc_trans_utils/trans_crate.rs +++ b/src/librustc_trans_utils/trans_crate.rs @@ -192,6 +192,11 @@ impl TransCrate for MetadataOnlyTransCrate { tcx: TyCtxt<'a, 'tcx, 'tcx>, _rx: mpsc::Receiver> ) -> Self::OngoingCrateTranslation { + ::check_for_rustc_errors_attr(tcx); + let _ = tcx.link_args(LOCAL_CRATE); + let _ = tcx.native_libraries(LOCAL_CRATE); + tcx.sess.abort_if_errors(); + let crate_hash = tcx.dep_graph .fingerprint_of(&DepNode::new_no_params(DepKind::Krate)) .unwrap();