Skip to content

Commit c54427d

Browse files
committed
libstd: Change Path::new to Path::init.
1 parent 6c672ee commit c54427d

File tree

40 files changed

+552
-547
lines changed

40 files changed

+552
-547
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(':') {
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
@@ -276,20 +276,20 @@ pub fn parse_opts(args: &[~str]) -> Option<OptRes> {
276276
let run_ignored = matches.opt_present("ignored");
277277

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

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

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

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

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

294294
let test_shard = matches.opt_str("test-shard");
295295
let test_shard = opt_shard(test_shard);

src/librustc/back/rpath.rs

Lines changed: 9 additions & 9 deletions
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
@@ -183,7 +183,7 @@ mod test {
183183
#[test]
184184
fn test_prefix_rpath() {
185185
let res = get_install_prefix_rpath("triple");
186-
let mut d = Path::new(env!("CFG_PREFIX"));
186+
let mut d = Path::init(env!("CFG_PREFIX"));
187187
d.push("lib/rustc/triple/lib");
188188
debug!("test_prefix_path: {} vs. {}",
189189
res,
@@ -194,7 +194,7 @@ mod test {
194194
#[test]
195195
fn test_prefix_rpath_abs() {
196196
let res = get_install_prefix_rpath("triple");
197-
assert!(Path::new(res).is_absolute());
197+
assert!(Path::init(res).is_absolute());
198198
}
199199
200200
#[test]
@@ -218,7 +218,7 @@ mod test {
218218
fn test_rpath_relative() {
219219
let o = abi::OsLinux;
220220
let res = get_rpath_relative_to_output(o,
221-
&Path::new("bin/rustc"), &Path::new("lib/libstd.so"));
221+
&Path::init("bin/rustc"), &Path::init("lib/libstd.so"));
222222
assert_eq!(res.as_slice(), "$ORIGIN/../lib");
223223
}
224224
@@ -227,7 +227,7 @@ mod test {
227227
fn test_rpath_relative() {
228228
let o = abi::OsFreebsd;
229229
let res = get_rpath_relative_to_output(o,
230-
&Path::new("bin/rustc"), &Path::new("lib/libstd.so"));
230+
&Path::init("bin/rustc"), &Path::init("lib/libstd.so"));
231231
assert_eq!(res.as_slice(), "$ORIGIN/../lib");
232232
}
233233
@@ -236,15 +236,15 @@ mod test {
236236
fn test_rpath_relative() {
237237
let o = abi::OsMacos;
238238
let res = get_rpath_relative_to_output(o,
239-
&Path::new("bin/rustc"),
240-
&Path::new("lib/libstd.so"));
239+
&Path::init("bin/rustc"),
240+
&Path::init("lib/libstd.so"));
241241
assert_eq!(res.as_slice(), "@loader_path/../lib");
242242
}
243243
244244
#[test]
245245
fn test_get_absolute_rpath() {
246-
let res = get_absolute_rpath(&Path::new("lib/libstd.so"));
247-
let lib = os::make_absolute(&Path::new("lib"));
246+
let res = get_absolute_rpath(&Path::init("lib/libstd.so"));
247+
let lib = os::make_absolute(&Path::init("lib"));
248248
debug!("test_get_absolute_rpath: {} vs. {}",
249249
res.to_str(), lib.display());
250250

src/librustc/driver/driver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ pub fn build_session_options(binary: @str,
719719
} else if matches.opt_present("emit-llvm") {
720720
link::output_type_bitcode
721721
} else { link::output_type_exe };
722-
let sysroot_opt = matches.opt_str("sysroot").map(|m| @Path::new(m));
722+
let sysroot_opt = matches.opt_str("sysroot").map(|m| @Path::init(m));
723723
let target = matches.opt_str("target").unwrap_or(host_triple());
724724
let target_cpu = matches.opt_str("target-cpu").unwrap_or(~"generic");
725725
let target_feature = matches.opt_str("target-feature").unwrap_or(~"");
@@ -753,7 +753,7 @@ pub fn build_session_options(binary: @str,
753753
let statik = debugging_opts & session::statik != 0;
754754

755755
let addl_lib_search_paths = matches.opt_strs("L").map(|s| {
756-
Path::new(s.as_slice())
756+
Path::init(s.as_slice())
757757
}).move_iter().collect();
758758
let linker = matches.opt_str("linker");
759759
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
@@ -248,16 +248,16 @@ pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) {
248248
let src = str::from_utf8(io::stdin().read_to_end());
249249
str_input(src.to_managed())
250250
} else {
251-
file_input(Path::new(ifile))
251+
file_input(Path::init(ifile))
252252
}
253253
}
254254
_ => early_error(demitter, "multiple input filenames provided")
255255
};
256256

257257
let sopts = build_session_options(binary, matches, demitter);
258258
let sess = build_session(sopts, demitter);
259-
let odir = matches.opt_str("out-dir").map(|o| Path::new(o));
260-
let ofile = matches.opt_str("o").map(|o| Path::new(o));
259+
let odir = matches.opt_str("out-dir").map(|o| Path::init(o));
260+
let ofile = matches.opt_str("o").map(|o| Path::init(o));
261261
let cfg = build_configuration(sess);
262262
let pretty = matches.opt_default("pretty", "normal").map(|a| {
263263
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);

0 commit comments

Comments
 (0)