Skip to content

Commit 391bb0b

Browse files
committed
std: Make newsched failures log correctly
1 parent 5086c08 commit 391bb0b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/libstd/sys.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,13 @@ impl FailWithCause for &'static str {
180180

181181
// FIXME #4427: Temporary until rt::rt_fail_ goes away
182182
pub fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! {
183+
use cell::Cell;
183184
use option::Option;
185+
use either::Left;
184186
use rt::{context, OldTaskContext, TaskContext};
185187
use rt::task::{Task, Unwinder};
186188
use rt::local::Local;
189+
use rt::logging::Logger;
187190

188191
let context = context();
189192
match context {
@@ -200,12 +203,18 @@ pub fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! {
200203
let msg = str::raw::from_c_str(msg);
201204
let file = str::raw::from_c_str(file);
202205

203-
let outmsg = fmt!("%s at line %i of file %s", msg, line as int, file);
206+
let outmsg = fmt!("task failed: '%s' at line %i of file %s",
207+
msg, line as int, file);
204208

205209
// XXX: Logging doesn't work correctly in non-task context because it
206210
// invokes the local heap
207211
if context == TaskContext {
208-
error!(outmsg);
212+
// XXX: Logging doesn't work here - the check to call the log
213+
// function never passes - so calling the log function directly.
214+
let outmsg = Cell::new(outmsg);
215+
do Local::borrow::<Task, ()> |task| {
216+
task.logger.log(Left(outmsg.take()));
217+
}
209218
} else {
210219
rtdebug!("%s", outmsg);
211220
}

0 commit comments

Comments
 (0)