diff options
| author | Kevin Ballard <kevin@sb.org> | 2013-10-05 19:49:32 -0700 |
|---|---|---|
| committer | Kevin Ballard <kevin@sb.org> | 2013-10-15 22:18:30 -0700 |
| commit | d6d9b926836b1f1c2b8b3fe4ab35dc63bec7ffcd (patch) | |
| tree | e197783b86700e71d94c9bc6d0254eb25b16cc0c /src/librustc | |
| parent | ed539e14712539473c3e89604cb69e2307110772 (diff) | |
| download | rust-d6d9b926836b1f1c2b8b3fe4ab35dc63bec7ffcd.tar.gz rust-d6d9b926836b1f1c2b8b3fe4ab35dc63bec7ffcd.zip | |
path2: Adjust the API to remove all the _str mutation methods
Add a new trait BytesContainer that is implemented for both byte vectors and strings. Convert Path::from_vec and ::from_str to one function, Path::new(). Remove all the _str-suffixed mutation methods (push, join, with_*, set_*) and modify the non-suffixed versions to use BytesContainer.
Diffstat (limited to 'src/librustc')
| -rw-r--r-- | src/librustc/back/link.rs | 8 | ||||
| -rw-r--r-- | src/librustc/back/rpath.rs | 22 | ||||
| -rw-r--r-- | src/librustc/driver/driver.rs | 18 | ||||
| -rw-r--r-- | src/librustc/metadata/creader.rs | 4 | ||||
| -rw-r--r-- | src/librustc/metadata/filesearch.rs | 22 | ||||
| -rw-r--r-- | src/librustc/rustc.rs | 6 |
6 files changed, 40 insertions, 40 deletions
diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index d5cd78f54f7..404efa25ff3 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -249,7 +249,7 @@ pub mod write { llvm::LLVMInitializeMipsAsmParser(); if sess.opts.save_temps { - do output.with_extension_str("no-opt.bc").with_c_str |buf| { + do output.with_extension("no-opt.bc").with_c_str |buf| { llvm::LLVMWriteBitcodeToFile(llmod, buf); } } @@ -317,7 +317,7 @@ pub mod write { llvm::LLVMDisposePassManager(mpm); if sess.opts.save_temps { - do output.with_extension_str("bc").with_c_str |buf| { + do output.with_extension("bc").with_c_str |buf| { llvm::LLVMWriteBitcodeToFile(llmod, buf); } } @@ -921,7 +921,7 @@ pub fn link_binary(sess: Session, let out_dirname = out_filename.dir_path(); debug2!("dirname(out_filename): {}", out_dirname.display()); - out_filename.with_filename_str(long_libname) + out_filename.with_filename(long_libname) } else { out_filename.clone() }; @@ -977,7 +977,7 @@ pub fn link_args(sess: Session, let output = if *sess.building_library { let long_libname = output_dll_filename(sess.targ_cfg.os, lm); - out_filename.with_filename_str(long_libname) + out_filename.with_filename(long_libname) } else { out_filename.clone() }; diff --git a/src/librustc/back/rpath.rs b/src/librustc/back/rpath.rs index b3fb6be686d..b7ae9c1ecb5 100644 --- a/src/librustc/back/rpath.rs +++ b/src/librustc/back/rpath.rs @@ -46,7 +46,7 @@ pub fn get_rpath_flags(sess: session::Session, out_filename: &Path) fn get_sysroot_absolute_rt_lib(sess: session::Session) -> Path { let r = filesearch::relative_target_lib_path(sess.opts.target_triple); let mut p = sess.filesearch.sysroot().join_path(&r); - p.push_str(os::dll_filename("rustrt")); + p.push(os::dll_filename("rustrt")); p } @@ -147,7 +147,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::from_str(install_prefix); + let mut path = Path::new(install_prefix); path.push_path(&tlib); let path = os::make_absolute(&path); // FIXME (#9639): This needs to handle non-utf8 paths @@ -186,8 +186,8 @@ mod test { #[test] fn test_prefix_rpath() { let res = get_install_prefix_rpath("triple"); - let mut d = Path::from_str(env!("CFG_PREFIX")); - d.push_str("lib/rustc/triple/lib"); + let mut d = Path::new(env!("CFG_PREFIX")); + d.push("lib/rustc/triple/lib"); debug2!("test_prefix_path: {} vs. {}", res.to_str(), d.display()); @@ -200,7 +200,7 @@ mod test { #[test] fn test_prefix_rpath_abs() { let res = get_install_prefix_rpath("triple"); - assert!(Path::from_str(res).is_absolute()); + assert!(Path::new(res).is_absolute()); } #[test] @@ -224,7 +224,7 @@ mod test { fn test_rpath_relative() { let o = session::OsLinux; let res = get_rpath_relative_to_output(o, - &Path::from_str("bin/rustc"), &Path::from_str("lib/libstd.so")); + &Path::new("bin/rustc"), &Path::new("lib/libstd.so")); assert_eq!(res.as_slice(), "$ORIGIN/../lib"); } @@ -233,7 +233,7 @@ mod test { fn test_rpath_relative() { let o = session::OsFreebsd; let res = get_rpath_relative_to_output(o, - &Path::from_str("bin/rustc"), &Path::from_str("lib/libstd.so")); + &Path::new("bin/rustc"), &Path::new("lib/libstd.so")); assert_eq!(res.as_slice(), "$ORIGIN/../lib"); } @@ -242,15 +242,15 @@ mod test { fn test_rpath_relative() { let o = session::OsMacos; let res = get_rpath_relative_to_output(o, - &Path::from_str("bin/rustc"), - &Path::from_str("lib/libstd.so")); + &Path::new("bin/rustc"), + &Path::new("lib/libstd.so")); assert_eq!(res.as_slice(), "@executable_path/../lib"); } #[test] fn test_get_absolute_rpath() { - let res = get_absolute_rpath(&Path::from_str("lib/libstd.so")); - let lib = os::make_absolute(&Path::from_str("lib")); + let res = get_absolute_rpath(&Path::new("lib/libstd.so")); + let lib = os::make_absolute(&Path::new("lib")); debug2!("test_get_absolute_rpath: {} vs. {}", res.to_str(), lib.display()); diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index fc5ff163d74..f85b0dbcdc3 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -353,7 +353,7 @@ pub fn phase_5_run_llvm_passes(sess: Session, (sess.opts.output_type == link::output_type_object || sess.opts.output_type == link::output_type_exe) { let output_type = link::output_type_assembly; - let asm_filename = outputs.obj_filename.with_extension_str("s"); + let asm_filename = outputs.obj_filename.with_extension("s"); time(sess.time_passes(), "LLVM passes", (), |_| link::write::run_passes(sess, @@ -722,7 +722,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::from_str(m)); + let sysroot_opt = matches.opt_str("sysroot").map(|m| @Path::new(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(~""); @@ -755,7 +755,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::from_str(*s)); + let addl_lib_search_paths = matches.opt_strs("L").map(|s| Path::new(s.as_slice())); let linker = matches.opt_str("linker"); let linker_args = matches.opt_strs("link-args").flat_map( |a| { a.split_iter(' ').map(|arg| arg.to_owned()).collect() @@ -1005,15 +1005,15 @@ pub fn build_output_filenames(input: &input, } if *sess.building_library { - out_path = dirpath.join_str(os::dll_filename(stem)); + out_path = dirpath.join(os::dll_filename(stem)); obj_path = { - let mut p = dirpath.join_str(stem); - p.set_extension_str(obj_suffix); + let mut p = dirpath.join(stem); + p.set_extension(obj_suffix); p }; } else { - out_path = dirpath.join_str(stem); - obj_path = out_path.with_extension_str(obj_suffix); + out_path = dirpath.join(stem); + obj_path = out_path.with_extension(obj_suffix); } } @@ -1022,7 +1022,7 @@ pub fn build_output_filenames(input: &input, obj_path = if stop_after_codegen { out_file.clone() } else { - out_file.with_extension_str(obj_suffix) + out_file.with_extension(obj_suffix) }; if *sess.building_library { diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index 8ece290293b..9700f68383a 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -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::from_str(p); + let p_path = Path::new(p); match p_path.filestem_str() { None|Some("") => e.diag.span_bug(i.span, "Bad package path in `extern mod` item"), @@ -275,7 +275,7 @@ fn resolve_crate(e: @mut Env, }; let (lident, ldata) = loader::load_library_crate(&load_ctxt); - let cfilename = Path::from_str(lident); + let cfilename = Path::new(lident); let cdata = ldata; let attrs = decoder::get_crate_attributes(cdata); diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index 4e3daa7c185..6335df47d73 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -138,11 +138,11 @@ pub fn search(filesearch: @FileSearch, pick: pick) { pub fn relative_target_lib_path(target_triple: &str) -> Path { let dir = libdir(); - let mut p = Path::from_str(dir); + let mut p = Path::new(dir.as_slice()); assert!(p.is_relative()); - p.push_str("rustc"); - p.push_str(target_triple); - p.push_str(dir); + p.push("rustc"); + p.push(target_triple); + p.push(dir); p } @@ -153,8 +153,8 @@ fn make_target_lib_path(sysroot: &Path, fn make_rustpkg_target_lib_path(dir: &Path, target_triple: &str) -> Path { - let mut p = dir.join_str(libdir()); - p.push_str(target_triple); + let mut p = dir.join(libdir()); + p.push(target_triple); p } @@ -192,13 +192,13 @@ pub fn rust_path() -> ~[Path] { Some(env_path) => { let env_path_components: ~[&str] = env_path.split_str_iter(PATH_ENTRY_SEPARATOR).collect(); - env_path_components.map(|&s| Path::from_str(s)) + env_path_components.map(|&s| Path::new(s)) } None => ~[] }; let cwd = os::getcwd(); // now add in default entries - let cwd_dot_rust = cwd.join_str(".rust"); + let cwd_dot_rust = cwd.join(".rust"); if !env_rust_path.contains(&cwd_dot_rust) { env_rust_path.push(cwd_dot_rust); } @@ -206,14 +206,14 @@ pub fn rust_path() -> ~[Path] { env_rust_path.push(cwd.clone()); } do cwd.each_parent() |p| { - if !env_rust_path.contains(&p.join_str(".rust")) { + if !env_rust_path.contains(&p.join(".rust")) { push_if_exists(&mut env_rust_path, p); } true }; let h = os::homedir(); for h in h.iter() { - if !env_rust_path.contains(&h.join_str(".rust")) { + if !env_rust_path.contains(&h.join(".rust")) { push_if_exists(&mut env_rust_path, h); } } @@ -223,7 +223,7 @@ pub fn rust_path() -> ~[Path] { /// Adds p/.rust into vec, only if it exists fn push_if_exists(vec: &mut ~[Path], p: &Path) { - let maybe_dir = p.join_str(".rust"); + let maybe_dir = p.join(".rust"); if os::path_exists(&maybe_dir) { vec.push(maybe_dir); } diff --git a/src/librustc/rustc.rs b/src/librustc/rustc.rs index 460ac45cdba..1d9f37a2e87 100644 --- a/src/librustc/rustc.rs +++ b/src/librustc/rustc.rs @@ -250,7 +250,7 @@ pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) { let src = str::from_utf8(io::stdin().read_whole_stream()); str_input(src.to_managed()) } else { - file_input(Path::from_str(ifile)) + file_input(Path::new(ifile)) } } _ => early_error(demitter, "multiple input filenames provided") @@ -258,8 +258,8 @@ pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) { let sopts = build_session_options(binary, matches, demitter); let sess = build_session(sopts, demitter); - let odir = matches.opt_str("out-dir").map(|o| Path::from_str(o)); - let ofile = matches.opt_str("o").map(|o| Path::from_str(o)); + let odir = matches.opt_str("out-dir").map(|o| Path::new(o)); + let ofile = matches.opt_str("o").map(|o| Path::new(o)); let cfg = build_configuration(sess); let pretty = do matches.opt_default("pretty", "normal").map |a| { parse_pretty(sess, a) |
