Skip to content

Commit 0a5f88a

Browse files
committed
Change the log level to be an enum rather than an int
This allows for eliminating a match check.
1 parent 73ffc7e commit 0a5f88a

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/libsyntax/ast.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ enum blk_check_mode { default_blk, unchecked_blk, unsafe_blk, }
309309
type expr = {id: node_id, callee_id: node_id, node: expr_, span: span};
310310
// Extra node ID is only used for index, assign_op, unary, binary
311311

312+
#[auto_serialize]
313+
enum log_level { error, debug, other }
314+
// 0 = error, 1 = debug, 2 = other
315+
312316
#[auto_serialize]
313317
enum alt_mode { alt_check, alt_exhaustive, }
314318

@@ -354,7 +358,7 @@ enum expr_ {
354358
expr_break(option<ident>),
355359
expr_again(option<ident>),
356360
expr_ret(option<@expr>),
357-
expr_log(int, @expr, @expr),
361+
expr_log(log_level, @expr, @expr),
358362

359363
/* just an assert */
360364
expr_assert(@expr),

src/libsyntax/parse/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ struct parser {
947947
let lvl = self.parse_expr();
948948
self.expect(token::COMMA);
949949
let e = self.parse_expr();
950-
ex = expr_log(2, lvl, e);
950+
ex = expr_log(ast::other, lvl, e);
951951
hi = self.span.hi;
952952
self.expect(token::RPAREN);
953953
} else if self.eat_keyword(~"assert") {

src/libsyntax/print/pprust.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,10 +1309,10 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
13091309
}
13101310
}
13111311
ast::expr_log(lvl, lexp, expr) => {
1312-
match check lvl {
1313-
1 => { word_nbsp(s, ~"log"); print_expr(s, expr); }
1314-
0 => { word_nbsp(s, ~"log_err"); print_expr(s, expr); }
1315-
2 => {
1312+
match lvl {
1313+
ast::debug => { word_nbsp(s, ~"log"); print_expr(s, expr); }
1314+
ast::error => { word_nbsp(s, ~"log_err"); print_expr(s, expr); }
1315+
ast::other => {
13161316
word_nbsp(s, ~"log");
13171317
popen(s);
13181318
print_expr(s, lexp);

0 commit comments

Comments
 (0)