Skip to content

libstd: Change Path::new to Path::init. #10697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ pub fn parse_config(args: ~[~str]) -> config {
}

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

config {
compile_lib_path: matches.opt_str("compile-lib-path").unwrap(),
run_lib_path: matches.opt_str("run-lib-path").unwrap(),
rustc_path: opt_path(matches, "rustc-path"),
clang_path: matches.opt_str("clang-path").map(|s| Path::new(s)),
llvm_bin_path: matches.opt_str("llvm-bin-path").map(|s| Path::new(s)),
clang_path: matches.opt_str("clang-path").map(|s| Path::init(s)),
llvm_bin_path: matches.opt_str("llvm-bin-path").map(|s| Path::init(s)),
src_base: opt_path(matches, "src-base"),
build_base: opt_path(matches, "build-base"),
aux_base: opt_path(matches, "aux-base"),
Expand All @@ -124,10 +124,10 @@ pub fn parse_config(args: ~[~str]) -> config {
} else {
None
},
logfile: matches.opt_str("logfile").map(|s| Path::new(s)),
save_metrics: matches.opt_str("save-metrics").map(|s| Path::new(s)),
logfile: matches.opt_str("logfile").map(|s| Path::init(s)),
save_metrics: matches.opt_str("save-metrics").map(|s| Path::init(s)),
ratchet_metrics:
matches.opt_str("ratchet-metrics").map(|s| Path::new(s)),
matches.opt_str("ratchet-metrics").map(|s| Path::init(s)),
ratchet_noise_percent:
matches.opt_str("ratchet-noise-percent").and_then(|s| from_str::<f64>(s)),
runtool: matches.opt_str("runtool"),
Expand Down
4 changes: 2 additions & 2 deletions src/compiletest/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {

fn parse_pp_exact(line: &str, testfile: &Path) -> Option<Path> {
match parse_name_value_directive(line, ~"pp-exact") {
Some(s) => Some(Path::new(s)),
Some(s) => Some(Path::init(s)),
None => {
if parse_name_directive(line, "pp-exact") {
testfile.filename().map(|s| Path::new(s))
testfile.filename().map(|s| Path::init(s))
} else {
None
}
Expand Down
4 changes: 2 additions & 2 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn run_metrics(config: config, testfile: ~str, mm: &mut MetricMap) {
// We're going to be dumping a lot of info. Start on a new line.
print!("\n\n");
}
let testfile = Path::new(testfile);
let testfile = Path::init(testfile);
debug!("running {}", testfile.display());
let props = load_props(&testfile);
debug!("loaded props");
Expand Down Expand Up @@ -852,7 +852,7 @@ fn aux_output_dir_name(config: &config, testfile: &Path) -> Path {
}

fn output_testname(testfile: &Path) -> Path {
Path::new(testfile.filestem().unwrap())
Path::init(testfile.filestem().unwrap())
}

fn output_base_name(config: &config, testfile: &Path) -> Path {
Expand Down
6 changes: 3 additions & 3 deletions src/libextra/glob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> GlobIterator {

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

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

10 changes: 5 additions & 5 deletions src/libextra/terminfo/searcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn get_dbpath_for_term(term: &str) -> Option<~Path> {

// Find search directory
match getenv("TERMINFO") {
Some(dir) => dirs_to_search.push(Path::new(dir)),
Some(dir) => dirs_to_search.push(Path::init(dir)),
None => {
if homedir.is_some() {
// ncurses compatability;
Expand All @@ -38,17 +38,17 @@ pub fn get_dbpath_for_term(term: &str) -> Option<~Path> {
match getenv("TERMINFO_DIRS") {
Some(dirs) => for i in dirs.split(':') {
if i == "" {
dirs_to_search.push(Path::new("/usr/share/terminfo"));
dirs_to_search.push(Path::init("/usr/share/terminfo"));
} else {
dirs_to_search.push(Path::new(i.to_owned()));
dirs_to_search.push(Path::init(i.to_owned()));
}
},
// Found nothing, use the default paths
// /usr/share/terminfo is the de facto location, but it seems
// Ubuntu puts it in /lib/terminfo
None => {
dirs_to_search.push(Path::new("/usr/share/terminfo"));
dirs_to_search.push(Path::new("/lib/terminfo"));
dirs_to_search.push(Path::init("/usr/share/terminfo"));
dirs_to_search.push(Path::init("/lib/terminfo"));
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/libextra/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,20 +276,20 @@ pub fn parse_opts(args: &[~str]) -> Option<OptRes> {
let run_ignored = matches.opt_present("ignored");

let logfile = matches.opt_str("logfile");
let logfile = logfile.map(|s| Path::new(s));
let logfile = logfile.map(|s| Path::init(s));

let run_benchmarks = matches.opt_present("bench");
let run_tests = ! run_benchmarks ||
matches.opt_present("test");

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

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

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

let test_shard = matches.opt_str("test-shard");
let test_shard = opt_shard(test_shard);
Expand Down
18 changes: 9 additions & 9 deletions src/librustc/back/rpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub fn get_install_prefix_rpath(target_triple: &str) -> ~str {
let install_prefix = env!("CFG_PREFIX");

let tlib = filesearch::relative_target_lib_path(target_triple);
let mut path = Path::new(install_prefix);
let mut path = Path::init(install_prefix);
path.push(&tlib);
let path = os::make_absolute(&path);
// FIXME (#9639): This needs to handle non-utf8 paths
Expand Down Expand Up @@ -183,7 +183,7 @@ mod test {
#[test]
fn test_prefix_rpath() {
let res = get_install_prefix_rpath("triple");
let mut d = Path::new(env!("CFG_PREFIX"));
let mut d = Path::init(env!("CFG_PREFIX"));
d.push("lib/rustc/triple/lib");
debug!("test_prefix_path: {} vs. {}",
res,
Expand All @@ -194,7 +194,7 @@ mod test {
#[test]
fn test_prefix_rpath_abs() {
let res = get_install_prefix_rpath("triple");
assert!(Path::new(res).is_absolute());
assert!(Path::init(res).is_absolute());
}

#[test]
Expand All @@ -218,7 +218,7 @@ mod test {
fn test_rpath_relative() {
let o = abi::OsLinux;
let res = get_rpath_relative_to_output(o,
&Path::new("bin/rustc"), &Path::new("lib/libstd.so"));
&Path::init("bin/rustc"), &Path::init("lib/libstd.so"));
assert_eq!(res.as_slice(), "$ORIGIN/../lib");
}

Expand All @@ -227,7 +227,7 @@ mod test {
fn test_rpath_relative() {
let o = abi::OsFreebsd;
let res = get_rpath_relative_to_output(o,
&Path::new("bin/rustc"), &Path::new("lib/libstd.so"));
&Path::init("bin/rustc"), &Path::init("lib/libstd.so"));
assert_eq!(res.as_slice(), "$ORIGIN/../lib");
}

Expand All @@ -236,15 +236,15 @@ mod test {
fn test_rpath_relative() {
let o = abi::OsMacos;
let res = get_rpath_relative_to_output(o,
&Path::new("bin/rustc"),
&Path::new("lib/libstd.so"));
&Path::init("bin/rustc"),
&Path::init("lib/libstd.so"));
assert_eq!(res.as_slice(), "@loader_path/../lib");
}

#[test]
fn test_get_absolute_rpath() {
let res = get_absolute_rpath(&Path::new("lib/libstd.so"));
let lib = os::make_absolute(&Path::new("lib"));
let res = get_absolute_rpath(&Path::init("lib/libstd.so"));
let lib = os::make_absolute(&Path::init("lib"));
debug!("test_get_absolute_rpath: {} vs. {}",
res.to_str(), lib.display());

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ pub fn build_session_options(binary: @str,
} else if matches.opt_present("emit-llvm") {
link::output_type_bitcode
} else { link::output_type_exe };
let sysroot_opt = matches.opt_str("sysroot").map(|m| @Path::new(m));
let sysroot_opt = matches.opt_str("sysroot").map(|m| @Path::init(m));
let target = matches.opt_str("target").unwrap_or(host_triple());
let target_cpu = matches.opt_str("target-cpu").unwrap_or(~"generic");
let target_feature = matches.opt_str("target-feature").unwrap_or(~"");
Expand Down Expand Up @@ -753,7 +753,7 @@ pub fn build_session_options(binary: @str,
let statik = debugging_opts & session::statik != 0;

let addl_lib_search_paths = matches.opt_strs("L").map(|s| {
Path::new(s.as_slice())
Path::init(s.as_slice())
}).move_iter().collect();
let linker = matches.opt_str("linker");
let linker_args = matches.opt_strs("link-args").flat_map( |a| {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,16 @@ pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) {
let src = str::from_utf8(io::stdin().read_to_end());
str_input(src.to_managed())
} else {
file_input(Path::new(ifile))
file_input(Path::init(ifile))
}
}
_ => early_error(demitter, "multiple input filenames provided")
};

let sopts = build_session_options(binary, matches, demitter);
let sess = build_session(sopts, demitter);
let odir = matches.opt_str("out-dir").map(|o| Path::new(o));
let ofile = matches.opt_str("o").map(|o| Path::new(o));
let odir = matches.opt_str("out-dir").map(|o| Path::init(o));
let ofile = matches.opt_str("o").map(|o| Path::init(o));
let cfg = build_configuration(sess);
let pretty = matches.opt_default("pretty", "normal").map(|a| {
parse_pretty(sess, a)
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ fn visit_view_item(e: @mut Env, i: &ast::view_item) {
let meta_items = match path_opt {
None => meta_items.clone(),
Some((p, _path_str_style)) => {
let p_path = Path::new(p);
let p_path = Path::init(p);
match p_path.filestem_str() {
None|Some("") =>
e.diag.span_bug(i.span, "Bad package path in `extern mod` item"),
Expand Down Expand Up @@ -275,7 +275,7 @@ fn resolve_crate(e: @mut Env,
};
let (lident, ldata) = loader::load_library_crate(&load_ctxt);

let cfilename = Path::new(lident);
let cfilename = Path::init(lident);
let cdata = ldata;

let attrs = decoder::get_crate_attributes(cdata);
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/metadata/filesearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ pub fn search(filesearch: @FileSearch, pick: pick) {

pub fn relative_target_lib_path(target_triple: &str) -> Path {
let dir = libdir();
let mut p = Path::new(dir.as_slice());
let mut p = Path::init(dir.as_slice());
assert!(p.is_relative());
p.push("rustc");
p.push(target_triple);
Expand Down Expand Up @@ -199,7 +199,7 @@ pub fn rust_path() -> ~[Path] {
Some(env_path) => {
let env_path_components: ~[&str] =
env_path.split_str(PATH_ENTRY_SEPARATOR).collect();
env_path_components.map(|&s| Path::new(s))
env_path_components.map(|&s| Path::init(s))
}
None => ~[]
};
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ fn mkdir(path: &Path) {
/// static HTML tree.
// FIXME (#9639): The closure should deal with &[u8] instead of &str
fn clean_srcpath(src: &[u8], f: |&str|) {
let p = Path::new(src);
let p = Path::init(src);
if p.as_vec() != bytes!(".") {
for c in p.str_components().map(|x|x.unwrap()) {
if ".." == c {
Expand Down Expand Up @@ -411,7 +411,7 @@ impl<'self> DocFolder for SourceCollector<'self> {
impl<'self> SourceCollector<'self> {
/// Renders the given filename into its corresponding HTML source file.
fn emit_source(&mut self, filename: &str) -> bool {
let p = Path::new(filename);
let p = Path::init(filename);

// Read the contents of the file
let mut contents = ~[];
Expand Down
14 changes: 7 additions & 7 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ pub fn main_args(args: &[~str]) -> int {

info!("going to format");
let started = time::precise_time_ns();
let output = matches.opt_str("o").map(|s| Path::new(s));
let output = matches.opt_str("o").map(|s| Path::init(s));
match matches.opt_str("w") {
Some(~"html") | None => {
html::render::run(crate, output.unwrap_or(Path::new("doc")))
html::render::run(crate, output.unwrap_or(Path::init("doc")))
}
Some(~"json") => {
json_output(crate, res, output.unwrap_or(Path::new("doc.json")))
json_output(crate, res, output.unwrap_or(Path::init("doc.json")))
}
Some(s) => {
println!("unknown output format: {}", s);
Expand Down Expand Up @@ -194,9 +194,9 @@ fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output {
let mut plugins = matches.opt_strs("plugins");

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

// Load all plugins/passes into a PluginManager
let path = matches.opt_str("plugin-path").unwrap_or(~"/tmp/rustdoc_ng/plugins");
let mut pm = plugins::PluginManager::new(Path::new(path));
let mut pm = plugins::PluginManager::new(Path::init(path));
for pass in passes.iter() {
let plugin = match PASSES.iter().position(|&(p, _, _)| p == *pass) {
Some(i) => PASSES[i].n1(),
Expand All @@ -262,7 +262,7 @@ fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output {
/// This input format purely deserializes the json output file. No passes are
/// run over the deserialized output.
fn json_input(input: &str) -> Result<Output, ~str> {
let input = match File::open(&Path::new(input)) {
let input = match File::open(&Path::init(input)) {
Some(f) => f,
None => return Err(format!("couldn't open {} for reading", input)),
};
Expand Down
6 changes: 3 additions & 3 deletions src/librustpkg/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ pub fn new_default_context(c: workcache::Context, p: Path) -> BuildContext {
}

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

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

Expand Down Expand Up @@ -189,7 +189,7 @@ pub fn my_workspace(context: &Context, package_name: &str) -> Path {
let pkgid = PkgId::new(package_name);
let workspaces = pkg_parent_workspaces(context, &pkgid);
if workspaces.is_empty() {
bad_pkg_id.raise((Path::new(package_name), package_name.to_owned()));
bad_pkg_id.raise((Path::init(package_name), package_name.to_owned()));
}
workspaces[0]
}
Expand Down
Loading