Fix some tests with no llvm build
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user