Skip to content

Commit

Permalink
Return nonzero exit code if there are errors at a stop point
Browse files Browse the repository at this point in the history
  • Loading branch information
fhahn committed Apr 18, 2015
1 parent 7a5754b commit 2a24e97
Show file tree
Hide file tree
Showing 215 changed files with 440 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/librustc_driver/driver.rs
Expand Up @@ -52,11 +52,11 @@ pub fn compile_input(sess: Session,
output: &Option<PathBuf>,
addl_plugins: Option<Vec<String>>,
control: CompileController) {
macro_rules! controller_entry_point{($point: ident, $make_state: expr) => ({
{
let state = $make_state;
(control.$point.callback)(state);
}
macro_rules! controller_entry_point{($point: ident, $tsess: expr, $make_state: expr) => ({
let state = $make_state;
(control.$point.callback)(state);

$tsess.abort_if_errors();
if control.$point.stop == Compilation::Stop {
return;
}
Expand All @@ -70,6 +70,7 @@ pub fn compile_input(sess: Session,
let krate = phase_1_parse_input(&sess, cfg, input);

controller_entry_point!(after_parse,
sess,
CompileState::state_after_parse(input,
&sess,
outdir,
Expand All @@ -96,6 +97,7 @@ pub fn compile_input(sess: Session,
};

controller_entry_point!(after_expand,
sess,
CompileState::state_after_expand(input,
&sess,
outdir,
Expand All @@ -109,6 +111,7 @@ pub fn compile_input(sess: Session,
write_out_deps(&sess, input, &outputs, &id[..]);

controller_entry_point!(after_write_deps,
sess,
CompileState::state_after_write_deps(input,
&sess,
outdir,
Expand All @@ -123,6 +126,7 @@ pub fn compile_input(sess: Session,
control.make_glob_map);

controller_entry_point!(after_analysis,
analysis.ty_cx.sess,
CompileState::state_after_analysis(input,
&analysis.ty_cx.sess,
outdir,
Expand All @@ -149,6 +153,7 @@ pub fn compile_input(sess: Session,
phase_5_run_llvm_passes(&sess, &trans, &outputs);

controller_entry_point!(after_llvm,
sess,
CompileState::state_after_llvm(input,
&sess,
outdir,
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/mod_file_disambig.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

mod mod_file_disambig_aux; //~ ERROR file for module `mod_file_disambig_aux` found at both

fn main() {
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/mod_file_not_owning.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

// error-pattern: cannot declare a new module at this location

mod mod_file_not_owning_aux1;
Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/array-old-syntax-1.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

// Test that the old fixed length array syntax is a parsing error.

fn main() {
Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/ascii-only-character-escape.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

fn main() {
let x = "\x80"; //~ ERROR may only be used
let y = "\xff"; //~ ERROR may only be used
Expand Down
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

// Test you can't use a higher-ranked trait bound inside of a qualified
// path (just won't parse).

Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/attr-bad-meta.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

// error-pattern:expected `]`

// asterisk is bogus
Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/attr-before-eof.rs
Expand Up @@ -8,4 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

#[derive(Debug)] //~ERROR expected item after attributes
2 changes: 2 additions & 0 deletions src/test/parse-fail/attr-before-ext.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

fn main() {
#[attr] //~ ERROR expected item after attributes
println!("hi");
Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/attr-before-let.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

fn main() {
#[attr] //~ ERROR expected item
let __isize = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/attr-before-stmt.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

// error-pattern:expected item

fn f() {
Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/attr-dangling-in-fn.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

// error-pattern:expected item

fn f() {
Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/attr-dangling-in-mod.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

// error-pattern:expected item

fn main() {
Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/attr.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

#![feature(lang_items)]

fn main() {}
Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/attrs-after-extern-mod.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

// Constants (static variables) can be used to match in patterns, but mutable
// statics cannot. This ensures that there's some form of error if this is
// attempted.
Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/bad-char-literals.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

// ignore-tidy-cr
// ignore-tidy-tab
fn main() {
Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/bad-lit-suffixes.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only


extern
"C"suffix //~ ERROR ABI spec with a suffix is illegal
Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/bad-match.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

// error-pattern: expected

fn main() {
Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/bad-name.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

// error-pattern: expected

fn main() {
Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/bad-value-ident-false.rs
Expand Up @@ -8,5 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

fn false() { } //~ ERROR expected identifier, found keyword `false`
fn main() { }
2 changes: 2 additions & 0 deletions src/test/parse-fail/bad-value-ident-true.rs
Expand Up @@ -8,5 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

fn true() { } //~ ERROR expected identifier, found keyword `true`
fn main() { }
2 changes: 2 additions & 0 deletions src/test/parse-fail/better-expected.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

fn main() {
let x: [isize 3]; //~ ERROR expected one of `(`, `+`, `::`, `;`, `<`, or `]`, found `3`
}
2 changes: 2 additions & 0 deletions src/test/parse-fail/bind-struct-early-modifiers.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

fn main() {
struct Foo { x: isize }
match (Foo { x: 10 }) {
Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/byte-literals.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only


// ignore-tidy-tab

Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/byte-string-literals.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only


// ignore-tidy-tab

Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/circular_modules_hello.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

// ignore-test: this is an auxiliary file for circular-modules-main.rs

mod circular_modules_main;
Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/circular_modules_main.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

#[path = "circular_modules_hello.rs"]
mod circular_modules_hello; //~ ERROR: circular modules

Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/class-implements-bad-trait.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

// error-pattern:nonexistent
class cat : nonexistent {
let meows: usize;
Expand Down
4 changes: 3 additions & 1 deletion src/test/parse-fail/column-offset-1-based.rs
Expand Up @@ -8,4 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

# //~ ERROR 11:1: 11:2 error: expected `[`, found `<eof>`
// compile-flags: -Z parse-only

# //~ ERROR 13:1: 13:2 error: expected `[`, found `<eof>`
2 changes: 2 additions & 0 deletions src/test/parse-fail/doc-before-attr.rs
Expand Up @@ -8,5 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

/// hi
#[derive(Debug)] //~ERROR expected item after attributes
2 changes: 2 additions & 0 deletions src/test/parse-fail/doc-before-eof.rs
Expand Up @@ -8,4 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

/// hi //~ERROR expected item after doc comment
2 changes: 2 additions & 0 deletions src/test/parse-fail/doc-before-extern-rbrace.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

extern {
/// hi
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/doc-before-macro.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

fn main() {
/// hi
println!("hi");
Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/doc-before-rbrace.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

fn main() {
println!("Hi"); /// hi
//~^ ERROR expected item after doc comment
Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/doc-before-semi.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

fn main() {
/// hi
;
Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/duplicate-visibility.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

// error-pattern:unmatched visibility `pub`
extern {
pub pub fn foo();
Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/empty-impl-semicolon.rs
Expand Up @@ -8,4 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

impl Foo; //~ ERROR expected one of `(`, `+`, `..`, `::`, `<`, `for`, `where`, or `{`, found `;`
2 changes: 2 additions & 0 deletions src/test/parse-fail/extern-expected-fn-or-brace.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

// Verifies that the expected token errors for `extern crate` are
// raised

Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/extern-foreign-crate.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

// Verifies that the expected token errors for `extern crate` are
// raised

Expand Down
2 changes: 2 additions & 0 deletions src/test/parse-fail/extern-no-fn.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

extern {
f(); //~ ERROR expected one of `fn`, `pub`, `static`, `unsafe`, or `}`, found `f`
}
Expand Down

0 comments on commit 2a24e97

Please sign in to comment.