Skip to content

Commit cf3f0bd

Browse files
committed
libstd: Change Path::new to Path::init.
1 parent 023e729 commit cf3f0bd

File tree

38 files changed

+526
-525
lines changed

38 files changed

+526
-525
lines changed

src/compiletest/compiletest.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ pub fn parse_config(args: ~[~str]) -> config {
103103
}
104104

105105
fn opt_path(m: &getopts::Matches, nm: &str) -> Path {
106-
Path::new(m.opt_str(nm).unwrap())
106+
Path::init(m.opt_str(nm).unwrap())
107107
}
108108

109109
config {
110110
compile_lib_path: matches.opt_str("compile-lib-path").unwrap(),
111111
run_lib_path: matches.opt_str("run-lib-path").unwrap(),
112112
rustc_path: opt_path(matches, "rustc-path"),
113-
clang_path: matches.opt_str("clang-path").map(|s| Path::new(s)),
114-
llvm_bin_path: matches.opt_str("llvm-bin-path").map(|s| Path::new(s)),
113+
clang_path: matches.opt_str("clang-path").map(|s| Path::init(s)),
114+
llvm_bin_path: matches.opt_str("llvm-bin-path").map(|s| Path::init(s)),
115115
src_base: opt_path(matches, "src-base"),
116116
build_base: opt_path(matches, "build-base"),
117117
aux_base: opt_path(matches, "aux-base"),
@@ -124,10 +124,10 @@ pub fn parse_config(args: ~[~str]) -> config {
124124
} else {
125125
None
126126
},
127-
logfile: matches.opt_str("logfile").map(|s| Path::new(s)),
128-
save_metrics: matches.opt_str("save-metrics").map(|s| Path::new(s)),
127+
logfile: matches.opt_str("logfile").map(|s| Path::init(s)),
128+
save_metrics: matches.opt_str("save-metrics").map(|s| Path::init(s)),
129129
ratchet_metrics:
130-
matches.opt_str("ratchet-metrics").map(|s| Path::new(s)),
130+
matches.opt_str("ratchet-metrics").map(|s| Path::init(s)),
131131
ratchet_noise_percent:
132132
matches.opt_str("ratchet-noise-percent").and_then(|s| from_str::<f64>(s)),
133133
runtool: matches.opt_str("runtool"),

src/compiletest/header.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
160160

161161
fn parse_pp_exact(line: &str, testfile: &Path) -> Option<Path> {
162162
match parse_name_value_directive(line, ~"pp-exact") {
163-
Some(s) => Some(Path::new(s)),
163+
Some(s) => Some(Path::init(s)),
164164
None => {
165165
if parse_name_directive(line, "pp-exact") {
166-
testfile.filename().map(|s| Path::new(s))
166+
testfile.filename().map(|s| Path::init(s))
167167
} else {
168168
None
169169
}

src/compiletest/runtest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub fn run_metrics(config: config, testfile: ~str, mm: &mut MetricMap) {
4545
// We're going to be dumping a lot of info. Start on a new line.
4646
print!("\n\n");
4747
}
48-
let testfile = Path::new(testfile);
48+
let testfile = Path::init(testfile);
4949
debug!("running {}", testfile.display());
5050
let props = load_props(&testfile);
5151
debug!("loaded props");
@@ -852,7 +852,7 @@ fn aux_output_dir_name(config: &config, testfile: &Path) -> Path {
852852
}
853853

854854
fn output_testname(testfile: &Path) -> Path {
855-
Path::new(testfile.filestem().unwrap())
855+
Path::init(testfile.filestem().unwrap())
856856
}
857857

858858
fn output_base_name(config: &config, testfile: &Path) -> Path {

src/libextra/glob.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> GlobIterator {
9090

9191
// calculate root this way to handle volume-relative Windows paths correctly
9292
let mut root = os::getcwd();
93-
let pat_root = Path::new(pattern).root_path();
93+
let pat_root = Path::init(pattern).root_path();
9494
if pat_root.is_some() {
9595
if check_windows_verbatim(pat_root.get_ref()) {
9696
// XXX: How do we want to handle verbatim paths? I'm inclined to return nothing,
@@ -766,9 +766,9 @@ mod test {
766766

767767
#[test]
768768
fn test_matches_path() {
769-
// on windows, (Path::new("a/b").as_str().unwrap() == "a\\b"), so this
769+
// on windows, (Path::init("a/b").as_str().unwrap() == "a\\b"), so this
770770
// tests that / and \ are considered equivalent on windows
771-
assert!(Pattern::new("a/b").matches_path(&Path::new("a/b")));
771+
assert!(Pattern::new("a/b").matches_path(&Path::init("a/b")));
772772
}
773773
}
774774

src/libextra/terminfo/searcher.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn get_dbpath_for_term(term: &str) -> Option<~Path> {
2929

3030
// Find search directory
3131
match getenv("TERMINFO") {
32-
Some(dir) => dirs_to_search.push(Path::new(dir)),
32+
Some(dir) => dirs_to_search.push(Path::init(dir)),
3333
None => {
3434
if homedir.is_some() {
3535
// ncurses compatability;
@@ -38,17 +38,17 @@ pub fn get_dbpath_for_term(term: &str) -> Option<~Path> {
3838
match getenv("TERMINFO_DIRS") {
3939
Some(dirs) => for i in dirs.split_iter(':') {
4040
if i == "" {
41-
dirs_to_search.push(Path::new("/usr/share/terminfo"));
41+
dirs_to_search.push(Path::init("/usr/share/terminfo"));
4242
} else {
43-
dirs_to_search.push(Path::new(i.to_owned()));
43+
dirs_to_search.push(Path::init(i.to_owned()));
4444
}
4545
},
4646
// Found nothing, use the default paths
4747
// /usr/share/terminfo is the de facto location, but it seems
4848
// Ubuntu puts it in /lib/terminfo
4949
None => {
50-
dirs_to_search.push(Path::new("/usr/share/terminfo"));
51-
dirs_to_search.push(Path::new("/lib/terminfo"));
50+
dirs_to_search.push(Path::init("/usr/share/terminfo"));
51+
dirs_to_search.push(Path::init("/lib/terminfo"));
5252
}
5353
}
5454
}

src/libextra/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,20 +274,20 @@ pub fn parse_opts(args: &[~str]) -> Option<OptRes> {
274274
let run_ignored = matches.opt_present("ignored");
275275

276276
let logfile = matches.opt_str("logfile");
277-
let logfile = logfile.map(|s| Path::new(s));
277+
let logfile = logfile.map(|s| Path::init(s));
278278

279279
let run_benchmarks = matches.opt_present("bench");
280280
let run_tests = ! run_benchmarks ||
281281
matches.opt_present("test");
282282

283283
let ratchet_metrics = matches.opt_str("ratchet-metrics");
284-
let ratchet_metrics = ratchet_metrics.map(|s| Path::new(s));
284+
let ratchet_metrics = ratchet_metrics.map(|s| Path::init(s));
285285

286286
let ratchet_noise_percent = matches.opt_str("ratchet-noise-percent");
287287
let ratchet_noise_percent = ratchet_noise_percent.map(|s| from_str::<f64>(s).unwrap());
288288

289289
let save_metrics = matches.opt_str("save-metrics");
290-
let save_metrics = save_metrics.map(|s| Path::new(s));
290+
let save_metrics = save_metrics.map(|s| Path::init(s));
291291

292292
let test_shard = matches.opt_str("test-shard");
293293
let test_shard = opt_shard(test_shard);

src/librustc/back/rpath.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub fn get_install_prefix_rpath(target_triple: &str) -> ~str {
148148
let install_prefix = env!("CFG_PREFIX");
149149

150150
let tlib = filesearch::relative_target_lib_path(target_triple);
151-
let mut path = Path::new(install_prefix);
151+
let mut path = Path::init(install_prefix);
152152
path.push(&tlib);
153153
let path = os::make_absolute(&path);
154154
// FIXME (#9639): This needs to handle non-utf8 paths

src/librustc/driver/driver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ pub fn build_session_options(binary: @str,
714714
} else if matches.opt_present("emit-llvm") {
715715
link::output_type_bitcode
716716
} else { link::output_type_exe };
717-
let sysroot_opt = matches.opt_str("sysroot").map(|m| @Path::new(m));
717+
let sysroot_opt = matches.opt_str("sysroot").map(|m| @Path::init(m));
718718
let target = matches.opt_str("target").unwrap_or(host_triple());
719719
let target_cpu = matches.opt_str("target-cpu").unwrap_or(~"generic");
720720
let target_feature = matches.opt_str("target-feature").unwrap_or(~"");
@@ -748,7 +748,7 @@ pub fn build_session_options(binary: @str,
748748
let statik = debugging_opts & session::statik != 0;
749749

750750
let addl_lib_search_paths = matches.opt_strs("L").map(|s| {
751-
Path::new(s.as_slice())
751+
Path::init(s.as_slice())
752752
}).move_iter().collect();
753753
let linker = matches.opt_str("linker");
754754
let linker_args = matches.opt_strs("link-args").flat_map( |a| {

src/librustc/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,16 +250,16 @@ pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) {
250250
let src = str::from_utf8(io::stdin().read_to_end());
251251
str_input(src.to_managed())
252252
} else {
253-
file_input(Path::new(ifile))
253+
file_input(Path::init(ifile))
254254
}
255255
}
256256
_ => early_error(demitter, "multiple input filenames provided")
257257
};
258258

259259
let sopts = build_session_options(binary, matches, demitter);
260260
let sess = build_session(sopts, demitter);
261-
let odir = matches.opt_str("out-dir").map(|o| Path::new(o));
262-
let ofile = matches.opt_str("o").map(|o| Path::new(o));
261+
let odir = matches.opt_str("out-dir").map(|o| Path::init(o));
262+
let ofile = matches.opt_str("o").map(|o| Path::init(o));
263263
let cfg = build_configuration(sess);
264264
let pretty = matches.opt_default("pretty", "normal").map(|a| {
265265
parse_pretty(sess, a)

src/librustc/metadata/creader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ fn visit_view_item(e: @mut Env, i: &ast::view_item) {
143143
let meta_items = match path_opt {
144144
None => meta_items.clone(),
145145
Some((p, _path_str_style)) => {
146-
let p_path = Path::new(p);
146+
let p_path = Path::init(p);
147147
match p_path.filestem_str() {
148148
None|Some("") =>
149149
e.diag.span_bug(i.span, "Bad package path in `extern mod` item"),
@@ -275,7 +275,7 @@ fn resolve_crate(e: @mut Env,
275275
};
276276
let (lident, ldata) = loader::load_library_crate(&load_ctxt);
277277

278-
let cfilename = Path::new(lident);
278+
let cfilename = Path::init(lident);
279279
let cdata = ldata;
280280

281281
let attrs = decoder::get_crate_attributes(cdata);

src/librustc/metadata/filesearch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ pub fn search(filesearch: @FileSearch, pick: pick) {
145145

146146
pub fn relative_target_lib_path(target_triple: &str) -> Path {
147147
let dir = libdir();
148-
let mut p = Path::new(dir.as_slice());
148+
let mut p = Path::init(dir.as_slice());
149149
assert!(p.is_relative());
150150
p.push("rustc");
151151
p.push(target_triple);
@@ -199,7 +199,7 @@ pub fn rust_path() -> ~[Path] {
199199
Some(env_path) => {
200200
let env_path_components: ~[&str] =
201201
env_path.split_str_iter(PATH_ENTRY_SEPARATOR).collect();
202-
env_path_components.map(|&s| Path::new(s))
202+
env_path_components.map(|&s| Path::init(s))
203203
}
204204
None => ~[]
205205
};

src/librustdoc/html/render.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ fn mkdir(path: &Path) {
336336
/// static HTML tree.
337337
// FIXME (#9639): The closure should deal with &[u8] instead of &str
338338
fn clean_srcpath(src: &[u8], f: |&str|) {
339-
let p = Path::new(src);
339+
let p = Path::init(src);
340340
if p.as_vec() != bytes!(".") {
341341
for c in p.str_component_iter().map(|x|x.unwrap()) {
342342
if ".." == c {
@@ -411,7 +411,7 @@ impl<'self> DocFolder for SourceCollector<'self> {
411411
impl<'self> SourceCollector<'self> {
412412
/// Renders the given filename into its corresponding HTML source file.
413413
fn emit_source(&mut self, filename: &str) -> bool {
414-
let p = Path::new(filename);
414+
let p = Path::init(filename);
415415

416416
// Read the contents of the file
417417
let mut contents = ~[];

src/librustdoc/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ pub fn main_args(args: &[~str]) -> int {
139139

140140
info!("going to format");
141141
let started = time::precise_time_ns();
142-
let output = matches.opt_str("o").map(|s| Path::new(s));
142+
let output = matches.opt_str("o").map(|s| Path::init(s));
143143
match matches.opt_str("w") {
144144
Some(~"html") | None => {
145-
html::render::run(crate, output.unwrap_or(Path::new("doc")))
145+
html::render::run(crate, output.unwrap_or(Path::init("doc")))
146146
}
147147
Some(~"json") => {
148-
json_output(crate, res, output.unwrap_or(Path::new("doc.json")))
148+
json_output(crate, res, output.unwrap_or(Path::init("doc.json")))
149149
}
150150
Some(s) => {
151151
println!("unknown output format: {}", s);
@@ -193,8 +193,8 @@ fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output {
193193
let mut plugins = matches.opt_strs("plugins");
194194

195195
// First, parse the crate and extract all relevant information.
196-
let libs = Cell::new(matches.opt_strs("L").map(|s| Path::new(s.as_slice())));
197-
let cr = Cell::new(Path::new(cratefile));
196+
let libs = Cell::new(matches.opt_strs("L").map(|s| Path::init(s.as_slice())));
197+
let cr = Cell::new(Path::init(cratefile));
198198
info!("starting to run rustc");
199199
let (crate, analysis) = do std::task::try {
200200
let cr = cr.take();
@@ -236,7 +236,7 @@ fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output {
236236

237237
// Load all plugins/passes into a PluginManager
238238
let path = matches.opt_str("plugin-path").unwrap_or(~"/tmp/rustdoc_ng/plugins");
239-
let mut pm = plugins::PluginManager::new(Path::new(path));
239+
let mut pm = plugins::PluginManager::new(Path::init(path));
240240
for pass in passes.iter() {
241241
let plugin = match PASSES.iter().position(|&(p, _, _)| p == *pass) {
242242
Some(i) => PASSES[i].n1(),
@@ -260,7 +260,7 @@ fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output {
260260
/// This input format purely deserializes the json output file. No passes are
261261
/// run over the deserialized output.
262262
fn json_input(input: &str) -> Result<Output, ~str> {
263-
let input = match File::open(&Path::new(input)) {
263+
let input = match File::open(&Path::init(input)) {
264264
Some(f) => f,
265265
None => return Err(format!("couldn't open {} for reading", input)),
266266
};

src/librustpkg/api.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ pub fn new_default_context(c: workcache::Context, p: Path) -> BuildContext {
5656
}
5757

5858
fn file_is_fresh(path: &str, in_hash: &str) -> bool {
59-
let path = Path::new(path);
59+
let path = Path::init(path);
6060
path.exists() && in_hash == digest_file_with_date(&path)
6161
}
6262

6363
fn binary_is_fresh(path: &str, in_hash: &str) -> bool {
64-
let path = Path::new(path);
64+
let path = Path::init(path);
6565
path.exists() && in_hash == digest_only_date(&path)
6666
}
6767

@@ -189,7 +189,7 @@ pub fn my_workspace(context: &Context, package_name: &str) -> Path {
189189
let pkgid = PkgId::new(package_name);
190190
let workspaces = pkg_parent_workspaces(context, &pkgid);
191191
if workspaces.is_empty() {
192-
bad_pkg_id.raise((Path::new(package_name), package_name.to_owned()));
192+
bad_pkg_id.raise((Path::init(package_name), package_name.to_owned()));
193193
}
194194
workspaces[0]
195195
}

src/librustpkg/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ impl CtxMethods for BuildContext {
483483
})
484484
});
485485
// We always *run* the package script
486-
let (cfgs, hook_result) = PkgScript::run_custom(&Path::new(pkg_exe), &sysroot);
486+
let (cfgs, hook_result) = PkgScript::run_custom(&Path::init(pkg_exe), &sysroot);
487487
debug!("Command return code = {:?}", hook_result);
488488
if !hook_result.success() {
489489
fail!("Error running custom build command")
@@ -509,7 +509,7 @@ impl CtxMethods for BuildContext {
509509
// Find crates inside the workspace
510510
Everything => pkg_src.find_crates(),
511511
// Find only tests
512-
Tests => pkg_src.find_crates_with_filter(|s| { is_test(&Path::new(s)) }),
512+
Tests => pkg_src.find_crates_with_filter(|s| { is_test(&Path::init(s)) }),
513513
// Don't infer any crates -- just build the one that was requested
514514
JustOne(ref p) => {
515515
// We expect that p is relative to the package source's start directory,
@@ -588,7 +588,7 @@ impl CtxMethods for BuildContext {
588588
let result = self.install_no_build(pkg_src.build_workspace(),
589589
build_inputs,
590590
&pkg_src.destination_workspace,
591-
&id).map(|s| Path::new(s.as_slice()));
591+
&id).map(|s| Path::init(s.as_slice()));
592592
installed_files = installed_files + result;
593593
note(format!("Installed package {} to {}",
594594
id.to_str(),
@@ -709,10 +709,10 @@ impl CtxMethods for BuildContext {
709709
}
710710

711711
fn init(&self) {
712-
fs::mkdir_recursive(&Path::new("src"), io::UserRWX);
713-
fs::mkdir_recursive(&Path::new("bin"), io::UserRWX);
714-
fs::mkdir_recursive(&Path::new("lib"), io::UserRWX);
715-
fs::mkdir_recursive(&Path::new("build"), io::UserRWX);
712+
fs::mkdir_recursive(&Path::init("src"), io::UserRWX);
713+
fs::mkdir_recursive(&Path::init("bin"), io::UserRWX);
714+
fs::mkdir_recursive(&Path::init("lib"), io::UserRWX);
715+
fs::mkdir_recursive(&Path::init("build"), io::UserRWX);
716716
}
717717

718718
fn uninstall(&self, _id: &str, _vers: Option<~str>) {
@@ -894,7 +894,7 @@ pub fn main_args(args: &[~str]) -> int {
894894
let mut remaining_args: ~[~str] = remaining_args.map(|s| (*s).clone()).collect();
895895
remaining_args.shift();
896896
let sroot = match supplied_sysroot {
897-
Some(s) => Path::new(s),
897+
Some(s) => Path::init(s),
898898
_ => filesearch::get_or_default_sysroot()
899899
};
900900

src/librustpkg/package_id.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl PkgId {
5858
}
5959
};
6060

61-
let path = Path::new(s);
61+
let path = Path::init(s);
6262
if !path.is_relative() {
6363
return cond.raise((path, ~"absolute pkgid"));
6464
}
@@ -136,8 +136,8 @@ impl Iterator<(Path, Path)> for Prefixes {
136136
let last = self.components.pop();
137137
self.remaining.unshift(last);
138138
// converting to str and then back is a little unfortunate
139-
Some((Path::new(self.components.connect("/")),
140-
Path::new(self.remaining.connect("/"))))
139+
Some((Path::init(self.components.connect("/")),
140+
Path::init(self.remaining.connect("/"))))
141141
}
142142
}
143143
}

0 commit comments

Comments
 (0)