Skip to content

Commit c54427d

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

40 files changed

+552
-547
lines changed

src/compiletest/compiletest.rs

+6-6
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

+2-2
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

+2-2
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

+3-3
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

+5-5
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

+3-3
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

+9-9
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

+2-2
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

+3-3
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

+2-2
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

+2-2
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(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

+2-2
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_components().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

+7-7
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,13 @@ pub fn main_args(args: &[~str]) -> int {
140140

141141
info!("going to format");
142142
let started = time::precise_time_ns();
143-
let output = matches.opt_str("o").map(|s| Path::new(s));
143+
let output = matches.opt_str("o").map(|s| Path::init(s));
144144
match matches.opt_str("w") {
145145
Some(~"html") | None => {
146-
html::render::run(crate, output.unwrap_or(Path::new("doc")))
146+
html::render::run(crate, output.unwrap_or(Path::init("doc")))
147147
}
148148
Some(~"json") => {
149-
json_output(crate, res, output.unwrap_or(Path::new("doc.json")))
149+
json_output(crate, res, output.unwrap_or(Path::init("doc.json")))
150150
}
151151
Some(s) => {
152152
println!("unknown output format: {}", s);
@@ -194,9 +194,9 @@ fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output {
194194
let mut plugins = matches.opt_strs("plugins");
195195

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

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

src/librustpkg/api.rs

+3-3
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
}

0 commit comments

Comments
 (0)