about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2017-09-23 18:15:58 +0200
committerbjorn3 <bjorn3@users.noreply.github.com>2017-09-23 18:15:58 +0200
commit3c32c6aa8dceb0759df7f1aadb46fbd35e40b003 (patch)
treeb8db79fb7a0902f6f09a2ed10fc693ccebdc4b4c
parent56c46707ed19caaadfe8b0e7fdb034d140eb45fb (diff)
downloadrust-3c32c6aa8dceb0759df7f1aadb46fbd35e40b003.tar.gz
rust-3c32c6aa8dceb0759df7f1aadb46fbd35e40b003.zip
Fix some tests with no llvm build
-rw-r--r--src/librustc_trans/base.rs16
-rw-r--r--src/librustc_trans_utils/lib.rs14
-rw-r--r--src/librustc_trans_utils/trans_crate.rs5
3 files changed, 20 insertions, 15 deletions
diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs
index ec4cec331d0..b0d24670dae 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 1de3175e2fc..6873befd2bf 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 26aa7b02046..76a15920b24 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<Box<Any + Send>>
     ) -> 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();