diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-09-27 21:01:58 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-09-30 23:21:19 -0700 |
| commit | af3b132285bc9314d545cae2e4eaef079a26252a (patch) | |
| tree | 1c7116cb4d82388a6eb3da6e4088448ea24016ba /src/libsyntax/ext | |
| parent | 7e709bfd0dac1d5bbe5c97494980731b4d477e8f (diff) | |
| download | rust-af3b132285bc9314d545cae2e4eaef079a26252a.tar.gz rust-af3b132285bc9314d545cae2e4eaef079a26252a.zip | |
syntax: Remove usage of fmt!
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/asm.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/base.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/clone.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/decodable.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/encodable.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic.rs | 11 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/mod.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/env.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 93 | ||||
| -rw-r--r-- | src/libsyntax/ext/fmt.rs | 60 | ||||
| -rw-r--r-- | src/libsyntax/ext/format.rs | 58 | ||||
| -rw-r--r-- | src/libsyntax/ext/quote.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/transcribe.rs | 10 |
14 files changed, 143 insertions, 141 deletions
diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index d47435dab56..9241e8c4fbc 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -111,7 +111,7 @@ pub fn expand_asm(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) p.eat(&token::COMMA); } - let clob = fmt!("~{%s}", p.parse_str()); + let clob = format!("~\\{{}\\}", p.parse_str()); clobs.push(clob); } diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 4824924bc0f..3b4be1de3e8 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -423,7 +423,7 @@ pub fn expr_to_str(cx: @ExtCtxt, expr: @ast::Expr, err_msg: &str) -> @str { pub fn check_zero_tts(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree], name: &str) { if tts.len() != 0 { - cx.span_fatal(sp, fmt!("%s takes no arguments", name)); + cx.span_fatal(sp, format!("{} takes no arguments", name)); } } @@ -433,12 +433,12 @@ pub fn get_single_str_from_tts(cx: @ExtCtxt, name: &str) -> @str { if tts.len() != 1 { - cx.span_fatal(sp, fmt!("%s takes 1 argument.", name)); + cx.span_fatal(sp, format!("{} takes 1 argument.", name)); } match tts[0] { ast::tt_tok(_, token::LIT_STR(ident)) => cx.str_of(ident), - _ => cx.span_fatal(sp, fmt!("%s requires a string.", name)), + _ => cx.span_fatal(sp, format!("{} requires a string.", name)), } } @@ -539,11 +539,11 @@ impl <K: Eq + Hash + IterBytes + 'static, V: 'static> MapChain<K,V>{ // names? I think not. // delaying implementing this.... pub fn each_key (&self, _f: &fn (&K)->bool) { - fail!("unimplemented 2013-02-15T10:01"); + fail2!("unimplemented 2013-02-15T10:01"); } pub fn each_value (&self, _f: &fn (&V) -> bool) { - fail!("unimplemented 2013-02-15T10:02"); + fail2!("unimplemented 2013-02-15T10:02"); } // Returns a copy of the value that the name maps to. @@ -586,7 +586,7 @@ impl <K: Eq + Hash + IterBytes + 'static, V: 'static> MapChain<K,V>{ if satisfies_pred(map,&n,pred) { map.insert(key,ext); } else { - fail!(~"expected map chain containing satisfying frame") + fail2!("expected map chain containing satisfying frame") } }, ConsMapChain (~ref mut map, rest) => { diff --git a/src/libsyntax/ext/deriving/clone.rs b/src/libsyntax/ext/deriving/clone.rs index 9ef995b0d57..5b107a49175 100644 --- a/src/libsyntax/ext/deriving/clone.rs +++ b/src/libsyntax/ext/deriving/clone.rs @@ -86,10 +86,10 @@ fn cs_clone( all_fields = af; }, EnumNonMatching(*) => cx.span_bug(span, - fmt!("Non-matching enum variants in `deriving(%s)`", + format!("Non-matching enum variants in `deriving({})`", name)), StaticEnum(*) | StaticStruct(*) => cx.span_bug(span, - fmt!("Static method in `deriving(%s)`", + format!("Static method in `deriving({})`", name)) } @@ -105,7 +105,7 @@ fn cs_clone( let ident = match o_id { Some(i) => i, None => cx.span_bug(span, - fmt!("unnamed field in normal struct in `deriving(%s)`", + format!("unnamed field in normal struct in `deriving({})`", name)) }; cx.field_imm(span, ident, subcall(self_f)) diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs index 66cd2d511a8..91fe71c5414 100644 --- a/src/libsyntax/ext/deriving/decodable.rs +++ b/src/libsyntax/ext/deriving/decodable.rs @@ -84,7 +84,7 @@ fn decodable_substructure(cx: @ExtCtxt, span: Span, } else { let mut fields = vec::with_capacity(n); for i in range(0, n) { - fields.push(getarg(fmt!("_field%u", i).to_managed(), i)); + fields.push(getarg(format!("_field{}", i).to_managed(), i)); } cx.expr_call_ident(span, substr.type_ident, fields) } diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs index 99b2359232c..d1c436c045d 100644 --- a/src/libsyntax/ext/deriving/encodable.rs +++ b/src/libsyntax/ext/deriving/encodable.rs @@ -125,7 +125,7 @@ fn encodable_substructure(cx: @ExtCtxt, span: Span, for (i, f) in fields.iter().enumerate() { let (name, val) = match *f { (Some(id), e, _) => (cx.str_of(id), e), - (None, e, _) => (fmt!("_field%u", i).to_managed(), e) + (None, e, _) => (format!("_field{}", i).to_managed(), e) }; let enc = cx.expr_method_call(span, val, encode, ~[blkencoder]); let lambda = cx.lambda_expr_1(span, enc, blkarg); diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index 646b65d080b..f5e45eec7e0 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -487,7 +487,7 @@ impl<'self> MethodDef<'self> { for (i, ty) in self.args.iter().enumerate() { let ast_ty = ty.to_ty(cx, span, type_ident, generics); - let ident = cx.ident_of(fmt!("__arg_%u", i)); + let ident = cx.ident_of(format!("__arg_{}", i)); arg_tys.push((ident, ast_ty)); let arg_expr = cx.expr_ident(span, ident); @@ -582,7 +582,8 @@ impl<'self> MethodDef<'self> { for i in range(0u, self_args.len()) { let (pat, ident_expr) = create_struct_pattern(cx, span, type_ident, struct_def, - fmt!("__self_%u", i), ast::MutImmutable); + format!("__self_{}", i), + ast::MutImmutable); patterns.push(pat); raw_fields.push(ident_expr); } @@ -767,7 +768,7 @@ impl<'self> MethodDef<'self> { let current_match_str = if match_count == 0 { ~"__self" } else { - fmt!("__arg_%u", match_count) + format!("__arg_{}", match_count) }; let mut arms = ~[]; @@ -948,7 +949,7 @@ fn create_struct_pattern(cx: @ExtCtxt, } }; let path = cx.path_ident(span, - cx.ident_of(fmt!("%s_%u", prefix, i))); + cx.ident_of(format!("{}_{}", prefix, i))); paths.push(path.clone()); ident_expr.push((opt_id, cx.expr_path(path))); } @@ -993,7 +994,7 @@ fn create_enum_variant_pattern(cx: @ExtCtxt, let mut ident_expr = ~[]; for i in range(0u, variant_args.len()) { let path = cx.path_ident(span, - cx.ident_of(fmt!("%s_%u", prefix, i))); + cx.ident_of(format!("{}_{}", prefix, i))); paths.push(path.clone()); ident_expr.push((None, cx.expr_path(path))); diff --git a/src/libsyntax/ext/deriving/mod.rs b/src/libsyntax/ext/deriving/mod.rs index dfd4f79cd9e..a428c6704f9 100644 --- a/src/libsyntax/ext/deriving/mod.rs +++ b/src/libsyntax/ext/deriving/mod.rs @@ -101,8 +101,8 @@ pub fn expand_meta_deriving(cx: @ExtCtxt, "Default" => expand!(default::expand_deriving_default), ref tname => { - cx.span_err(titem.span, fmt!("unknown \ - `deriving` trait: `%s`", *tname)); + cx.span_err(titem.span, format!("unknown \ + `deriving` trait: `{}`", *tname)); in_items } } diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs index e97af9cbfb1..63a45b06e16 100644 --- a/src/libsyntax/ext/env.rs +++ b/src/libsyntax/ext/env.rs @@ -43,7 +43,7 @@ pub fn expand_env(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) let var = expr_to_str(cx, exprs[0], "expected string literal"); let msg = match exprs.len() { - 1 => fmt!("Environment variable %s not defined", var).to_managed(), + 1 => format!("Environment variable {} not defined", var).to_managed(), 2 => expr_to_str(cx, exprs[1], "expected string literal"), _ => cx.span_fatal(sp, "env! takes 1 or 2 arguments") }; diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 697df52513d..e8307bf5786 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -51,7 +51,7 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv, if (pth.segments.len() > 1u) { cx.span_fatal( pth.span, - fmt!("expected macro name without module \ + format!("expected macro name without module \ separators")); } let extname = &pth.segments[0].identifier; @@ -61,7 +61,7 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv, None => { cx.span_fatal( pth.span, - fmt!("macro undefined: '%s'", extnamestr)) + format!("macro undefined: '{}'", extnamestr)) } Some(@SE(NormalTT(expandfun, exp_span))) => { cx.bt_push(ExpnInfo { @@ -92,8 +92,8 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv, _ => { cx.span_fatal( pth.span, - fmt!( - "non-expr macro in expr pos: %s", + format!( + "non-expr macro in expr pos: {}", extnamestr ) ) @@ -119,7 +119,7 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv, _ => { cx.span_fatal( pth.span, - fmt!("'%s' is not a tt-style macro", extnamestr) + format!("'{}' is not a tt-style macro", extnamestr) ) } } @@ -353,13 +353,13 @@ pub fn expand_item_mac(extsbox: @mut SyntaxEnv, let fm = fresh_mark(); let expanded = match (*extsbox).find(&extname.name) { None => cx.span_fatal(pth.span, - fmt!("macro undefined: '%s!'", extnamestr)), + format!("macro undefined: '{}!'", extnamestr)), Some(@SE(NormalTT(expander, span))) => { if it.ident.name != parse::token::special_idents::invalid.name { cx.span_fatal(pth.span, - fmt!("macro %s! expects no ident argument, \ - given '%s'", extnamestr, + format!("macro {}! expects no ident argument, \ + given '{}'", extnamestr, ident_to_str(&it.ident))); } cx.bt_push(ExpnInfo { @@ -377,7 +377,7 @@ pub fn expand_item_mac(extsbox: @mut SyntaxEnv, Some(@SE(IdentTT(expander, span))) => { if it.ident.name == parse::token::special_idents::invalid.name { cx.span_fatal(pth.span, - fmt!("macro %s! expects an ident argument", + format!("macro {}! expects an ident argument", extnamestr)); } cx.bt_push(ExpnInfo { @@ -393,7 +393,7 @@ pub fn expand_item_mac(extsbox: @mut SyntaxEnv, expander.expand(cx, it.span, it.ident, marked_tts, marked_ctxt) } _ => cx.span_fatal( - it.span, fmt!("%s! is not legal in item position", extnamestr)) + it.span, format!("{}! is not legal in item position", extnamestr)) }; let maybe_it = match expanded { @@ -402,7 +402,7 @@ pub fn expand_item_mac(extsbox: @mut SyntaxEnv, .and_then(|i| fld.fold_item(i)) } MRExpr(_) => { - cx.span_fatal(pth.span, fmt!("expr macro in item position: %s", extnamestr)) + cx.span_fatal(pth.span, format!("expr macro in item position: {}", extnamestr)) } MRAny(any_macro) => { any_macro.make_item() @@ -429,8 +429,8 @@ fn insert_macro(exts: SyntaxEnv, name: ast::Name, transformer: @Transformer) { match t { &@BlockInfo(BlockInfo {macros_escape:false,_}) => true, &@BlockInfo(BlockInfo {_}) => false, - _ => fail!(fmt!("special identifier %? was bound to a non-BlockInfo", - special_block_name)) + _ => fail2!("special identifier {:?} was bound to a non-BlockInfo", + special_block_name) } }; exts.insert_into_frame(name,transformer,intern(special_block_name), @@ -463,7 +463,7 @@ pub fn expand_stmt(extsbox: @mut SyntaxEnv, let extnamestr = ident_to_str(extname); let fully_expanded: @ast::Stmt = match (*extsbox).find(&extname.name) { None => { - cx.span_fatal(pth.span, fmt!("macro undefined: '%s'", extnamestr)) + cx.span_fatal(pth.span, format!("macro undefined: '{}'", extnamestr)) } Some(@SE(NormalTT(expandfun, exp_span))) => { @@ -496,7 +496,7 @@ pub fn expand_stmt(extsbox: @mut SyntaxEnv, MRAny(any_macro) => any_macro.make_stmt(), _ => cx.span_fatal( pth.span, - fmt!("non-stmt macro in stmt pos: %s", extnamestr)) + format!("non-stmt macro in stmt pos: {}", extnamestr)) }; let marked_after = mark_stmt(expanded,fm); @@ -521,7 +521,7 @@ pub fn expand_stmt(extsbox: @mut SyntaxEnv, _ => { cx.span_fatal(pth.span, - fmt!("'%s' is not a tt-style macro", extnamestr)) + format!("'{}' is not a tt-style macro", extnamestr)) } }; @@ -741,7 +741,7 @@ pub fn expand_block_elts(exts: SyntaxEnv, b: &Block, fld: &MacroExpander) fn mustbesome<T>(val : Option<T>) -> T { match val { Some(v) => v, - None => fail!("rename_fold returned None") + None => fail2!("rename_fold returned None") } } @@ -749,8 +749,8 @@ fn mustbesome<T>(val : Option<T>) -> T { fn get_block_info(exts : SyntaxEnv) -> BlockInfo { match exts.find_in_topmost_frame(&intern(special_block_name)) { Some(@BlockInfo(bi)) => bi, - _ => fail!(fmt!("special identifier %? was bound to a non-BlockInfo", - @" block")) + _ => fail2!("special identifier {:?} was bound to a non-BlockInfo", + @" block") } } @@ -782,7 +782,7 @@ pub fn renames_to_fold(renames: @mut ~[(ast::Ident,ast::Name)]) -> @ast_fold { fn apply_pending_renames(folder : @ast_fold, stmt : ast::Stmt) -> @ast::Stmt { match folder.fold_stmt(&stmt) { Some(s) => s, - None => fail!(fmt!("renaming of stmt produced None")) + None => fail2!("renaming of stmt produced None") } } @@ -813,7 +813,7 @@ pub fn std_macros() -> @str { mod fmt_extension { #[macro_escape]; - macro_rules! fmt(($($arg:tt)*) => (oldfmt!($($arg)*))) + macro_rules! fmt(($($arg:tt)*) => (oldformat!($($arg)*))) macro_rules! log( ($lvl:expr, $arg:expr) => ({ @@ -821,7 +821,7 @@ pub fn std_macros() -> @str { if lvl <= __log_level() { format_args!(|args| { ::std::logging::log(lvl, args) - }, \"{}\", fmt!(\"%?\", $arg)) + }, \"{}\", format!(\"{:?}\", $arg)) } }); ($lvl:expr, $($arg:expr),+) => ({ @@ -829,7 +829,7 @@ pub fn std_macros() -> @str { if lvl <= __log_level() { format_args!(|args| { ::std::logging::log(lvl, args) - }, \"{}\", fmt!($($arg),+)) + }, \"{}\", format!($($arg),+)) } }) ) @@ -842,13 +842,13 @@ pub fn std_macros() -> @str { macro_rules! fail( () => ( - fail!(\"explicit failure\") + fail2!(\"explicit failure\") ); ($msg:expr) => ( ::std::sys::FailWithCause::fail_with($msg, file!(), line!()) ); ($( $arg:expr ),+) => ( - ::std::sys::FailWithCause::fail_with(fmt!( $($arg),+ ), file!(), line!()) + ::std::sys::FailWithCause::fail_with(format!( $($arg),+ ), file!(), line!()) ) ) } @@ -896,7 +896,7 @@ pub fn std_macros() -> @str { }; ($cond:expr, $( $arg:expr ),+) => { if !$cond { - ::std::sys::FailWithCause::fail_with(fmt!( $($arg),+ ), file!(), line!()) + ::std::sys::FailWithCause::fail_with(format!( $($arg),+ ), file!(), line!()) } } ) @@ -1164,7 +1164,7 @@ pub fn inject_std_macros(parse_sess: @mut parse::ParseSess, ~[], parse_sess) { Some(item) => item, - None => fail!("expected core macros to parse correctly") + None => fail2!("expected core macros to parse correctly") }; let injector = @Injector { @@ -1422,16 +1422,16 @@ mod test { use util::parser_testing::{string_to_pat, string_to_tts, strs_to_idents}; use visit; - // make sure that fail! is present + // make sure that fail2! is present #[test] fn fail_exists_test () { - let src = @"fn main() { fail!(\"something appropriately gloomy\");}"; + let src = @"fn main() { fail2!(\"something appropriately gloomy\");}"; let sess = parse::new_parse_sess(None); let crate_ast = parse::parse_crate_from_source_str( @"<test>", src, ~[],sess); let crate_ast = inject_std_macros(sess, ~[], crate_ast); - // don't bother with striping, doesn't affect fail!. + // don't bother with striping, doesn't affect fail2!. expand_crate(sess,~[],crate_ast); } @@ -1489,7 +1489,7 @@ mod test { cfg,~[],sess); match item_ast { Some(_) => (), // success - None => fail!("expected this to parse") + None => fail2!("expected this to parse") } } @@ -1528,7 +1528,7 @@ mod test { let marked_once_ctxt = match marked_once[0] { ast::tt_tok(_,token::IDENT(id,_)) => id.ctxt, - _ => fail!(fmt!("unexpected shape for marked tts: %?",marked_once[0])) + _ => fail2!(format!("unexpected shape for marked tts: {:?}",marked_once[0])) }; assert_eq!(mtwt_marksof(marked_once_ctxt,invalid_name),~[fm]); let remarked = mtwt_cancel_outer_mark(marked_once,marked_once_ctxt); @@ -1536,7 +1536,7 @@ mod test { match remarked[0] { ast::tt_tok(_,token::IDENT(id,_)) => assert_eq!(mtwt_marksof(id.ctxt,invalid_name),~[]), - _ => fail!(fmt!("unexpected shape for marked tts: %?",remarked[0])) + _ => fail2!(format!("unexpected shape for marked tts: {:?}",remarked[0])) } } @@ -1583,7 +1583,7 @@ mod test { //fn expand_and_resolve(crate_str: @str) -> ast::crate { //let expanded_ast = expand_crate_str(crate_str); - // std::io::println(fmt!("expanded: %?\n",expanded_ast)); + // std::io::println(format!("expanded: {:?}\n",expanded_ast)); //mtwt_resolve_crate(expanded_ast) //} //fn expand_and_resolve_and_pretty_print (crate_str : @str) -> ~str { @@ -1693,8 +1693,8 @@ mod test { invalid_name); if (!(varref_name==binding_name)){ std::io::println("uh oh, should match but doesn't:"); - std::io::println(fmt!("varref: %?",varref)); - std::io::println(fmt!("binding: %?", bindings[binding_idx])); + std::io::println(format!("varref: {:?}",varref)); + std::io::println(format!("binding: {:?}", bindings[binding_idx])); ast_util::display_sctable(get_sctable()); } assert_eq!(varref_name,binding_name); @@ -1712,12 +1712,12 @@ mod test { println!("text of test case: \"{}\"", teststr); println!(""); println!("uh oh, matches but shouldn't:"); - std::io::println(fmt!("varref: %?",varref)); + std::io::println(format!("varref: {:?}",varref)); // good lord, you can't make a path with 0 segments, can you? println!("varref's first segment's uint: {}, and string: \"{}\"", varref.segments[0].identifier.name, ident_to_str(&varref.segments[0].identifier)); - std::io::println(fmt!("binding: %?", bindings[binding_idx])); + std::io::println(format!("binding: {:?}", bindings[binding_idx])); ast_util::display_sctable(get_sctable()); } assert!(!fail); @@ -1727,7 +1727,7 @@ mod test { } #[test] fn fmt_in_macro_used_inside_module_macro() { - let crate_str = @"macro_rules! fmt_wrap(($b:expr)=>(fmt!(\"left: %?\", $b))) + let crate_str = @"macro_rules! fmt_wrap(($b:expr)=>($b.to_str())) macro_rules! foo_module (() => (mod generated { fn a() { let xx = 147; fmt_wrap!(xx);}})) foo_module!() "; @@ -1739,7 +1739,7 @@ foo_module!() bindings.iter().filter(|b|{@"xx" == (ident_to_str(*b))}).collect(); let cxbind = match cxbinds { [b] => b, - _ => fail!("expected just one binding for ext_cx") + _ => fail2!("expected just one binding for ext_cx") }; let resolved_binding = mtwt_resolve(*cxbind); // find all the xx varrefs: @@ -1751,15 +1751,16 @@ foo_module!() }).enumerate() { if (mtwt_resolve(v.segments[0].identifier) != resolved_binding) { std::io::println("uh oh, xx binding didn't match xx varref:"); - std::io::println(fmt!("this is xx varref # %?",idx)); - std::io::println(fmt!("binding: %?",cxbind)); - std::io::println(fmt!("resolves to: %?",resolved_binding)); - std::io::println(fmt!("varref: %?",v.segments[0].identifier)); - std::io::println(fmt!("resolves to: %?",mtwt_resolve(v.segments[0].identifier))); + std::io::println(format!("this is xx varref \\# {:?}",idx)); + std::io::println(format!("binding: {:?}",cxbind)); + std::io::println(format!("resolves to: {:?}",resolved_binding)); + std::io::println(format!("varref: {:?}",v.segments[0].identifier)); + std::io::println(format!("resolves to: {:?}", + mtwt_resolve(v.segments[0].identifier))); let table = get_sctable(); std::io::println("SC table:"); for (idx,val) in table.table.iter().enumerate() { - std::io::println(fmt!("%4u : %?",idx,val)); + std::io::println(format!("{:4u} : {:?}",idx,val)); } } assert_eq!(mtwt_resolve(v.segments[0].identifier),resolved_binding); diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index d48fa03c0ef..cd364e7ad64 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -34,7 +34,7 @@ pub fn expand_syntax_ext(cx: @ExtCtxt, 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: %s", fmt); + debug2!("Format string: {}", fmt); fn parse_fmt_err_(cx: @ExtCtxt, sp: Span, msg: &str) -> ! { cx.span_fatal(sp, msg); } @@ -198,53 +198,53 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: Span, cx.expr_mut_addr_of(arg.span, buf)); } fn log_conv(c: &Conv) { - debug!("Building conversion:"); + debug2!("Building conversion:"); match c.param { - Some(p) => { debug!("param: %s", p.to_str()); } - _ => debug!("param: none") + Some(p) => { debug2!("param: {}", p.to_str()); } + _ => debug2!("param: none") } for f in c.flags.iter() { match *f { - FlagLeftJustify => debug!("flag: left justify"), - FlagLeftZeroPad => debug!("flag: left zero pad"), - FlagSpaceForSign => debug!("flag: left space pad"), - FlagSignAlways => debug!("flag: sign always"), - FlagAlternate => debug!("flag: alternate") + FlagLeftJustify => debug2!("flag: left justify"), + FlagLeftZeroPad => debug2!("flag: left zero pad"), + FlagSpaceForSign => debug2!("flag: left space pad"), + FlagSignAlways => debug2!("flag: sign always"), + FlagAlternate => debug2!("flag: alternate") } } match c.width { CountIs(i) => - debug!("width: count is %s", i.to_str()), + debug2!("width: count is {}", 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") + debug2!("width: count is param {}", i.to_str()), + CountIsNextParam => debug2!("width: count is next param"), + CountImplied => debug2!("width: count is implied") } match c.precision { CountIs(i) => - debug!("prec: count is %s", i.to_str()), + debug2!("prec: count is {}", 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") + debug2!("prec: count is param {}", i.to_str()), + CountIsNextParam => debug2!("prec: count is next param"), + CountImplied => debug2!("prec: count is implied") } match c.ty { - TyBool => debug!("type: bool"), - TyStr => debug!("type: str"), - TyChar => debug!("type: char"), + TyBool => debug2!("type: bool"), + TyStr => debug2!("type: str"), + TyChar => debug2!("type: char"), TyInt(s) => match s { - Signed => debug!("type: signed"), - Unsigned => debug!("type: unsigned") + Signed => debug2!("type: signed"), + Unsigned => debug2!("type: unsigned") }, - TyBits => debug!("type: bits"), + TyBits => debug2!("type: bits"), TyHex(cs) => match cs { - CaseUpper => debug!("type: uhex"), - CaseLower => debug!("type: lhex"), + CaseUpper => debug2!("type: uhex"), + CaseLower => debug2!("type: lhex"), }, - TyOctal => debug!("type: octal"), - TyFloat => debug!("type: float"), - TyPointer => debug!("type: pointer"), - TyPoly => debug!("type: poly") + TyOctal => debug2!("type: octal"), + TyFloat => debug2!("type: float"), + TyPointer => debug2!("type: pointer"), + TyPoly => debug2!("type: poly") } } @@ -319,7 +319,7 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: Span, let expected_nargs = n + 1u; // n conversions + the fmt string if expected_nargs < nargs { cx.span_fatal - (sp, fmt!("too many arguments to fmt!. found %u, expected %u", + (sp, format!("too many arguments to fmt!. found {}, expected {}", nargs, expected_nargs)); } diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index ef3879f56ae..a9e5318db40 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -51,7 +51,7 @@ struct Context { impl Context { /// Parses the arguments from the given list of tokens, returning None if - /// there's a parse error so we can continue parsing other fmt! expressions. + /// there's a parse error so we can continue parsing other format! expressions. fn parse_args(&mut self, sp: Span, tts: &[ast::token_tree]) -> (@ast::Expr, Option<@ast::Expr>) { let p = rsparse::new_parser_from_tts(self.ecx.parse_sess(), @@ -92,8 +92,8 @@ impl Context { } _ => { self.ecx.span_err(*p.span, - fmt!("expected ident for named \ - argument, but found `%s`", + format!("expected ident for named \ + argument, but found `{}`", p.this_token_to_str())); return (extra, None); } @@ -104,8 +104,8 @@ impl Context { match self.names.find(&name) { None => {} Some(prev) => { - self.ecx.span_err(e.span, fmt!("duplicate argument \ - named `%s`", name)); + self.ecx.span_err(e.span, format!("duplicate argument \ + named `{}`", name)); self.ecx.parse_sess.span_diagnostic.span_note( prev.span, "previously here"); loop @@ -207,13 +207,13 @@ impl Context { match arm.selector { Left(name) => { self.ecx.span_err(self.fmtsp, - fmt!("duplicate selector \ - `%?`", name)); + format!("duplicate selector \ + `{:?}`", name)); } Right(idx) => { self.ecx.span_err(self.fmtsp, - fmt!("duplicate selector \ - `=%u`", idx)); + format!("duplicate selector \ + `={}`", idx)); } } } @@ -227,7 +227,7 @@ impl Context { for arm in arms.iter() { if !seen_cases.insert(arm.selector) { self.ecx.span_err(self.fmtsp, - fmt!("duplicate selector `%s`", + format!("duplicate selector `{}`", arm.selector)); } else if arm.selector == "" { self.ecx.span_err(self.fmtsp, @@ -245,8 +245,8 @@ impl Context { match arg { Left(arg) => { if arg < 0 || self.args.len() <= arg { - let msg = fmt!("invalid reference to argument `%u` (there \ - are %u arguments)", arg, self.args.len()); + let msg = format!("invalid reference to argument `{}` (there \ + are {} arguments)", arg, self.args.len()); self.ecx.span_err(self.fmtsp, msg); return; } @@ -260,7 +260,7 @@ impl Context { let span = match self.names.find(&name) { Some(e) => e.span, None => { - let msg = fmt!("there is no argument named `%s`", name); + let msg = format!("there is no argument named `{}`", name); self.ecx.span_err(self.fmtsp, msg); return; } @@ -298,20 +298,20 @@ impl Context { match (cur, ty) { (Known(cur), Known(ty)) => { self.ecx.span_err(sp, - fmt!("argument redeclared with type `%s` when \ - it was previously `%s`", ty, cur)); + format!("argument redeclared with type `{}` when \ + it was previously `{}`", ty, cur)); } (Known(cur), _) => { self.ecx.span_err(sp, - fmt!("argument used to format with `%s` was \ - attempted to not be used for formatting", - cur)); + format!("argument used to format with `{}` was \ + attempted to not be used for formatting", + cur)); } (_, Known(ty)) => { self.ecx.span_err(sp, - fmt!("argument previously used as a format \ - argument attempted to be used as `%s`", - ty)); + format!("argument previously used as a format \ + argument attempted to be used as `{}`", + ty)); } (_, _) => { self.ecx.span_err(sp, "argument declared with multiple formats"); @@ -405,7 +405,7 @@ impl Context { }).collect(); let (lr, selarg) = match arm.selector { Left(t) => { - let p = ctpath(fmt!("%?", t)); + let p = ctpath(format!("{:?}", t)); let p = self.ecx.path_global(sp, p); (self.ecx.ident_of("Left"), self.ecx.expr_path(p)) @@ -444,7 +444,7 @@ impl Context { ~[] ), None); let st = ast::item_static(ty, ast::MutImmutable, method); - let static_name = self.ecx.ident_of(fmt!("__static_method_%u", + let static_name = self.ecx.ident_of(format!("__static_method_{}", self.method_statics.len())); // Flag these statics as `address_insignificant` so LLVM can // merge duplicate globals as much as possible (which we're @@ -538,7 +538,7 @@ impl Context { } } - /// Actually builds the expression which the ifmt! block will be expanded + /// Actually builds the expression which the iformat! block will be expanded /// to fn to_expr(&self, extra: @ast::Expr) -> @ast::Expr { let mut lets = ~[]; @@ -584,13 +584,13 @@ impl Context { // foo(bar(&1)) // the lifetime of `1` doesn't outlast the call to `bar`, so it's not // vald for the call to `foo`. To work around this all arguments to the - // fmt! string are shoved into locals. Furthermore, we shove the address + // format! string are shoved into locals. Furthermore, we shove the address // of each variable because we don't want to move out of the arguments // passed to this function. for (i, &e) in self.args.iter().enumerate() { if self.arg_types[i].is_none() { loop } // error already generated - let name = self.ecx.ident_of(fmt!("__arg%u", i)); + let name = self.ecx.ident_of(format!("__arg{}", i)); let e = self.ecx.expr_addr_of(e.span, e); lets.push(self.ecx.stmt_let(e.span, false, name, e)); locals.push(self.format_arg(e.span, Left(i), @@ -599,7 +599,7 @@ impl Context { for (&name, &e) in self.names.iter() { if !self.name_types.contains_key(&name) { loop } - let lname = self.ecx.ident_of(fmt!("__arg%s", name)); + let lname = self.ecx.ident_of(format!("__arg{}", name)); let e = self.ecx.expr_addr_of(e.span, e); lets.push(self.ecx.stmt_let(e.span, false, lname, e)); names[*self.name_positions.get(&name)] = @@ -662,8 +662,8 @@ impl Context { "x" => "LowerHex", "X" => "UpperHex", _ => { - self.ecx.span_err(sp, fmt!("unknown format trait \ - `%s`", tyname)); + self.ecx.span_err(sp, format!("unknown format trait \ + `{}`", tyname)); "Dummy" } } diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 6527b083cc1..24a5f9d5e3c 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -255,8 +255,8 @@ pub mod rt { match res { Some(ast) => ast, None => { - error!("Parse error with ```\n%s\n```", s); - fail!() + error2!("Parse error with ```\n{}\n```", s); + fail2!() } } } @@ -484,7 +484,7 @@ fn mk_token(cx: @ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr { ~[mk_ident(cx, sp, ident)]); } - INTERPOLATED(_) => fail!("quote! with interpolated token"), + INTERPOLATED(_) => fail2!("quote! with interpolated token"), _ => () } @@ -522,7 +522,7 @@ fn mk_token(cx: @ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr { DOLLAR => "DOLLAR", UNDERSCORE => "UNDERSCORE", EOF => "EOF", - _ => fail!() + _ => fail2!() }; cx.expr_ident(sp, id_ext(name)) } @@ -547,7 +547,7 @@ fn mk_tt(cx: @ExtCtxt, sp: Span, tt: &ast::token_tree) } ast::tt_delim(ref tts) => mk_tts(cx, sp, **tts), - ast::tt_seq(*) => fail!("tt_seq in quote!"), + ast::tt_seq(*) => fail2!("tt_seq in quote!"), ast::tt_nonterminal(sp, ident) => { diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index aa4183837e3..7db64feb809 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -122,7 +122,7 @@ pub struct MatcherPos { pub fn copy_up(mpu: &matcher_pos_up) -> ~MatcherPos { match *mpu { matcher_pos_up(Some(ref mp)) => (*mp).clone(), - _ => fail!() + _ => fail2!() } } @@ -384,14 +384,14 @@ pub fn parse( let nts = bb_eis.map(|ei| { match ei.elts[ei.idx].node { match_nonterminal(ref bind,ref name,_) => { - fmt!("%s ('%s')", ident_to_str(name), + format!("{} ('{}')", ident_to_str(name), ident_to_str(bind)) } - _ => fail!() + _ => fail2!() } }).connect(" or "); - return error(sp, fmt!( + return error(sp, format!( "Local ambiguity: multiple parsing options: \ - built-in NTs %s or %u other options.", + built-in NTs {} or {} other options.", nts, next_eis.len())); } else if (bb_eis.len() == 0u && next_eis.len() == 0u) { return failure(sp, ~"No rules expected the token: " @@ -412,7 +412,7 @@ pub fn parse( parse_nt(&rust_parser, ident_to_str(name)))); ei.idx += 1u; } - _ => fail!() + _ => fail2!() } cur_eis.push(ei); diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 8a858f3d985..f8d48d00db9 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -117,7 +117,7 @@ fn lookup_cur_matched(r: &mut TtReader, name: Ident) -> @named_match { match r.interpolations.find_copy(&name) { Some(s) => lookup_cur_matched_by_matched(r, s), None => { - r.sp_diag.span_fatal(r.cur_span, fmt!("unknown macro variable `%s`", + r.sp_diag.span_fatal(r.cur_span, format!("unknown macro variable `{}`", ident_to_str(&name))); } } @@ -142,9 +142,9 @@ fn lockstep_iter_size(t: &token_tree, r: &mut TtReader) -> lis { lis_constraint(r_len, ref r_id) => { let l_n = ident_to_str(l_id); let r_n = ident_to_str(r_id); - lis_contradiction(fmt!("Inconsistent lockstep iteration: \ - '%s' has %u items, but '%s' has %u", - l_n, l_len, r_n, r_len)) + lis_contradiction(format!("Inconsistent lockstep iteration: \ + '{}' has {} items, but '{}' has {}", + l_n, l_len, r_n, r_len)) } } } @@ -294,7 +294,7 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan { matched_seq(*) => { r.sp_diag.span_fatal( r.cur_span, /* blame the macro writer */ - fmt!("variable '%s' is still repeating at this depth", + format!("variable '{}' is still repeating at this depth", ident_to_str(&ident))); } } |
