Skip to content

Commit

Permalink
Fix some tests with no llvm build
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Sep 23, 2017
1 parent 56c4670 commit 3c32c6a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
16 changes: 1 addition & 15 deletions src/librustc_trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -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) {
Expand Down
14 changes: 14 additions & 0 deletions src/librustc_trans_utils/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/librustc_trans_utils/trans_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 3c32c6a

Please sign in to comment.