14
14
15
15
use c_str:: ToCStr ;
16
16
use cast;
17
+ use libc:: size_t;
17
18
use libc;
18
- use libc:: { c_char, size_t} ;
19
19
use repr;
20
+ use rt:: task;
20
21
use str;
21
22
use unstable:: intrinsics;
22
23
@@ -109,7 +110,7 @@ impl FailWithCause for ~str {
109
110
fn fail_with ( cause : ~str , file : & ' static str , line : uint ) -> ! {
110
111
do cause. with_c_str |msg_buf| {
111
112
do file. with_c_str |file_buf| {
112
- begin_unwind_ ( msg_buf, file_buf, line as libc:: size_t )
113
+ task :: begin_unwind ( msg_buf, file_buf, line as libc:: size_t )
113
114
}
114
115
}
115
116
}
@@ -119,47 +120,12 @@ impl FailWithCause for &'static str {
119
120
fn fail_with ( cause : & ' static str , file : & ' static str , line : uint ) -> ! {
120
121
do cause. with_c_str |msg_buf| {
121
122
do file. with_c_str |file_buf| {
122
- begin_unwind_ ( msg_buf, file_buf, line as libc:: size_t )
123
+ task :: begin_unwind ( msg_buf, file_buf, line as libc:: size_t )
123
124
}
124
125
}
125
126
}
126
127
}
127
128
128
- // FIXME #4427: Temporary until rt::rt_fail_ goes away
129
- pub fn begin_unwind_ ( msg : * c_char , file : * c_char , line : size_t ) -> ! {
130
- use rt:: in_green_task_context;
131
- use rt:: task:: Task ;
132
- use rt:: local:: Local ;
133
- use rt:: logging:: Logger ;
134
- use str:: Str ;
135
-
136
- unsafe {
137
- // XXX: Bad re-allocations. fail2! needs some refactoring
138
- let msg = str:: raw:: from_c_str ( msg) ;
139
- let file = str:: raw:: from_c_str ( file) ;
140
-
141
- if in_green_task_context ( ) {
142
- // Be careful not to allocate in this block, if we're failing we may
143
- // have been failing due to a lack of memory in the first place...
144
- do Local :: borrow |task: & mut Task | {
145
- let n = task. name . as_ref ( ) . map ( |n| n. as_slice ( ) ) . unwrap_or ( "<unnamed>" ) ;
146
- format_args ! ( |args| { task. logger. log( args) } ,
147
- "task '{}' failed at '{}', {}:{}" ,
148
- n, msg. as_slice( ) , file. as_slice( ) , line) ;
149
- }
150
- } else {
151
- rterrln ! ( "failed in non-task context at '{}', {}:{}" ,
152
- msg, file, line as int) ;
153
- }
154
-
155
- let task: * mut Task = Local :: unsafe_borrow ( ) ;
156
- if ( * task) . unwinder . unwinding {
157
- rtabort ! ( "unwinding again" ) ;
158
- }
159
- ( * task) . unwinder . begin_unwind ( ) ;
160
- }
161
- }
162
-
163
129
#[ cfg( test) ]
164
130
mod tests {
165
131
use cast;
0 commit comments