Skip to content

Commit 6eade9e

Browse files
committed
path2: Update for latest master
Also fix some issues that crept into earlier commits during the conflict resoution for the rebase.
1 parent 40b324f commit 6eade9e

File tree

13 files changed

+76
-59
lines changed

13 files changed

+76
-59
lines changed

src/compiletest/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ fn parse_pp_exact(line: &str, testfile: &Path) -> Option<Path> {
164164
Some(s) => Some(Path::new(s)),
165165
None => {
166166
if parse_name_directive(line, "pp-exact") {
167-
testfile.filename().map_move(|s| Path::new(s))
167+
testfile.filename().map(|s| Path::new(s))
168168
} else {
169169
None
170170
}

src/compiletest/runtest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ fn make_lib_name(config: &config, auxfile: &Path, testfile: &Path) -> Path {
663663
fn make_exe_name(config: &config, testfile: &Path) -> Path {
664664
let mut f = output_base_name(config, testfile);
665665
if !os::EXE_SUFFIX.is_empty() {
666-
match f.filename().map_move(|s| s + os::EXE_SUFFIX.as_bytes()) {
666+
match f.filename().map(|s| s + os::EXE_SUFFIX.as_bytes()) {
667667
Some(v) => f.set_filename(v),
668668
None => ()
669669
}
@@ -752,7 +752,7 @@ fn make_out_name(config: &config, testfile: &Path, extension: &str) -> Path {
752752

753753
fn aux_output_dir_name(config: &config, testfile: &Path) -> Path {
754754
let mut f = output_base_name(config, testfile);
755-
match f.filename().map_move(|s| s + bytes!(".libaux")) {
755+
match f.filename().map(|s| s + bytes!(".libaux")) {
756756
Some(v) => f.set_filename(v),
757757
None => ()
758758
}

src/libextra/glob.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> GlobIterator {
9898
root.push(pat_root.get_ref());
9999
}
100100
101-
let root_len = pat_root.map_move_default(0u, |p| p.as_vec().len());
101+
let root_len = pat_root.map_default(0u, |p| p.as_vec().len());
102102
let dir_patterns = pattern.slice_from(root_len.min(&pattern.len()))
103103
.split_terminator_iter(is_sep).map(|s| Pattern::new(s)).to_owned_vec();
104104
@@ -303,7 +303,7 @@ impl Pattern {
303303
*/
304304
pub fn matches_path(&self, path: &Path) -> bool {
305305
// FIXME (#9639): This needs to handle non-utf8 paths
306-
do path.as_str().map_move_default(false) |s| {
306+
do path.as_str().map_default(false) |s| {
307307
self.matches(s)
308308
}
309309
}
@@ -321,7 +321,7 @@ impl Pattern {
321321
*/
322322
pub fn matches_path_with(&self, path: &Path, options: MatchOptions) -> bool {
323323
// FIXME (#9639): This needs to handle non-utf8 paths
324-
do path.as_str().map_move_default(false) |s| {
324+
do path.as_str().map_default(false) |s| {
325325
self.matches_with(s, options)
326326
}
327327
}

src/librustpkg/package_source.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl PkgSrc {
104104

105105
let mut result = build_dir.join("src");
106106
result.push(&id.path.dir_path());
107-
result.push_str(format!("{}-{}", id.short_name, id.version.to_str()));
107+
result.push(format!("{}-{}", id.short_name, id.version.to_str()));
108108
to_try.push(result.clone());
109109
output_names.push(result);
110110
let mut other_result = build_dir.join("src");
@@ -174,17 +174,19 @@ impl PkgSrc {
174174
}
175175
match ok_d {
176176
Some(ref d) => {
177-
if d.is_parent_of(&id.path)
178-
|| d.is_parent_of(&versionize(&id.path, &id.version)) {
177+
if d.is_ancestor_of(&id.path)
178+
|| d.is_ancestor_of(&versionize(&id.path, &id.version)) {
179179
// Strip off the package ID
180180
source_workspace = d.clone();
181-
for _ in id.path.components().iter() {
182-
source_workspace = source_workspace.pop();
181+
for _ in id.path.component_iter() {
182+
source_workspace.pop();
183183
}
184184
// Strip off the src/ part
185-
source_workspace = source_workspace.pop();
185+
source_workspace.pop();
186186
// Strip off the build/<target-triple> part to get the workspace
187-
destination_workspace = source_workspace.pop().pop();
187+
destination_workspace = source_workspace.clone();
188+
destination_workspace.pop();
189+
destination_workspace.pop();
188190
}
189191
break;
190192
}
@@ -244,9 +246,10 @@ impl PkgSrc {
244246
pub fn fetch_git(local: &Path, pkgid: &PkgId) -> Option<Path> {
245247
use conditions::git_checkout_failed::cond;
246248

249+
let cwd = os::getcwd();
247250
debug2!("Checking whether {} (path = {}) exists locally. Cwd = {}, does it? {:?}",
248251
pkgid.to_str(), pkgid.path.display(),
249-
os::getcwd().display(),
252+
cwd.display(),
250253
os::path_exists(&pkgid.path));
251254

252255
match safe_git_clone(&pkgid.path, &pkgid.version, local) {
@@ -400,7 +403,7 @@ impl PkgSrc {
400403
// into account. I'm not sure if the workcache really likes seeing the
401404
// output as "Some(\"path\")". But I don't know what to do about it.
402405
// FIXME (#9639): This needs to handle non-utf8 paths
403-
let result = result.map(|p|p.as_str().unwrap());
406+
let result = result.as_ref().map(|p|p.as_str().unwrap());
404407
debug2!("Result of compiling {} was {}", subpath.display(), result.to_str());
405408
result.to_str()
406409
}

src/librustpkg/path_util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ pub fn versionize(p: &Path, v: &Version) -> Path {
462462
pub fn chmod_read_only(p: &Path) -> bool {
463463
#[fixed_stack_segment];
464464
unsafe {
465-
do p.to_str().with_c_str |src_buf| {
465+
do p.with_c_str |src_buf| {
466466
libc::chmod(src_buf, S_IRUSR as libc::c_int) == 0 as libc::c_int
467467
}
468468
}
@@ -472,7 +472,7 @@ pub fn chmod_read_only(p: &Path) -> bool {
472472
pub fn chmod_read_only(p: &Path) -> bool {
473473
#[fixed_stack_segment];
474474
unsafe {
475-
do p.to_str().with_c_str |src_buf| {
475+
do p.with_c_str |src_buf| {
476476
libc::chmod(src_buf, S_IRUSR as libc::mode_t) == 0
477477
as libc::c_int
478478
}

src/librustpkg/rustpkg.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,9 @@ impl CtxMethods for BuildContext {
247247
dest_ws = determine_destination(os::getcwd(),
248248
self.context.use_rust_path_hack,
249249
workspace);
250-
let mut pkg_src = PkgSrc::new(workspace.clone(), false, pkgid.clone());
251-
dest_ws = Some(self.build(&mut pkg_src, what));
250+
let mut pkg_src = PkgSrc::new(workspace.clone(), dest_ws.clone(),
251+
false, pkgid.clone());
252+
self.build(&mut pkg_src, what);
252253
true
253254
};
254255
// n.b. If this builds multiple packages, it only returns the workspace for
@@ -430,7 +431,7 @@ impl CtxMethods for BuildContext {
430431
match git_result {
431432
CheckedOutSources => make_read_only(&out_dir),
432433
// FIXME (#9639): This needs to handle non-utf8 paths
433-
_ => cond.raise((pkgid.path.as_str().unwrap(), out_dir.clone()))
434+
_ => cond.raise((pkgid.path.as_str().unwrap().to_owned(), out_dir.clone()))
434435
};
435436
let default_ws = default_workspace();
436437
debug2!("Calling build recursively with {:?} and {:?}", default_ws.display(),
@@ -562,7 +563,7 @@ impl CtxMethods for BuildContext {
562563

563564
let result = self.install_no_build(pkg_src.build_workspace(),
564565
&pkg_src.destination_workspace,
565-
&id).map(|s| Path::new(*s));
566+
&id).map(|s| Path::new(s.as_slice()));
566567
debug2!("install: id = {}, about to call discover_outputs, {:?}",
567568
id.to_str(), result.map(|p| p.display().to_str()));
568569
installed_files = installed_files + result;
@@ -580,7 +581,7 @@ impl CtxMethods for BuildContext {
580581
use conditions::copy_failed::cond;
581582

582583
debug2!("install_no_build: assuming {} comes from {} with target {}",
583-
id.to_str(), build_workspace.to_str(), target_workspace.to_str());
584+
id.to_str(), build_workspace.display(), target_workspace.display());
584585

585586
// Now copy stuff into the install dirs
586587
let maybe_executable = built_executable_in_workspace(id, build_workspace);
@@ -631,8 +632,7 @@ impl CtxMethods for BuildContext {
631632
let mut target_lib = sub_target_lib
632633
.clone().expect(format!("I built {} but apparently \
633634
didn't install it!", lib.display()));
634-
let target_lib = target_lib
635-
.set_filename(lib.filename().expect("weird target lib"));
635+
target_lib.set_filename(lib.filename().expect("weird target lib"));
636636
if !(os::mkdir_recursive(&target_lib.dir_path(), U_RWX) &&
637637
os::copy_file(lib, &target_lib)) {
638638
cond.raise(((*lib).clone(), target_lib.clone()));

src/librustpkg/source_control.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ pub fn make_read_only(target: &Path) {
107107
pub fn git_clone_url(source: &str, target: &Path, v: &Version) {
108108
use conditions::git_checkout_failed::cond;
109109

110-
let outp = run::process_output("git", [~"clone", source.to_str(), target.to_str()]);
110+
// FIXME (#9639): This needs to handle non-utf8 paths
111+
let outp = run::process_output("git", [~"clone", source.to_owned(),
112+
target.as_str().unwrap().to_owned()]);
111113
if outp.status != 0 {
112114
debug2!("{}", str::from_utf8_owned(outp.output.clone()));
113115
debug2!("{}", str::from_utf8_owned(outp.error));

src/librustpkg/tests.rs

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ fn writeFile(file_path: &Path, contents: &str) {
8888

8989
fn mk_emptier_workspace(tag: &str) -> TempDir {
9090
let workspace = TempDir::new(tag).expect("couldn't create temp dir");
91-
let package_dir = workspace.path().push("src");
91+
let package_dir = workspace.path().join("src");
9292
assert!(os::mkdir_recursive(&package_dir, U_RWX));
9393
workspace
9494
}
@@ -110,9 +110,10 @@ fn mk_workspace(workspace: &Path, short_name: &Path, version: &Version) -> Path
110110

111111
fn mk_temp_workspace(short_name: &Path, version: &Version) -> (TempDir, Path) {
112112
let workspace_dir = mk_empty_workspace(short_name, version, "temp_workspace");
113+
// FIXME (#9639): This needs to handle non-utf8 paths
113114
let package_dir = workspace_dir.path().join_many([~"src",
114115
format!("{}-{}",
115-
short_name.to_str(),
116+
short_name.as_str().unwrap(),
116117
version.to_str())]);
117118

118119
debug2!("Created {} and does it exist? {:?}", package_dir.display(),
@@ -912,7 +913,8 @@ fn rust_path_test() {
912913
// FIXME (#9639): This needs to handle non-utf8 paths
913914
command_line_test_with_env([~"install", ~"foo"],
914915
&cwd,
915-
Some(~[(~"RUST_PATH", dir_for_path.path().as_str().unwrap())]));
916+
Some(~[(~"RUST_PATH",
917+
dir_for_path.path().as_str().unwrap().to_owned())]));
916918
assert_executable_exists(dir_for_path.path(), "foo");
917919
}
918920
@@ -1078,7 +1080,7 @@ fn do_rebuild_dep_dates_change() {
10781080
command_line_test([~"build", ~"foo"], workspace);
10791081
let bar_lib_name = lib_output_file_name(workspace, "bar");
10801082
let bar_date = datestamp(&bar_lib_name);
1081-
debug2!("Datestamp on {} is {:?}", bar_lib_name.to_str(), bar_date);
1083+
debug2!("Datestamp on {} is {:?}", bar_lib_name.display(), bar_date);
10821084
touch_source_file(workspace, &dep_id);
10831085
command_line_test([~"build", ~"foo"], workspace);
10841086
let new_bar_date = datestamp(&bar_lib_name);
@@ -1326,6 +1328,7 @@ fn rust_path_hack_test(hack_flag: bool) {
13261328
let workspace = workspace.path();
13271329
let dest_workspace = mk_empty_workspace(&Path::new("bar"), &NoVersion, "dest_workspace");
13281330
let dest_workspace = dest_workspace.path();
1331+
let foo_path = workspace.join_many(["src", "foo-0.1"]);
13291332
let rust_path = Some(~[(~"RUST_PATH",
13301333
format!("{}:{}",
13311334
dest_workspace.as_str().unwrap(),
@@ -1568,7 +1571,7 @@ fn dash_S() {
15681571
let workspace = workspace.path();
15691572
let test_sys = test_sysroot();
15701573
// FIXME (#9639): This needs to handle non-utf8 paths
1571-
command_line_test([test_sysroot().as_str().unwrap().to_owned(),
1574+
command_line_test([test_sys.as_str().unwrap().to_owned(),
15721575
~"build",
15731576
~"-S",
15741577
~"foo"],
@@ -1809,7 +1812,7 @@ fn test_recursive_deps() {
18091812
let c_id = PkgId::new("c");
18101813
let b_workspace = create_local_package_with_dep(&b_id, &c_id);
18111814
let b_workspace = b_workspace.path();
1812-
writeFile(&b_workspace.join_many(["src", "c-0.1", "lib.rs"])),
1815+
writeFile(&b_workspace.join_many(["src", "c-0.1", "lib.rs"]),
18131816
"pub fn g() {}");
18141817
let a_workspace = create_local_package(&a_id);
18151818
let a_workspace = a_workspace.path();
@@ -1879,7 +1882,7 @@ fn test_target_specific_install_dir() {
18791882
~"install",
18801883
~"foo"],
18811884
workspace);
1882-
assert!(os::path_is_dir(&workspace.join_many(["lib", host_triple()])));
1885+
assert!(os::path_is_dir(&workspace.join_many([~"lib", host_triple()])));
18831886
assert_lib_exists(workspace, &Path::new("foo"), NoVersion);
18841887
assert!(os::list_dir(&workspace.join("lib")).len() == 1);
18851888
assert!(os::path_is_dir(&workspace.join("bin")));
@@ -2051,7 +2054,7 @@ fn test_installed_read_only() {
20512054
let repo = init_git_repo(&temp_pkg_id.path);
20522055
let repo = repo.path();
20532056
debug2!("repo = {}", repo.display());
2054-
let repo_subdir = repo.join_many_str(["mockgithub.com", "catamorphism", "test-pkg"]);
2057+
let repo_subdir = repo.join_many(["mockgithub.com", "catamorphism", "test-pkg"]);
20552058
debug2!("repo_subdir = {}", repo_subdir.display());
20562059
20572060
writeFile(&repo_subdir.join("main.rs"),
@@ -2077,8 +2080,8 @@ fn test_installed_read_only() {
20772080
assert!(is_rwx(&built_lib));
20782081
20792082
// Make sure sources are (a) under "build" and (b) read-only
2080-
let src1 = target_build_dir(&ws).join_many_str(["src", temp_pkg_id.to_str(), "main.rs"]);
2081-
let src2 = target_build_dir(&ws).join_many_str(["src", temp_pkg_id.to_str(), "lib.rs"]);
2083+
let src1 = target_build_dir(&ws).join_many([~"src", temp_pkg_id.to_str(), ~"main.rs"]);
2084+
let src2 = target_build_dir(&ws).join_many([~"src", temp_pkg_id.to_str(), ~"lib.rs"]);
20822085
assert!(os::path_exists(&src1));
20832086
assert!(os::path_exists(&src2));
20842087
assert!(is_read_only(&src1));
@@ -2091,9 +2094,9 @@ fn test_installed_local_changes() {
20912094
let repo = init_git_repo(&temp_pkg_id.path);
20922095
let repo = repo.path();
20932096
debug2!("repo = {}", repo.display());
2094-
let repo_subdir = repo.join_many_str(["mockgithub.com", "catamorphism", "test-pkg"]);
2097+
let repo_subdir = repo.join_many(["mockgithub.com", "catamorphism", "test-pkg"]);
20952098
debug2!("repo_subdir = {}", repo_subdir.display());
2096-
assert!(os::mkdir_recursive(&repo.join_many_str([".rust", "src"]), U_RWX));
2099+
assert!(os::mkdir_recursive(&repo.join_many([".rust", "src"]), U_RWX));
20972100
20982101
writeFile(&repo_subdir.join("main.rs"),
20992102
"fn main() { let _x = (); }");
@@ -2109,10 +2112,10 @@ fn test_installed_local_changes() {
21092112
// Now start a new workspace and clone it into it
21102113
let hacking_workspace = mk_emptier_workspace("hacking_workspace");
21112114
let hacking_workspace = hacking_workspace.path();
2112-
let target_dir = hacking_workspace.join_many_str(["src",
2113-
"mockgithub.com",
2114-
"catamorphism",
2115-
"test-pkg-0.1"]);
2115+
let target_dir = hacking_workspace.join_many(["src",
2116+
"mockgithub.com",
2117+
"catamorphism",
2118+
"test-pkg-0.1"]);
21162119
debug2!("---- git clone {} {}", repo_subdir.display(), target_dir.display());
21172120
21182121
let c_res = safe_git_clone(&repo_subdir, &NoVersion, &target_dir);
@@ -2159,7 +2162,7 @@ fn test_compile_error() {
21592162
let foo_id = PkgId::new("foo");
21602163
let foo_workspace = create_local_package(&foo_id);
21612164
let foo_workspace = foo_workspace.path();
2162-
let main_crate = foo_workspace.join_many_str(["src", "foo-0.1", "main.rs"]);
2165+
let main_crate = foo_workspace.join_many(["src", "foo-0.1", "main.rs"]);
21632166
// Write something bogus
21642167
writeFile(&main_crate, "pub fn main() { if 42 != ~\"the answer\" { fail!(); } }");
21652168
let result = command_line_test_partial([~"build", ~"foo"], foo_workspace);

src/librustpkg/util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,9 @@ impl<'self> Visitor<()> for ViewItemVisitor<'self> {
482482
dep.as_str().unwrap(),
483483
digest_only_date(dep));
484484
// Also, add an additional search path
485-
debug2!("Installed {} into {}", dep.display(),
486-
dep.dir_path().display());
487-
(self.save)(dep.dir_path());
485+
let dep_dir = dep.dir_path();
486+
debug2!("Installed {} into {}", dep.display(), dep_dir.display());
487+
(self.save)(dep_dir);
488488
}
489489
for &(ref what, ref dep) in inputs_disc.iter() {
490490
if *what == ~"file" {

src/librustpkg/workspace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub fn cwd_to_workspace() -> Option<(Path, PkgId)> {
6363
let srcpath = path.join("src");
6464
if srcpath.is_ancestor_of(&cwd) {
6565
let rel = cwd.path_relative_from(&srcpath);
66-
let rel_s = rel.and_then_ref(|p|p.as_str());
66+
let rel_s = rel.as_ref().and_then(|p|p.as_str());
6767
if rel_s.is_some() {
6868
return Some((path, PkgId::new(rel_s.unwrap())));
6969
}

src/libstd/os.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,11 +509,11 @@ pub fn self_exe_path() -> Option<Path> {
509509
use os::win32::fill_utf16_buf_and_decode;
510510
do fill_utf16_buf_and_decode() |buf, sz| {
511511
libc::GetModuleFileNameW(0u as libc::DWORD, buf, sz)
512-
}.map_move(|s| s.into_bytes())
512+
}.map(|s| s.into_bytes())
513513
}
514514
}
515515

516-
load_self().and_then(|path| Path::new_opt(path).map(|p| { p.pop(); p }))
516+
load_self().and_then(|path| Path::new_opt(path).map(|mut p| { p.pop(); p }))
517517
}
518518

519519

src/libstd/path/posix.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ mod tests {
791791
(s: $path:expr, $op:ident, $exp:expr, opt) => (
792792
{
793793
let path = Path::new($path);
794-
let left = path.$op().map(|&x| str::from_utf8_slice(x));
794+
let left = path.$op().map(|x| str::from_utf8_slice(x));
795795
assert_eq!(left, $exp);
796796
}
797797
);
@@ -1313,7 +1313,7 @@ mod tests {
13131313
let path = Path::new($path);
13141314
let other = Path::new($other);
13151315
let res = path.path_relative_from(&other);
1316-
assert_eq!(res.and_then_ref(|x| x.as_str()), $exp);
1316+
assert_eq!(res.as_ref().and_then(|x| x.as_str()), $exp);
13171317
}
13181318
)
13191319
)

0 commit comments

Comments
 (0)