Skip to content

Commit 1b80558

Browse files
committed
rustc: Remove usage of fmt!
1 parent af3b132 commit 1b80558

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+1743
-1739
lines changed

src/librustc/back/link.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,13 @@ pub mod jit {
131131
for cratepath in r.iter() {
132132
let path = cratepath.to_str();
133133

134-
debug!("linking: %s", path);
134+
debug2!("linking: {}", path);
135135

136136
do path.with_c_str |buf_t| {
137137
if !llvm::LLVMRustLoadCrate(manager, buf_t) {
138138
llvm_err(sess, ~"Could not link");
139139
}
140-
debug!("linked: %s", path);
140+
debug2!("linked: {}", path);
141141
}
142142
}
143143

@@ -303,7 +303,7 @@ pub mod write {
303303
for pass in sess.opts.custom_passes.iter() {
304304
do pass.with_c_str |s| {
305305
if !llvm::LLVMRustAddPass(mpm, s) {
306-
sess.warn(fmt!("Unknown pass %s, ignoring", *pass));
306+
sess.warn(format!("Unknown pass {}, ignoring", *pass));
307307
}
308308
}
309309
}
@@ -381,9 +381,9 @@ pub mod write {
381381
let prog = run::process_output(cc_prog, cc_args);
382382

383383
if prog.status != 0 {
384-
sess.err(fmt!("building with `%s` failed with code %d",
384+
sess.err(format!("building with `{}` failed with code {}",
385385
cc_prog, prog.status));
386-
sess.note(fmt!("%s arguments: %s",
386+
sess.note(format!("{} arguments: {}",
387387
cc_prog, cc_args.connect(" ")));
388388
sess.note(str::from_utf8(prog.error + prog.output));
389389
sess.abort_if_errors();
@@ -554,7 +554,7 @@ pub fn build_link_meta(sess: Session,
554554
dep_hashes: ~[@str],
555555
pkg_id: Option<@str>) -> @str {
556556
fn len_and_str(s: &str) -> ~str {
557-
fmt!("%u_%s", s.len(), s)
557+
format!("{}_{}", s.len(), s)
558558
}
559559

560560
fn len_and_str_lit(l: ast::lit) -> ~str {
@@ -599,7 +599,7 @@ pub fn build_link_meta(sess: Session,
599599

600600
fn warn_missing(sess: Session, name: &str, default: &str) {
601601
if !*sess.building_library { return; }
602-
sess.warn(fmt!("missing crate link meta `%s`, using `%s` as default",
602+
sess.warn(format!("missing crate link meta `{}`, using `{}` as default",
603603
name, default));
604604
}
605605

@@ -612,7 +612,7 @@ pub fn build_link_meta(sess: Session,
612612
// filestem that returned an @str
613613
let name = session::expect(sess,
614614
output.filestem(),
615-
|| fmt!("output file name `%s` doesn't\
615+
|| format!("output file name `{}` doesn't\
616616
appear to have a stem",
617617
output.to_str())).to_managed();
618618
if name.is_empty() {
@@ -762,7 +762,7 @@ pub fn mangle(sess: Session, ss: path,
762762

763763
let push = |s: &str| {
764764
let sani = sanitize(s);
765-
n.push_str(fmt!("%u%s", sani.len(), sani));
765+
n.push_str(format!("{}{}", sani.len(), sani));
766766
};
767767

768768
// First, connect each component with <len, name> pairs.
@@ -874,7 +874,7 @@ pub fn output_dll_filename(os: session::Os, lm: LinkMeta) -> ~str {
874874
session::OsAndroid => (android::DLL_PREFIX, android::DLL_SUFFIX),
875875
session::OsFreebsd => (freebsd::DLL_PREFIX, freebsd::DLL_SUFFIX),
876876
};
877-
fmt!("%s%s-%s-%s%s", dll_prefix, lm.name, lm.extras_hash, lm.vers, dll_suffix)
877+
format!("{}{}-{}-{}{}", dll_prefix, lm.name, lm.extras_hash, lm.vers, dll_suffix)
878878
}
879879

880880
pub fn get_cc_prog(sess: Session) -> ~str {
@@ -890,7 +890,7 @@ pub fn get_cc_prog(sess: Session) -> ~str {
890890
session::OsAndroid =>
891891
match &sess.opts.android_cross_path {
892892
&Some(ref path) => {
893-
fmt!("%s/bin/arm-linux-androideabi-gcc", *path)
893+
format!("{}/bin/arm-linux-androideabi-gcc", *path)
894894
}
895895
&None => {
896896
sess.fatal("need Android NDK path for linking \
@@ -915,29 +915,29 @@ pub fn link_binary(sess: Session,
915915

916916
let output = if *sess.building_library {
917917
let long_libname = output_dll_filename(sess.targ_cfg.os, lm);
918-
debug!("link_meta.name: %s", lm.name);
919-
debug!("long_libname: %s", long_libname);
920-
debug!("out_filename: %s", out_filename.to_str());
921-
debug!("dirname(out_filename): %s", out_filename.dir_path().to_str());
918+
debug2!("link_meta.name: {}", lm.name);
919+
debug2!("long_libname: {}", long_libname);
920+
debug2!("out_filename: {}", out_filename.to_str());
921+
debug2!("dirname(out_filename): {}", out_filename.dir_path().to_str());
922922

923923
out_filename.dir_path().push(long_libname)
924924
} else {
925925
out_filename.clone()
926926
};
927927

928-
debug!("output: %s", output.to_str());
928+
debug2!("output: {}", output.to_str());
929929
let cc_args = link_args(sess, obj_filename, out_filename, lm);
930-
debug!("%s link args: %s", cc_prog, cc_args.connect(" "));
930+
debug2!("{} link args: {}", cc_prog, cc_args.connect(" "));
931931
if (sess.opts.debugging_opts & session::print_link_args) != 0 {
932-
io::println(fmt!("%s link args: %s", cc_prog, cc_args.connect(" ")));
932+
io::println(format!("{} link args: {}", cc_prog, cc_args.connect(" ")));
933933
}
934934

935935
// We run 'cc' here
936936
let prog = run::process_output(cc_prog, cc_args);
937937
if 0 != prog.status {
938-
sess.err(fmt!("linking with `%s` failed with code %d",
938+
sess.err(format!("linking with `{}` failed with code {}",
939939
cc_prog, prog.status));
940-
sess.note(fmt!("%s arguments: %s",
940+
sess.note(format!("{} arguments: {}",
941941
cc_prog, cc_args.connect(" ")));
942942
sess.note(str::from_utf8(prog.error + prog.output));
943943
sess.abort_if_errors();
@@ -951,7 +951,7 @@ pub fn link_binary(sess: Session,
951951
// Remove the temporary object file if we aren't saving temps
952952
if !sess.opts.save_temps {
953953
if ! os::remove_file(obj_filename) {
954-
sess.warn(fmt!("failed to delete object file `%s`",
954+
sess.warn(format!("failed to delete object file `{}`",
955955
obj_filename.to_str()));
956956
}
957957
}

src/librustc/back/rpath.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn get_rpath_flags(sess: session::Session, out_filename: &Path)
2929
return ~[];
3030
}
3131

32-
debug!("preparing the RPATH!");
32+
debug2!("preparing the RPATH!");
3333

3434
let sysroot = sess.filesearch.sysroot();
3535
let output = out_filename;
@@ -49,21 +49,21 @@ fn get_sysroot_absolute_rt_lib(sess: session::Session) -> Path {
4949
}
5050

5151
pub fn rpaths_to_flags(rpaths: &[Path]) -> ~[~str] {
52-
rpaths.iter().map(|rpath| fmt!("-Wl,-rpath,%s",rpath.to_str())).collect()
52+
rpaths.iter().map(|rpath| format!("-Wl,-rpath,{}",rpath.to_str())).collect()
5353
}
5454

5555
fn get_rpaths(os: session::Os,
5656
sysroot: &Path,
5757
output: &Path,
5858
libs: &[Path],
5959
target_triple: &str) -> ~[Path] {
60-
debug!("sysroot: %s", sysroot.to_str());
61-
debug!("output: %s", output.to_str());
62-
debug!("libs:");
60+
debug2!("sysroot: {}", sysroot.to_str());
61+
debug2!("output: {}", output.to_str());
62+
debug2!("libs:");
6363
for libpath in libs.iter() {
64-
debug!(" %s", libpath.to_str());
64+
debug2!(" {}", libpath.to_str());
6565
}
66-
debug!("target_triple: %s", target_triple);
66+
debug2!("target_triple: {}", target_triple);
6767

6868
// Use relative paths to the libraries. Binaries can be moved
6969
// as long as they maintain the relative relationship to the
@@ -78,9 +78,9 @@ fn get_rpaths(os: session::Os,
7878
let fallback_rpaths = ~[get_install_prefix_rpath(target_triple)];
7979

8080
fn log_rpaths(desc: &str, rpaths: &[Path]) {
81-
debug!("%s rpaths:", desc);
81+
debug2!("{} rpaths:", desc);
8282
for rpath in rpaths.iter() {
83-
debug!(" %s", rpath.to_str());
83+
debug2!(" {}", rpath.to_str());
8484
}
8585
}
8686

@@ -172,7 +172,7 @@ mod test {
172172
let res = get_install_prefix_rpath("triple");
173173
let d = Path(env!("CFG_PREFIX"))
174174
.push_rel(&Path("lib/rustc/triple/lib"));
175-
debug!("test_prefix_path: %s vs. %s",
175+
debug2!("test_prefix_path: {} vs. {}",
176176
res.to_str(),
177177
d.to_str());
178178
assert!(res.to_str().ends_with(d.to_str()));
@@ -233,7 +233,7 @@ mod test {
233233
#[test]
234234
fn test_get_absolute_rpath() {
235235
let res = get_absolute_rpath(&Path("lib/libstd.so"));
236-
debug!("test_get_absolute_rpath: %s vs. %s",
236+
debug2!("test_get_absolute_rpath: {} vs. {}",
237237
res.to_str(),
238238
os::make_absolute(&Path("lib")).to_str());
239239

src/librustc/driver/driver.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -386,33 +386,33 @@ pub fn phase_6_link_output(sess: Session,
386386

387387
pub fn stop_after_phase_3(sess: Session) -> bool {
388388
if sess.opts.no_trans {
389-
debug!("invoked with --no-trans, returning early from compile_input");
389+
debug2!("invoked with --no-trans, returning early from compile_input");
390390
return true;
391391
}
392392
return false;
393393
}
394394

395395
pub fn stop_after_phase_1(sess: Session) -> bool {
396396
if sess.opts.parse_only {
397-
debug!("invoked with --parse-only, returning early from compile_input");
397+
debug2!("invoked with --parse-only, returning early from compile_input");
398398
return true;
399399
}
400400
return false;
401401
}
402402

403403
pub fn stop_after_phase_5(sess: Session) -> bool {
404404
if sess.opts.output_type != link::output_type_exe {
405-
debug!("not building executable, returning early from compile_input");
405+
debug2!("not building executable, returning early from compile_input");
406406
return true;
407407
}
408408

409409
if sess.opts.is_static && *sess.building_library {
410-
debug!("building static library, returning early from compile_input");
410+
debug2!("building static library, returning early from compile_input");
411411
return true;
412412
}
413413

414414
if sess.opts.jit {
415-
debug!("running JIT, returning early from compile_input");
415+
debug2!("running JIT, returning early from compile_input");
416416
return true;
417417
}
418418
return false;
@@ -670,7 +670,7 @@ pub fn build_session_options(binary: @str,
670670
let lint_name = lint_name.replace("-", "_");
671671
match lint_dict.find_equiv(&lint_name) {
672672
None => {
673-
early_error(demitter, fmt!("unknown %s flag: %s",
673+
early_error(demitter, format!("unknown {} flag: {}",
674674
level_name, lint_name));
675675
}
676676
Some(lint) => {
@@ -690,7 +690,7 @@ pub fn build_session_options(binary: @str,
690690
if name == debug_flag { this_bit = bit; break; }
691691
}
692692
if this_bit == 0u {
693-
early_error(demitter, fmt!("unknown debug flag: %s", *debug_flag))
693+
early_error(demitter, format!("unknown debug flag: {}", *debug_flag))
694694
}
695695
debugging_opts |= this_bit;
696696
}
@@ -1033,7 +1033,7 @@ pub fn build_output_filenames(input: &input,
10331033

10341034
pub fn early_error(emitter: @diagnostic::Emitter, msg: ~str) -> ! {
10351035
emitter.emit(None, msg, diagnostic::fatal);
1036-
fail!();
1036+
fail2!();
10371037
}
10381038

10391039
pub fn list_metadata(sess: Session, path: &Path, out: @io::Writer) {
@@ -1058,7 +1058,7 @@ mod test {
10581058
let matches =
10591059
&match getopts([~"--test"], optgroups()) {
10601060
Ok(m) => m,
1061-
Err(f) => fail!("test_switch_implies_cfg_test: %s", f.to_err_msg())
1061+
Err(f) => fail2!("test_switch_implies_cfg_test: {}", f.to_err_msg())
10621062
};
10631063
let sessopts = build_session_options(
10641064
@"rustc",
@@ -1079,7 +1079,8 @@ mod test {
10791079
&match getopts([~"--test", ~"--cfg=test"], optgroups()) {
10801080
Ok(m) => m,
10811081
Err(f) => {
1082-
fail!("test_switch_implies_cfg_test_unless_cfg_test: %s", f.to_err_msg());
1082+
fail2!("test_switch_implies_cfg_test_unless_cfg_test: {}",
1083+
f.to_err_msg());
10831084
}
10841085
};
10851086
let sessopts = build_session_options(

src/librustc/driver/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ impl Session_ {
296296
// This exists to help with refactoring to eliminate impossible
297297
// cases later on
298298
pub fn impossible_case(&self, sp: Span, msg: &str) -> ! {
299-
self.span_bug(sp, fmt!("Impossible case reached: %s", msg));
299+
self.span_bug(sp, format!("Impossible case reached: {}", msg));
300300
}
301301
pub fn verbose(&self) -> bool { self.debugging_opt(verbose) }
302302
pub fn time_passes(&self) -> bool { self.debugging_opt(time_passes) }

src/librustc/front/test.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl fold::ast_fold for TestHarnessGenerator {
7878

7979
fn fold_item(&self, i: @ast::item) -> Option<@ast::item> {
8080
self.cx.path.push(i.ident);
81-
debug!("current path: %s",
81+
debug2!("current path: {}",
8282
ast_util::path_name_i(self.cx.path.clone()));
8383

8484
if is_test_fn(self.cx, i) || is_bench_fn(i) {
@@ -91,7 +91,7 @@ impl fold::ast_fold for TestHarnessGenerator {
9191
tests");
9292
}
9393
_ => {
94-
debug!("this is a test function");
94+
debug2!("this is a test function");
9595
let test = Test {
9696
span: i.span,
9797
path: self.cx.path.clone(),
@@ -100,7 +100,7 @@ impl fold::ast_fold for TestHarnessGenerator {
100100
should_fail: should_fail(i)
101101
};
102102
self.cx.testfns.push(test);
103-
// debug!("have %u test/bench functions",
103+
// debug2!("have {} test/bench functions",
104104
// cx.testfns.len());
105105
}
106106
}
@@ -327,7 +327,7 @@ fn mk_test_module(cx: &TestCtxt) -> @ast::item {
327327
span: dummy_sp(),
328328
};
329329

330-
debug!("Synthetic test module:\n%s\n",
330+
debug2!("Synthetic test module:\n{}\n",
331331
pprust::item_to_str(@item.clone(), cx.sess.intr()));
332332

333333
return @item;
@@ -381,7 +381,7 @@ fn is_extra(crate: &ast::Crate) -> bool {
381381
}
382382

383383
fn mk_test_descs(cx: &TestCtxt) -> @ast::Expr {
384-
debug!("building test vector from %u tests", cx.testfns.len());
384+
debug2!("building test vector from {} tests", cx.testfns.len());
385385
let mut descs = ~[];
386386
for test in cx.testfns.iter() {
387387
descs.push(mk_test_desc_and_fn_rec(cx, test));
@@ -404,7 +404,7 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> @ast::Expr {
404404
let span = test.span;
405405
let path = test.path.clone();
406406

407-
debug!("encoding %s", ast_util::path_name_i(path));
407+
debug2!("encoding {}", ast_util::path_name_i(path));
408408

409409
let name_lit: ast::lit =
410410
nospan(ast::lit_str(ast_util::path_name_i(path).to_managed()));

0 commit comments

Comments
 (0)