Skip to content

Commit 3c32c6a

Browse files
committed
Fix some tests with no llvm build
1 parent 56c4670 commit 3c32c6a

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

src/librustc_trans/base.rs

+1-15
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ use syntax::ast;
9494

9595
use mir::lvalue::Alignment;
9696

97-
pub use rustc_trans_utils::find_exported_symbols;
97+
pub use rustc_trans_utils::{find_exported_symbols, check_for_rustc_errors_attr};
9898

9999
pub struct StatRecorder<'a, 'tcx: 'a> {
100100
ccx: &'a CrateContext<'a, 'tcx>,
@@ -661,20 +661,6 @@ pub fn set_link_section(ccx: &CrateContext,
661661
}
662662
}
663663

664-
// check for the #[rustc_error] annotation, which forces an
665-
// error in trans. This is used to write compile-fail tests
666-
// that actually test that compilation succeeds without
667-
// reporting an error.
668-
fn check_for_rustc_errors_attr(tcx: TyCtxt) {
669-
if let Some((id, span)) = *tcx.sess.entry_fn.borrow() {
670-
let main_def_id = tcx.hir.local_def_id(id);
671-
672-
if tcx.has_attr(main_def_id, "rustc_error") {
673-
tcx.sess.span_fatal(span, "compilation successful");
674-
}
675-
}
676-
}
677-
678664
/// Create the `main` function which will initialize the rust runtime and call
679665
/// users main function.
680666
fn maybe_create_entry_wrapper(ccx: &CrateContext) {

src/librustc_trans_utils/lib.rs

+14
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,20 @@ use syntax::attr;
5252
pub mod link;
5353
pub mod trans_crate;
5454

55+
/// check for the #[rustc_error] annotation, which forces an
56+
/// error in trans. This is used to write compile-fail tests
57+
/// that actually test that compilation succeeds without
58+
/// reporting an error.
59+
pub fn check_for_rustc_errors_attr(tcx: TyCtxt) {
60+
if let Some((id, span)) = *tcx.sess.entry_fn.borrow() {
61+
let main_def_id = tcx.hir.local_def_id(id);
62+
63+
if tcx.has_attr(main_def_id, "rustc_error") {
64+
tcx.sess.span_fatal(span, "compilation successful");
65+
}
66+
}
67+
}
68+
5569
/// The context provided lists a set of reachable ids as calculated by
5670
/// middle::reachable, but this contains far more ids and symbols than we're
5771
/// actually exposing from the object file. This function will filter the set in

src/librustc_trans_utils/trans_crate.rs

+5
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ impl TransCrate for MetadataOnlyTransCrate {
192192
tcx: TyCtxt<'a, 'tcx, 'tcx>,
193193
_rx: mpsc::Receiver<Box<Any + Send>>
194194
) -> Self::OngoingCrateTranslation {
195+
::check_for_rustc_errors_attr(tcx);
196+
let _ = tcx.link_args(LOCAL_CRATE);
197+
let _ = tcx.native_libraries(LOCAL_CRATE);
198+
tcx.sess.abort_if_errors();
199+
195200
let crate_hash = tcx.dep_graph
196201
.fingerprint_of(&DepNode::new_no_params(DepKind::Krate))
197202
.unwrap();

0 commit comments

Comments
 (0)