Skip to content

Commit f0d45c2

Browse files
committed
---
yaml --- r: 63563 b: refs/heads/snap-stage3 c: 69e0704 h: refs/heads/master i: 63561: 1204fad 63559: 3783355 v: v3
1 parent 6a1e7c0 commit f0d45c2

File tree

4 files changed

+21
-22
lines changed

4 files changed

+21
-22
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: df626ea137af1436cb2e5eda19c145363db801c9
4+
refs/heads/snap-stage3: 69e0704520c5296282a33e39ff056921e3cff7d3
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libsyntax/diagnostic.rs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -189,30 +189,36 @@ fn diagnosticcolor(lvl: level) -> u8 {
189189
}
190190
}
191191

192-
fn print_diagnostic(topic: &str, lvl: level, msg: &str) {
193-
let t = term::Terminal::new(io::stderr());
194-
192+
fn print_maybe_colored(msg: &str, color: u8) {
195193
let stderr = io::stderr();
196194

197-
if !topic.is_empty() {
198-
stderr.write_str(fmt!("%s ", topic));
199-
}
195+
let t = term::Terminal::new(stderr);
200196

201197
match t {
202198
Ok(term) => {
203199
if stderr.get_type() == io::Screen {
204-
term.fg(diagnosticcolor(lvl));
205-
stderr.write_str(fmt!("%s: ", diagnosticstr(lvl)));
200+
term.fg(color);
201+
stderr.write_str(msg);
206202
term.reset();
207-
stderr.write_str(fmt!("%s\n", msg));
208203
} else {
209-
stderr.write_str(fmt!("%s: %s\n", diagnosticstr(lvl), msg));
204+
stderr.write_str(msg);
210205
}
211206
},
212-
_ => stderr.write_str(fmt!("%s: %s\n", diagnosticstr(lvl), msg))
207+
_ => stderr.write_str(msg)
213208
}
214209
}
215210

211+
fn print_diagnostic(topic: &str, lvl: level, msg: &str) {
212+
let stderr = io::stderr();
213+
214+
if !topic.is_empty() {
215+
stderr.write_str(fmt!("%s ", topic));
216+
}
217+
218+
print_maybe_colored(fmt!("%s: ", diagnosticstr(lvl)), diagnosticcolor(lvl));
219+
stderr.write_str(fmt!("%s\n", msg));
220+
}
221+
216222
pub fn collect(messages: @mut ~[~str])
217223
-> @fn(Option<(@codemap::CodeMap, span)>, &str, level) {
218224
let f: @fn(Option<(@codemap::CodeMap, span)>, &str, level) =
@@ -292,14 +298,15 @@ fn highlight_lines(cm: @codemap::CodeMap,
292298
_ => " " // -squigly-line as well (instead of a
293299
}; // space). This way the squigly-line will
294300
} // usually appear in the correct position.
295-
s += "^";
301+
io::stderr().write_str(s);
302+
let mut s = ~"^";
296303
let hi = cm.lookup_char_pos(sp.hi);
297304
if hi.col != lo.col {
298305
// the ^ already takes up one space
299306
let num_squiglies = hi.col.to_uint()-lo.col.to_uint()-1u;
300307
for num_squiglies.times() { s += "~"; }
301308
}
302-
io::stderr().write_str(s + "\n");
309+
print_maybe_colored(s + "\n", term::color_bright_green);
303310
}
304311
}
305312

branches/snap-stage3/src/libsyntax/ext/fmt.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,6 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span,
249249
}
250250
}
251251

252-
/* Short circuit an easy case up front (won't work otherwise) */
253-
if pieces.len() == 0 {
254-
return cx.expr_str_uniq(args[0].span, @"");
255-
}
256-
257252
let fmt_sp = args[0].span;
258253
let mut n = 0u;
259254
let nargs = args.len();

branches/snap-stage3/src/test/run-pass/syntax-extension-fmt.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ fn part1() {
5858
test(fmt!("%x", 0xffffffff_u), ~"ffffffff");
5959
test(fmt!("%o", 0xffffffff_u), ~"37777777777");
6060
test(fmt!("%t", 0xffffffff_u), ~"11111111111111111111111111111111");
61-
62-
// Don't result in a compilation error
63-
test(fmt!(""), ~"");
6461
}
6562
fn part2() {
6663
// Widths

0 commit comments

Comments
 (0)