Skip to content

Fix make check-stage1 #27417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions mk/tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -612,8 +612,10 @@ define DEF_CTEST_VARS
# $(3) is the host triple to test

# Prerequisites for compiletest tests
# Note that we always use a stage2 compiletest binary; a stage1
# compiletest is unusable because stage1 binaries can't panic.
TEST_SREQ$(1)_T_$(2)_H_$(3) = \
$$(HBIN$(1)_H_$(3))/compiletest$$(X_$(3)) \
$$(HBIN2_H_$(3))/compiletest$$(X_$(3)) \
$$(SREQ$(1)_T_$(2)_H_$(3))

# Rules for the cfail/rfail/rpass/bench/perf test runner
Expand Down Expand Up @@ -735,7 +737,7 @@ $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
$$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3))
@$$(call E, run $(4) [$(2)]: $$<)
$$(Q)touch $$@.start_time
$$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
$$(Q)$$(call CFG_RUN_CTEST_$(2),2,$$<,$(3)) \
$$(CTEST_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
--logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
&& touch -r $$@.start_time $$@ && rm $$@.start_time
Expand Down
8 changes: 5 additions & 3 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,15 @@ impl Session {
if self.opts.treat_err_as_bug {
self.span_bug(sp, msg);
}
panic!(self.diagnostic().span_fatal(sp, msg))
let _ = self.diagnostic().span_fatal(sp, msg);
diagnostic::raise_fatal_error();
}
pub fn span_fatal_with_code(&self, sp: Span, msg: &str, code: &str) -> ! {
if self.opts.treat_err_as_bug {
self.span_bug(sp, msg);
}
panic!(self.diagnostic().span_fatal_with_code(sp, msg, code))
let _ = self.diagnostic().span_fatal_with_code(sp, msg, code);
diagnostic::raise_fatal_error();
}
pub fn fatal(&self, msg: &str) -> ! {
if self.opts.treat_err_as_bug {
Expand Down Expand Up @@ -454,7 +456,7 @@ pub fn expect<T, M>(sess: &Session, opt: Option<T>, msg: M) -> T where
pub fn early_error(msg: &str) -> ! {
let mut emitter = diagnostic::EmitterWriter::stderr(diagnostic::Auto, None);
emitter.emit(None, msg, None, diagnostic::Fatal);
panic!(diagnostic::FatalError);
diagnostic::raise_fatal_error();
}

pub fn early_warn(msg: &str) {
Expand Down
29 changes: 22 additions & 7 deletions src/libsyntax/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,15 @@ impl SpanHandler {
}
pub fn span_fatal(&self, sp: Span, msg: &str) -> FatalError {
self.handler.emit(Some((&self.cm, sp)), msg, Fatal);
return FatalError;
// FIXME: This API should probably be changed so it returns `!`,
// like its counterpart in librustc.
raise_fatal_error();
}
pub fn span_fatal_with_code(&self, sp: Span, msg: &str, code: &str) -> FatalError {
self.handler.emit_with_code(Some((&self.cm, sp)), msg, code, Fatal);
return FatalError;
// FIXME: This API should probably be changed so it returns `!`,
// like its counterpart in librustc.
raise_fatal_error();
}
pub fn span_err(&self, sp: Span, msg: &str) {
self.handler.emit(Some((&self.cm, sp)), msg, Error);
Expand Down Expand Up @@ -208,11 +212,7 @@ impl Handler {
}
pub fn fatal(&self, msg: &str) -> ! {
self.emit.borrow_mut().emit(None, msg, None, Fatal);

// Suppress the fatal error message from the panic below as we've
// already terminated in our own "legitimate" fashion.
io::set_panic(Box::new(io::sink()));
panic!(FatalError);
raise_fatal_error();
}
pub fn err(&self, msg: &str) {
self.emit.borrow_mut().emit(None, msg, None, Error);
Expand Down Expand Up @@ -824,6 +824,21 @@ pub fn expect<T, M>(diag: &SpanHandler, opt: Option<T>, msg: M) -> T where
}
}

// Note: this is necessary to make stage1 compilers usable; don't
// remove on snapshot.
#[cfg(stage0)]
pub fn raise_fatal_error() -> ! {
// A stage1 compiler has panics disabled... so as a hack, just kill the
// whole process.
use std;
std::process::exit(101);
}

#[cfg(not(stage0))]
pub fn raise_fatal_error() -> ! {
panic!(FatalError);
}

#[cfg(test)]
mod test {
use super::{EmitterWriter, Level};
Expand Down
5 changes: 2 additions & 3 deletions src/libsyntax/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#![feature(libc)]
#![feature(ref_slice)]
#![feature(rustc_private)]
#![feature(set_stdio)]
#![feature(staged_api)]
#![feature(str_char)]
#![feature(str_escape)]
Expand All @@ -55,10 +54,10 @@ extern crate serialize as rustc_serialize; // used by deriving
macro_rules! panictry {
($e:expr) => ({
use std::result::Result::{Ok, Err};
use diagnostic::FatalError;
use diagnostic::{FatalError, raise_fatal_error};
match $e {
Ok(e) => e,
Err(FatalError) => panic!(FatalError)
Err(FatalError) => raise_fatal_error(),
}
})
}
Expand Down
6 changes: 3 additions & 3 deletions src/test/compile-fail/macro-incomplete-parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ macro_rules! ignored_item {
}

macro_rules! ignored_expr {
() => ( 1, //~ ERROR unexpected token: `,`
2 ) //~ ERROR macro expansion ignores token `2`
() => ( 1, //~ ERROR macro expansion ignores token `,`
2 )
}

macro_rules! ignored_pat {
Expand All @@ -28,7 +28,7 @@ macro_rules! ignored_pat {
ignored_item!(); //~ NOTE caused by the macro expansion here

fn main() {
ignored_expr!(); //~ NOTE caused by the macro expansion here
(ignored_expr!()); //~ NOTE caused by the macro expansion here
match 1 {
ignored_pat!() => (), //~ NOTE caused by the macro expansion here
_ => (),
Expand Down