Skip to content

Commit beda30e

Browse files
committed
auto merge of #16342 : alexcrichton/rust/issue-16341, r=huonw
Now that rustdoc is spawning a child task, the program won't exit with a default error code if the main task fails (because it never fails). This commit forces the main task to wait for a child task in order to correctly propagate failure. Closes #16341
2 parents f9a4323 + d9038fc commit beda30e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/librustdoc/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,16 @@ pub fn main() {
120120
// So, in summary, it is unknown why this is necessary, what it is
121121
// preventing, or what the actual bug is. In the meantime, this allows
122122
// --test to work on windows, which seems good, right? Fun times.
123+
let (tx, rx) = channel();
123124
spawn(proc() {
124125
std::os::set_exit_status(main_args(std::os::args().as_slice()));
126+
tx.send(());
125127
});
128+
129+
// If the task failed, set an error'd exit status
130+
if rx.recv_opt().is_err() {
131+
std::os::set_exit_status(std::rt::DEFAULT_ERROR_CODE);
132+
}
126133
}
127134

128135
pub fn opts() -> Vec<getopts::OptGroup> {

0 commit comments

Comments
 (0)