From 82f190355b07f941bcc98408ea84c02b629991cf Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Fri, 8 Mar 2013 12:39:42 -0800 Subject: Remove uses of log --- src/libsyntax/ext/fmt.rs | 21 ++++++++++----------- src/libsyntax/parse/comments.rs | 4 ++-- src/libsyntax/print/pp.rs | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index af558e6b330..ee0de9e48db 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -37,8 +37,7 @@ pub fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) expr_to_str(cx, args[0], ~"first argument to fmt! must be a string literal."); let fmtspan = args[0].span; - debug!("Format string:"); - log(debug, fmt); + debug!("Format string: %s", fmt); fn parse_fmt_err_(cx: ext_ctxt, sp: span, msg: &str) -> ! { cx.span_fatal(sp, msg); } @@ -223,7 +222,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, } fn log_conv(c: Conv) { match c.param { - Some(p) => { log(debug, ~"param: " + p.to_str()); } + Some(p) => { debug!("param: %s", p.to_str()); } _ => debug!("param: none") } for c.flags.each |f| { @@ -236,18 +235,18 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, } } match c.width { - CountIs(i) => log( - debug, ~"width: count is " + i.to_str()), - CountIsParam(i) => log( - debug, ~"width: count is param " + i.to_str()), + CountIs(i) => + debug!("width: count is %s", i.to_str()), + CountIsParam(i) => + debug!("width: count is param %s", i.to_str()), CountIsNextParam => debug!("width: count is next param"), CountImplied => debug!("width: count is implied") } match c.precision { - CountIs(i) => log( - debug, ~"prec: count is " + i.to_str()), - CountIsParam(i) => log( - debug, ~"prec: count is param " + i.to_str()), + CountIs(i) => + debug!("prec: count is %s", i.to_str()), + CountIsParam(i) => + debug!("prec: count is param %s", i.to_str()), CountIsNextParam => debug!("prec: count is next param"), CountImplied => debug!("prec: count is implied") } diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index 494ef3a81a0..360cdebc670 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -183,7 +183,7 @@ fn read_line_comments(rdr: @mut StringReader, code_to_the_left: bool, let mut lines: ~[~str] = ~[]; while rdr.curr == '/' && nextch(rdr) == '/' { let line = read_one_line_comment(rdr); - log(debug, line); + debug!("%s", line); if is_doc_comment(line) { // doc-comments are not put in comments break; } @@ -221,7 +221,7 @@ fn trim_whitespace_prefix_and_push_line(lines: &mut ~[~str], s1 = str::slice(s, col, len); } else { s1 = ~""; } } else { s1 = /*bad*/ copy s; } - log(debug, ~"pushing line: " + s1); + debug!("pushing line: %s", s1); lines.push(s1); } diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index 8557ef22fc6..7f46e452299 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -472,7 +472,7 @@ pub impl Printer { fn print(&mut self, x: token, L: int) { debug!("print %s %d (remaining line space=%d)", tok_str(x), L, self.space); - log(debug, buf_str(copy self.token, + debug!("%s", buf_str(copy self.token, copy self.size, self.left, self.right, -- cgit 1.4.1-3-g733a5 From cb37d09f50e6e1ac50eee35b0874167f0119c114 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Fri, 8 Mar 2013 12:39:25 -0800 Subject: core: Remove logging constants --- src/libcore/core.rc | 9 ++++++++- src/libcore/prelude.rs | 15 --------------- src/libsyntax/ext/expand.rs | 16 ++++++++-------- 3 files changed, 16 insertions(+), 24 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libcore/core.rc b/src/libcore/core.rc index 026f49cac45..31d553f5a8c 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -216,14 +216,17 @@ pub use clone::Clone; * more-verbosity. Error is the bottom level, default logging level is * warn-and-below. */ - /// The error log level +#[cfg(stage0)] pub const error : u32 = 1_u32; /// The warning log level +#[cfg(stage0)] pub const warn : u32 = 2_u32; /// The info log level +#[cfg(stage0)] pub const info : u32 = 3_u32; /// The debug log level +#[cfg(stage0)] pub const debug : u32 = 4_u32; @@ -251,9 +254,13 @@ pub mod rt; // can be resolved within libcore. #[doc(hidden)] // FIXME #3538 pub mod core { + #[cfg(stage0)] pub const error : u32 = 1_u32; + #[cfg(stage0)] pub const warn : u32 = 2_u32; + #[cfg(stage0)] pub const info : u32 = 3_u32; + #[cfg(stage0)] pub const debug : u32 = 4_u32; pub use cmp; diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs index 2f575ce7d28..c5b1b9eb875 100644 --- a/src/libcore/prelude.rs +++ b/src/libcore/prelude.rs @@ -82,18 +82,3 @@ pub use u64; pub use u8; pub use uint; pub use vec; - -/* - * Export the log levels as global constants. Higher levels mean - * more-verbosity. Error is the bottom level, default logging level is - * warn-and-below. - */ - -/// The error log level -pub const error : u32 = 1_u32; -/// The warning log level -pub const warn : u32 = 2_u32; -/// The info log level -pub const info : u32 = 3_u32; -/// The debug log level -pub const debug : u32 = 4_u32; diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index e61e8a1a594..9cca2332374 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -411,34 +411,34 @@ pub fn core_macros() -> ~str { macro_rules! error ( ($arg:expr) => ( - log(::core::error, fmt!( \"%?\", $arg )) + log(1u32, fmt!( \"%?\", $arg )) ); ($( $arg:expr ),+) => ( - log(::core::error, fmt!( $($arg),+ )) + log(1u32, fmt!( $($arg),+ )) ) ) macro_rules! warn ( ($arg:expr) => ( - log(::core::warn, fmt!( \"%?\", $arg )) + log(2u32, fmt!( \"%?\", $arg )) ); ($( $arg:expr ),+) => ( - log(::core::warn, fmt!( $($arg),+ )) + log(2u32, fmt!( $($arg),+ )) ) ) macro_rules! info ( ($arg:expr) => ( - log(::core::info, fmt!( \"%?\", $arg )) + log(3u32, fmt!( \"%?\", $arg )) ); ($( $arg:expr ),+) => ( - log(::core::info, fmt!( $($arg),+ )) + log(3u32, fmt!( $($arg),+ )) ) ) macro_rules! debug ( ($arg:expr) => ( - log(::core::debug, fmt!( \"%?\", $arg )) + log(4u32, fmt!( \"%?\", $arg )) ); ($( $arg:expr ),+) => ( - log(::core::debug, fmt!( $($arg),+ )) + log(4u32, fmt!( $($arg),+ )) ) ) -- cgit 1.4.1-3-g733a5 From 9c7e16e48d15b3380cc680f6194fe3516867d2db Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Fri, 8 Mar 2013 18:32:03 -0800 Subject: Remove the log keyword (by renaming it to __log) We can't quite remove logging from the language, but this hides the keyword. --- src/libsyntax/ext/expand.rs | 16 ++++++++-------- src/libsyntax/parse/parser.rs | 2 +- src/libsyntax/parse/token.rs | 2 +- src/test/run-fail/issue-1459.rs | 14 -------------- 4 files changed, 10 insertions(+), 24 deletions(-) delete mode 100644 src/test/run-fail/issue-1459.rs (limited to 'src/libsyntax') diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 9cca2332374..831d1140a53 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -411,34 +411,34 @@ pub fn core_macros() -> ~str { macro_rules! error ( ($arg:expr) => ( - log(1u32, fmt!( \"%?\", $arg )) + __log(1u32, fmt!( \"%?\", $arg )) ); ($( $arg:expr ),+) => ( - log(1u32, fmt!( $($arg),+ )) + __log(1u32, fmt!( $($arg),+ )) ) ) macro_rules! warn ( ($arg:expr) => ( - log(2u32, fmt!( \"%?\", $arg )) + __log(2u32, fmt!( \"%?\", $arg )) ); ($( $arg:expr ),+) => ( - log(2u32, fmt!( $($arg),+ )) + __log(2u32, fmt!( $($arg),+ )) ) ) macro_rules! info ( ($arg:expr) => ( - log(3u32, fmt!( \"%?\", $arg )) + __log(3u32, fmt!( \"%?\", $arg )) ); ($( $arg:expr ),+) => ( - log(3u32, fmt!( $($arg),+ )) + __log(3u32, fmt!( $($arg),+ )) ) ) macro_rules! debug ( ($arg:expr) => ( - log(4u32, fmt!( \"%?\", $arg )) + __log(4u32, fmt!( \"%?\", $arg )) ); ($( $arg:expr ),+) => ( - log(4u32, fmt!( $($arg),+ )) + __log(4u32, fmt!( $($arg),+ )) ) ) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 99c1c2cb1fe..7d3f5c12612 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1184,7 +1184,7 @@ pub impl Parser { } } hi = self.span.hi; - } else if self.eat_keyword(&~"log") { + } else if self.eat_keyword(&~"__log") { self.expect(&token::LPAREN); let lvl = self.parse_expr(); self.expect(&token::COMMA); diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 81aacbf173d..c41b3aec09b 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -495,7 +495,7 @@ pub fn strict_keyword_table() -> HashMap<~str, ()> { ~"else", ~"enum", ~"extern", ~"false", ~"fn", ~"for", ~"if", ~"impl", - ~"let", ~"log", ~"loop", + ~"let", ~"__log", ~"loop", ~"match", ~"mod", ~"mut", ~"once", ~"priv", ~"pub", ~"pure", diff --git a/src/test/run-fail/issue-1459.rs b/src/test/run-fail/issue-1459.rs deleted file mode 100644 index 7f8cc7459de..00000000000 --- a/src/test/run-fail/issue-1459.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:roflcopter -fn main() { - log (fail!(~"roflcopter"), 2); -} -- cgit 1.4.1-3-g733a5