Skip to content

Commit da24c0d

Browse files
committed
rustpkg: Remove uses of fmt!
1 parent a7f19f3 commit da24c0d

14 files changed

+313
-305
lines changed

src/librustpkg/api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fn binary_is_fresh(path: &str, in_hash: &str) -> bool {
5252

5353
pub fn new_workcache_context(p: &Path) -> workcache::Context {
5454
let db_file = p.push("rustpkg_db.json"); // ??? probably wrong
55-
debug!("Workcache database file: %s", db_file.to_str());
55+
debug2!("Workcache database file: {}", db_file.to_str());
5656
let db = RWArc::new(Database::new(db_file));
5757
let lg = RWArc::new(Logger::new());
5858
let cfg = Arc::new(TreeMap::new());

src/librustpkg/context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl Context {
150150
/// rustpkg from a Rust target directory. This is part of a
151151
/// kludgy hack used to adjust the sysroot.
152152
pub fn in_target(sysroot: &Path) -> bool {
153-
debug!("Checking whether %s is in target", sysroot.to_str());
153+
debug2!("Checking whether {} is in target", sysroot.to_str());
154154
os::path_is_dir(&sysroot.pop().pop().push("rustc"))
155155
}
156156

@@ -214,8 +214,8 @@ pub fn flags_ok_for_cmd(flags: &RustcFlags,
214214
cfgs: &[~str],
215215
cmd: &str, user_supplied_opt_level: bool) -> bool {
216216
let complain = |s| {
217-
io::println(fmt!("The %s option can only be used with the build command:
218-
rustpkg [options..] build %s [package-ID]", s, s));
217+
println!("The {} option can only be used with the build command:
218+
rustpkg [options..] build {} [package-ID]", s, s);
219219
};
220220

221221
if flags.linker.is_some() && cmd != "build" && cmd != "install" {

src/librustpkg/installed_packages.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ pub fn list_installed_packages(f: &fn(&PkgId) -> bool) -> bool {
2828
let libfiles = os::list_dir(&p.push("lib"));
2929
for lib in libfiles.iter() {
3030
let lib = Path(*lib);
31-
debug!("Full name: %s", lib.to_str());
31+
debug2!("Full name: {}", lib.to_str());
3232
match has_library(&lib) {
3333
Some(basename) => {
34-
debug!("parent = %s, child = %s",
35-
p.push("lib").to_str(), lib.to_str());
34+
debug2!("parent = {}, child = {}",
35+
p.push("lib").to_str(), lib.to_str());
3636
let rel_p = p.push("lib/").get_relative_to(&lib);
37-
debug!("Rel: %s", rel_p.to_str());
37+
debug2!("Rel: {}", rel_p.to_str());
3838
let rel_path = rel_p.push(basename).to_str();
39-
debug!("Rel name: %s", rel_path);
39+
debug2!("Rel name: {}", rel_path);
4040
f(&PkgId::new(rel_path));
4141
}
4242
None => ()

src/librustpkg/package_id.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl PkgId {
6666
if path.components.len() < 1 {
6767
return cond.raise((path, ~"0-length pkgid"));
6868
}
69-
let short_name = path.filestem().expect(fmt!("Strange path! %s", s));
69+
let short_name = path.filestem().expect(format!("Strange path! {}", s));
7070

7171
let version = match given_version {
7272
Some(v) => v,
@@ -87,13 +87,13 @@ impl PkgId {
8787
}
8888

8989
pub fn hash(&self) -> ~str {
90-
fmt!("%s-%s-%s", self.path.to_str(),
91-
hash(self.path.to_str() + self.version.to_str()),
92-
self.version.to_str())
90+
format!("{}-{}-{}", self.path.to_str(),
91+
hash(self.path.to_str() + self.version.to_str()),
92+
self.version.to_str())
9393
}
9494

9595
pub fn short_name_with_version(&self) -> ~str {
96-
fmt!("%s%s", self.short_name, self.version.to_str())
96+
format!("{}{}", self.short_name, self.version.to_str())
9797
}
9898

9999
/// True if the ID has multiple components
@@ -112,7 +112,7 @@ impl PkgId {
112112
// binaries for this package (as opposed to the built ones,
113113
// which are per-crate).
114114
pub fn install_tag(&self) -> ~str {
115-
fmt!("install(%s)", self.to_str())
115+
format!("install({})", self.to_str())
116116
}
117117
}
118118

@@ -139,7 +139,7 @@ impl Iterator<(Path, Path)> for Prefixes {
139139
impl ToStr for PkgId {
140140
fn to_str(&self) -> ~str {
141141
// should probably use the filestem and not the whole path
142-
fmt!("%s-%s", self.path.to_str(), self.version.to_str())
142+
format!("{}-{}", self.path.to_str(), self.version.to_str())
143143
}
144144
}
145145

src/librustpkg/package_source.rs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ pub struct PkgSrc {
4343

4444
impl ToStr for PkgSrc {
4545
fn to_str(&self) -> ~str {
46-
fmt!("Package ID %s in start dir %s [workspace = %s]",
47-
self.id.to_str(),
48-
self.start_dir.to_str(), self.workspace.to_str())
46+
format!("Package ID {} in start dir {} [workspace = {}]",
47+
self.id.to_str(),
48+
self.start_dir.to_str(), self.workspace.to_str())
4949
}
5050
}
5151
condition! {
@@ -58,21 +58,21 @@ impl PkgSrc {
5858
pub fn new(workspace: Path, use_rust_path_hack: bool, id: PkgId) -> PkgSrc {
5959
use conditions::nonexistent_package::cond;
6060

61-
debug!("Checking package source for package ID %s, \
62-
workspace = %s use_rust_path_hack = %?",
61+
debug2!("Checking package source for package ID {}, \
62+
workspace = {} use_rust_path_hack = {:?}",
6363
id.to_str(), workspace.to_str(), use_rust_path_hack);
6464

6565
let mut to_try = ~[];
6666
if use_rust_path_hack {
6767
to_try.push(workspace.clone());
6868
} else {
69-
let result = workspace.push("src").push_rel(&id.path.pop()).push(fmt!("%s-%s",
69+
let result = workspace.push("src").push_rel(&id.path.pop()).push(format!("{}-{}",
7070
id.short_name, id.version.to_str()));
7171
to_try.push(result);
7272
to_try.push(workspace.push("src").push_rel(&id.path));
7373
}
7474

75-
debug!("Checking dirs: %?", to_try.map(|s| s.to_str()).connect(":"));
75+
debug2!("Checking dirs: {:?}", to_try.map(|s| s.to_str()).connect(":"));
7676

7777
let path = to_try.iter().find(|&d| os::path_exists(d));
7878

@@ -84,13 +84,13 @@ impl PkgSrc {
8484
for (prefix, suffix) in id.prefixes_iter() {
8585
let package_id = PkgId::new(prefix.to_str());
8686
let path = workspace.push("src").push_rel(&package_id.path);
87-
debug!("in loop: checking if %s is a directory", path.to_str());
87+
debug2!("in loop: checking if {} is a directory", path.to_str());
8888
if os::path_is_dir(&path) {
8989
let ps = PkgSrc::new(workspace.clone(),
9090
use_rust_path_hack,
9191
PkgId::new(prefix.to_str()));
92-
debug!("pkgsrc: Returning [%s|%s|%s]", workspace.to_str(),
93-
ps.start_dir.push_rel(&suffix).to_str(), ps.id.to_str());
92+
debug2!("pkgsrc: Returning [{}|{}|{}]", workspace.to_str(),
93+
ps.start_dir.push_rel(&suffix).to_str(), ps.id.to_str());
9494

9595
return PkgSrc {
9696
workspace: workspace,
@@ -108,7 +108,7 @@ impl PkgSrc {
108108
// Ok, no prefixes work, so try fetching from git
109109
let mut ok_d = None;
110110
for w in to_try.iter() {
111-
debug!("Calling fetch_git on %s", w.to_str());
111+
debug2!("Calling fetch_git on {}", w.to_str());
112112
let gf = PkgSrc::fetch_git(w, &id);
113113
for p in gf.iter() {
114114
ok_d = Some(p.clone());
@@ -138,14 +138,14 @@ impl PkgSrc {
138138
}
139139
}
140140
};
141-
debug!("For package id %s, returning %s", id.to_str(), dir.to_str());
141+
debug2!("For package id {}, returning {}", id.to_str(), dir.to_str());
142142

143143
if !os::path_is_dir(&dir) {
144144
cond.raise((id.clone(), ~"supplied path for package dir is a \
145145
non-directory"));
146146
}
147147

148-
debug!("pkgsrc: Returning {%s|%s|%s}", workspace.to_str(),
148+
debug2!("pkgsrc: Returning \\{{}|{}|{}\\}", workspace.to_str(),
149149
dir.to_str(), id.to_str());
150150

151151
PkgSrc {
@@ -176,13 +176,13 @@ impl PkgSrc {
176176
None => cond.raise(~"Failed to create temporary directory for fetching git sources")
177177
};
178178

179-
debug!("Checking whether %s (path = %s) exists locally. Cwd = %s, does it? %?",
179+
debug2!("Checking whether {} (path = {}) exists locally. Cwd = {}, does it? {:?}",
180180
pkgid.to_str(), pkgid.path.to_str(),
181181
os::getcwd().to_str(),
182182
os::path_exists(&pkgid.path));
183183

184184
if os::path_exists(&pkgid.path) {
185-
debug!("%s exists locally! Cloning it into %s",
185+
debug2!("{} exists locally! Cloning it into {}",
186186
pkgid.path.to_str(), local.to_str());
187187
// Ok to use local here; we know it will succeed
188188
git_clone(&pkgid.path, local, &pkgid.version);
@@ -194,8 +194,8 @@ impl PkgSrc {
194194
return None;
195195
}
196196

197-
let url = fmt!("https://%s", pkgid.path.to_str());
198-
debug!("Fetching package: git clone %s %s [version=%s]",
197+
let url = format!("https://{}", pkgid.path.to_str());
198+
debug2!("Fetching package: git clone {} {} [version={}]",
199199
url, clone_target.to_str(), pkgid.version.to_str());
200200

201201
if git_clone_general(url, &clone_target, &pkgid.version) {
@@ -219,7 +219,7 @@ impl PkgSrc {
219219
// return the path for it. Otherwise, None
220220
pub fn package_script_option(&self) -> Option<Path> {
221221
let maybe_path = self.start_dir.push("pkg.rs");
222-
debug!("package_script_option: checking whether %s exists", maybe_path.to_str());
222+
debug2!("package_script_option: checking whether {} exists", maybe_path.to_str());
223223
if os::path_exists(&maybe_path) {
224224
Some(maybe_path)
225225
}
@@ -239,7 +239,7 @@ impl PkgSrc {
239239
for c in p.components.slice(prefix, p.components.len()).iter() {
240240
sub = sub.push(*c);
241241
}
242-
debug!("Will compile crate %s", sub.to_str());
242+
debug2!("Will compile crate {}", sub.to_str());
243243
cs.push(Crate::new(&sub));
244244
}
245245

@@ -253,7 +253,7 @@ impl PkgSrc {
253253
use conditions::missing_pkg_files::cond;
254254

255255
let prefix = self.start_dir.components.len();
256-
debug!("Matching against %s", self.id.short_name);
256+
debug2!("Matching against {}", self.id.short_name);
257257
do os::walk_dir(&self.start_dir) |pth| {
258258
let maybe_known_crate_set = match pth.filename() {
259259
Some(filename) if filter(filename) => match filename {
@@ -282,7 +282,7 @@ impl PkgSrc {
282282
cond.raise(self.id.clone());
283283
}
284284

285-
debug!("In %s, found %u libs, %u mains, %u tests, %u benchs",
285+
debug2!("In {}, found {} libs, {} mains, {} tests, {} benchs",
286286
self.start_dir.to_str(),
287287
self.libs.len(),
288288
self.mains.len(),
@@ -298,12 +298,12 @@ impl PkgSrc {
298298
what: OutputType) {
299299
for crate in crates.iter() {
300300
let path = self.start_dir.push_rel(&crate.file).normalize();
301-
debug!("build_crates: compiling %s", path.to_str());
301+
debug2!("build_crates: compiling {}", path.to_str());
302302
let path_str = path.to_str();
303303
let cfgs = crate.cfgs + cfgs;
304304

305305
do ctx.workcache_context.with_prep(crate_tag(&path)) |prep| {
306-
debug!("Building crate %s, declaring it as an input", path.to_str());
306+
debug2!("Building crate {}, declaring it as an input", path.to_str());
307307
prep.declare_input("file", path.to_str(),
308308
workcache_support::digest_file_with_date(&path));
309309
let subpath = path.clone();
@@ -323,7 +323,7 @@ impl PkgSrc {
323323
subcfgs,
324324
false,
325325
what).to_str();
326-
debug!("Result of compiling %s was %s", subpath_str, result);
326+
debug2!("Result of compiling {} was {}", subpath_str, result);
327327
result
328328
}
329329
};
@@ -335,11 +335,11 @@ impl PkgSrc {
335335
pub fn declare_inputs(&self, prep: &mut workcache::Prep) {
336336
let to_do = ~[self.libs.clone(), self.mains.clone(),
337337
self.tests.clone(), self.benchs.clone()];
338-
debug!("In declare inputs, self = %s", self.to_str());
338+
debug2!("In declare inputs, self = {}", self.to_str());
339339
for cs in to_do.iter() {
340340
for c in cs.iter() {
341341
let path = self.start_dir.push_rel(&c.file).normalize();
342-
debug!("Declaring input: %s", path.to_str());
342+
debug2!("Declaring input: {}", path.to_str());
343343
prep.declare_input("file",
344344
path.to_str(),
345345
workcache_support::digest_file_with_date(&path.clone()));
@@ -357,17 +357,17 @@ impl PkgSrc {
357357
// Determine the destination workspace (which depends on whether
358358
// we're using the rust_path_hack)
359359
let destination_workspace = if is_workspace(&self.workspace) {
360-
debug!("%s is indeed a workspace", self.workspace.to_str());
360+
debug2!("{} is indeed a workspace", self.workspace.to_str());
361361
self.workspace.clone()
362362
} else {
363363
// It would be nice to have only one place in the code that checks
364364
// for the use_rust_path_hack flag...
365365
if build_context.context.use_rust_path_hack {
366366
let rs = default_workspace();
367-
debug!("Using hack: %s", rs.to_str());
367+
debug2!("Using hack: {}", rs.to_str());
368368
rs
369369
} else {
370-
cond.raise(fmt!("Package root %s is not a workspace; pass in --rust_path_hack \
370+
cond.raise(format!("Package root {} is not a workspace; pass in --rust_path_hack \
371371
if you want to treat it as a package source",
372372
self.workspace.to_str()))
373373
}
@@ -377,14 +377,14 @@ impl PkgSrc {
377377
let mains = self.mains.clone();
378378
let tests = self.tests.clone();
379379
let benchs = self.benchs.clone();
380-
debug!("Building libs in %s, destination = %s",
380+
debug2!("Building libs in {}, destination = {}",
381381
destination_workspace.to_str(), destination_workspace.to_str());
382382
self.build_crates(build_context, &destination_workspace, libs, cfgs, Lib);
383-
debug!("Building mains");
383+
debug2!("Building mains");
384384
self.build_crates(build_context, &destination_workspace, mains, cfgs, Main);
385-
debug!("Building tests");
385+
debug2!("Building tests");
386386
self.build_crates(build_context, &destination_workspace, tests, cfgs, Test);
387-
debug!("Building benches");
387+
debug2!("Building benches");
388388
self.build_crates(build_context, &destination_workspace, benchs, cfgs, Bench);
389389
destination_workspace.to_str()
390390
}
@@ -394,7 +394,7 @@ impl PkgSrc {
394394
let crate_sets = [&self.libs, &self.mains, &self.tests, &self.benchs];
395395
for crate_set in crate_sets.iter() {
396396
for c in crate_set.iter() {
397-
debug!("Built crate: %s", c.file.to_str())
397+
debug2!("Built crate: {}", c.file.to_str())
398398
}
399399
}
400400
}

0 commit comments

Comments
 (0)