Skip to content

Commit aa69b17

Browse files
committed
---
yaml --- r: 82702 b: refs/heads/auto c: a94158c h: refs/heads/master v: v3
1 parent b5000d6 commit aa69b17

File tree

19 files changed

+161
-180
lines changed

19 files changed

+161
-180
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 25bc6b628330c4f745f2261d2146e2839325d03e
16+
refs/heads/auto: a94158ce64524b7e21e6c8ec23a6b762d45926fb
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/etc/emacs/rust-mode.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
(defconst rust-mode-keywords
128128
'("as"
129129
"break"
130+
"continue"
130131
"do"
131132
"else" "enum" "extern"
132133
"false" "fn" "for"

branches/auto/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<keyword>assert</keyword>
4040
<keyword>break</keyword>
4141
<keyword>const</keyword>
42+
<keyword>continue</keyword>
4243
<keyword>do</keyword>
4344
<keyword>drop</keyword>
4445
<keyword>else</keyword>

branches/auto/src/etc/kate/rust.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<list name="keywords">
1919
<item> as </item>
2020
<item> break </item>
21+
<item> continue </item>
2122
<item> do </item>
2223
<item> drop </item>
2324
<item> else </item>

branches/auto/src/etc/vim/syntax/rust.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ syn keyword rustOperator as
1818

1919
syn match rustAssert "\<assert\(\w\)*!" contained
2020
syn match rustFail "\<fail\(\w\)*!" contained
21-
syn keyword rustKeyword break do extern
21+
syn keyword rustKeyword break continue do extern
2222
syn keyword rustKeyword in if impl let log
2323
syn keyword rustKeyword for impl let log
2424
syn keyword rustKeyword loop mod once priv pub

branches/auto/src/librustc/metadata/decoder.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -564,19 +564,19 @@ impl<'self> EachItemContext<'self> {
564564
}
565565
}
566566

567-
let mut continue = (self.callback)(*self.path_builder, def_like, vis);
567+
let mut continue_ = (self.callback)(*self.path_builder, def_like, vis);
568568

569569
let family = item_family(doc);
570570
if family == ForeignMod {
571571
// These are unnamed; pop the name now.
572572
self.pop_name(old_len)
573573
}
574574

575-
if continue {
575+
if continue_ {
576576
// Recurse if necessary.
577577
match family {
578578
Mod | ForeignMod | Trait | Impl => {
579-
continue = self.each_item_of_module(def_id);
579+
continue_ = self.each_item_of_module(def_id);
580580
}
581581
ImmStatic | MutStatic | Struct | UnsafeFn | Fn | ForeignFn |
582582
UnsafeStaticMethod | StaticMethod | Type | ForeignType |
@@ -589,7 +589,7 @@ impl<'self> EachItemContext<'self> {
589589
self.pop_name(old_len)
590590
}
591591

592-
continue
592+
continue_
593593
}
594594

595595
fn each_item_of_module(&mut self, def_id: ast::DefId) -> bool {
@@ -612,7 +612,7 @@ impl<'self> EachItemContext<'self> {
612612
}
613613

614614
fn each_child_of_module_or_crate(&mut self, item_doc: ebml::Doc) -> bool {
615-
let mut continue = true;
615+
let mut continue_ = true;
616616

617617
// Iterate over all children.
618618
do reader::tagged_docs(item_doc, tag_mod_child) |child_info_doc| {
@@ -654,16 +654,16 @@ impl<'self> EachItemContext<'self> {
654654
// Process this item.
655655

656656
let vis = item_visibility(child_item_doc);
657-
continue = self.process_item_and_pop_name(child_item_doc,
657+
continue_ = self.process_item_and_pop_name(child_item_doc,
658658
child_def_id,
659659
old_len,
660660
vis);
661661
}
662662
}
663-
continue
663+
continue_
664664
};
665665

666-
if !continue {
666+
if !continue_ {
667667
return false
668668
}
669669

@@ -705,18 +705,18 @@ impl<'self> EachItemContext<'self> {
705705
match maybe_find_item(def_id.node, other_crates_items) {
706706
None => { self.pop_name(old_len); }
707707
Some(reexported_item_doc) => {
708-
continue = self.process_item_and_pop_name(
708+
continue_ = self.process_item_and_pop_name(
709709
reexported_item_doc,
710710
def_id,
711711
old_len,
712712
ast::public);
713713
}
714714
}
715715

716-
continue
716+
continue_
717717
};
718718

719-
continue
719+
continue_
720720
}
721721
}
722722

branches/auto/src/librustc/metadata/encoder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -521,12 +521,12 @@ fn encode_reexported_static_methods(ecx: &EncodeContext,
521521
/// * For newtype structs, iterates through the node ID of the constructor.
522522
fn each_auxiliary_node_id(item: @item, callback: &fn(NodeId) -> bool)
523523
-> bool {
524-
let mut continue = true;
524+
let mut continue_ = true;
525525
match item.node {
526526
item_enum(ref enum_def, _) => {
527527
for variant in enum_def.variants.iter() {
528-
continue = callback(variant.node.id);
529-
if !continue {
528+
continue_ = callback(variant.node.id);
529+
if !continue_ {
530530
break
531531
}
532532
}
@@ -537,15 +537,15 @@ fn each_auxiliary_node_id(item: @item, callback: &fn(NodeId) -> bool)
537537
Some(ctor_id) if struct_def.fields.len() > 0 &&
538538
struct_def.fields[0].node.kind ==
539539
ast::unnamed_field => {
540-
continue = callback(ctor_id);
540+
continue_ = callback(ctor_id);
541541
}
542542
_ => {}
543543
}
544544
}
545545
_ => {}
546546
}
547547

548-
continue
548+
continue_
549549
}
550550

551551
fn encode_reexports(ecx: &EncodeContext,

branches/auto/src/libstd/logging.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
//! Logging
1212
13+
use fmt;
1314
use option::*;
1415
use os;
1516
use rt;
1617
use rt::logging::{Logger, StdErrLogger};
17-
use send_str::SendStrOwned;
1818

1919
/// Turns on logging to stdout globally
2020
pub fn console_on() {
@@ -37,7 +37,17 @@ pub fn console_off() {
3737
rt::logging::console_off();
3838
}
3939

40-
fn newsched_log_str(msg: ~str) {
40+
#[cfg(stage0)]
41+
#[doc(hidden)]
42+
pub fn log(_level: u32, s: ~str) {
43+
// this is a terrible approximation, but it gets the job done (for stage0 at
44+
// least)
45+
::io::println(s);
46+
}
47+
48+
#[allow(missing_doc)]
49+
#[cfg(not(stage0))]
50+
pub fn log(_level: u32, args: &fmt::Arguments) {
4151
use rt::task::Task;
4252
use rt::local::Local;
4353

@@ -46,20 +56,13 @@ fn newsched_log_str(msg: ~str) {
4656
match optional_task {
4757
Some(local) => {
4858
// Use the available logger
49-
(*local).logger.log(SendStrOwned(msg));
59+
(*local).logger.log(args);
5060
}
5161
None => {
5262
// There is no logger anywhere, just write to stderr
5363
let mut logger = StdErrLogger;
54-
logger.log(SendStrOwned(msg));
64+
logger.log(args);
5565
}
5666
}
5767
}
5868
}
59-
60-
// XXX: This will change soon to not require an allocation. This is an unstable
61-
// api which should not be used outside of the macros in ext/expand.
62-
#[doc(hidden)]
63-
pub fn log(_level: u32, msg: ~str) {
64-
newsched_log_str(msg);
65-
}

branches/auto/src/libstd/rt/logging.rs

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10+
11+
use fmt;
1012
use from_str::from_str;
11-
use libc::{uintptr_t, exit, STDERR_FILENO};
13+
use libc::{uintptr_t, exit};
1214
use option::{Some, None, Option};
15+
use rt;
1316
use rt::util::dumb_println;
1417
use rt::crate_map::{ModEntry, iter_crate_map};
1518
use rt::crate_map::get_crate_map;
@@ -18,7 +21,6 @@ use str::raw::from_c_str;
1821
use u32;
1922
use vec::ImmutableVector;
2023
use cast::transmute;
21-
use send_str::{SendStr, SendStrOwned, SendStrStatic};
2224

2325
struct LogDirective {
2426
name: Option<~str>,
@@ -171,44 +173,33 @@ fn update_log_settings(crate_map: *u8, settings: ~str) {
171173
}
172174

173175
pub trait Logger {
174-
fn log(&mut self, msg: SendStr);
176+
fn log(&mut self, args: &fmt::Arguments);
175177
}
176178

177179
pub struct StdErrLogger;
178180

179181
impl Logger for StdErrLogger {
180-
fn log(&mut self, msg: SendStr) {
181-
use io::{Writer, WriterUtil};
182-
183-
if !should_log_console() {
184-
return;
182+
fn log(&mut self, args: &fmt::Arguments) {
183+
if should_log_console() {
184+
fmt::write(self as &mut rt::io::Writer, args);
185185
}
186+
}
187+
}
186188

187-
let s: &str = match msg {
188-
SendStrOwned(ref s) => {
189-
let slc: &str = *s;
190-
slc
191-
},
192-
SendStrStatic(s) => s,
193-
};
194-
195-
// Truncate the string
196-
let buf_bytes = 2048;
197-
if s.len() > buf_bytes {
198-
let s = s.slice(0, buf_bytes) + "[...]";
199-
print(s);
200-
} else {
201-
print(s)
202-
};
203-
204-
fn print(s: &str) {
205-
let dbg = STDERR_FILENO as ::io::fd_t;
206-
dbg.write_str(s);
207-
dbg.write_str("\n");
208-
dbg.flush();
209-
}
189+
impl rt::io::Writer for StdErrLogger {
190+
fn write(&mut self, buf: &[u8]) {
191+
// Nothing like swapping between I/O implementations! In theory this
192+
// could use the libuv bindings for writing to file descriptors, but
193+
// that may not necessarily be desirable because logging should work
194+
// outside of the uv loop. (modify with caution)
195+
use io::Writer;
196+
let dbg = ::libc::STDERR_FILENO as ::io::fd_t;
197+
dbg.write(buf);
210198
}
199+
200+
fn flush(&mut self) {}
211201
}
202+
212203
/// Configure logging by traversing the crate map and setting the
213204
/// per-module global logging flags based on the logging spec
214205
pub fn init() {

branches/auto/src/libstd/std.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,5 @@ mod std {
223223
pub use os;
224224
pub use fmt;
225225
pub use to_bytes;
226+
pub use logging;
226227
}

branches/auto/src/libstd/sys.rs

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -125,37 +125,56 @@ impl FailWithCause for &'static str {
125125
}
126126
}
127127

128-
// FIXME #4427: Temporary until rt::rt_fail_ goes away
128+
// This stage0 version is incredibly wrong.
129+
#[cfg(stage0)]
129130
pub fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! {
130131
use option::{Some, None};
131132
use rt::in_green_task_context;
132133
use rt::task::Task;
133134
use rt::local::Local;
134135
use rt::logging::Logger;
135-
use send_str::SendStrOwned;
136+
use str::Str;
137+
138+
unsafe {
139+
let msg = str::raw::from_c_str(msg);
140+
let file = str::raw::from_c_str(file);
141+
if in_green_task_context() {
142+
rterrln!("task failed at '%s', %s:%i", msg, file, line as int);
143+
} else {
144+
rterrln!("failed in non-task context at '%s', %s:%i",
145+
msg, file, line as int);
146+
}
147+
148+
let task: *mut Task = Local::unsafe_borrow();
149+
if (*task).unwinder.unwinding {
150+
rtabort!("unwinding again");
151+
}
152+
(*task).unwinder.begin_unwind();
153+
}
154+
}
155+
156+
// FIXME #4427: Temporary until rt::rt_fail_ goes away
157+
#[cfg(not(stage0))]
158+
pub fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! {
159+
use rt::in_green_task_context;
160+
use rt::task::Task;
161+
use rt::local::Local;
162+
use rt::logging::Logger;
136163
use str::Str;
137164

138165
unsafe {
139166
// XXX: Bad re-allocations. fail! needs some refactoring
140167
let msg = str::raw::from_c_str(msg);
141168
let file = str::raw::from_c_str(file);
142169

143-
// XXX: Logging doesn't work correctly in non-task context because it
144-
// invokes the local heap
145170
if in_green_task_context() {
146-
// XXX: Logging doesn't work here - the check to call the log
147-
// function never passes - so calling the log function directly.
171+
// Be careful not to allocate in this block, if we're failing we may
172+
// have been failing due to a lack of memory in the first place...
148173
do Local::borrow |task: &mut Task| {
149-
let msg = match task.name {
150-
Some(ref name) =>
151-
fmt!("task '%s' failed at '%s', %s:%i",
152-
name.as_slice(), msg, file, line as int),
153-
None =>
154-
fmt!("task <unnamed> failed at '%s', %s:%i",
155-
msg, file, line as int)
156-
};
157-
158-
task.logger.log(SendStrOwned(msg));
174+
let n = task.name.map(|n| n.as_slice()).unwrap_or("<unnamed>");
175+
format_args!(|args| { task.logger.log(args) },
176+
"task '{}' failed at '{}', {}:{}",
177+
n, msg.as_slice(), file.as_slice(), line);
159178
}
160179
} else {
161180
rterrln!("failed in non-task context at '%s', %s:%i",

0 commit comments

Comments
 (0)