Skip to content

Commit 4bca7fd

Browse files
committed
auto merge of #11313 : alexcrichton/rust/fix-native-failure, r=pcwalton
2 parents 1d9e66c + eadfe0e commit 4bca7fd

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/libnative/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ pub fn start(argc: int, argv: **u8, main: proc()) -> int {
7373
exit_code = Some(run(main.take_unwrap()));
7474
});
7575
unsafe { rt::cleanup(); }
76-
return exit_code.unwrap();
76+
// If the exit code wasn't set, then the task block must have failed.
77+
return exit_code.unwrap_or(rt::DEFAULT_ERROR_CODE);
7778
}
7879

7980
/// Executes a procedure on the current thread in a Rust task context.

src/test/run-fail/native-failure.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// error-pattern:explicit failure
12+
13+
#[no_uv];
14+
15+
extern mod native;
16+
17+
#[start]
18+
fn start(argc: int, argv: **u8) -> int {
19+
do native::start(argc, argv) {
20+
fail!();
21+
}
22+
}

0 commit comments

Comments
 (0)