path2: Update for latest master
Also fix some issues that crept into earlier commits during the conflict resoution for the rebase.
This commit is contained in:
parent
40b324f0de
commit
6eade9e914
@ -164,7 +164,7 @@ fn parse_pp_exact(line: &str, testfile: &Path) -> Option<Path> {
|
||||
Some(s) => Some(Path::new(s)),
|
||||
None => {
|
||||
if parse_name_directive(line, "pp-exact") {
|
||||
testfile.filename().map_move(|s| Path::new(s))
|
||||
testfile.filename().map(|s| Path::new(s))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -663,7 +663,7 @@ fn make_lib_name(config: &config, auxfile: &Path, testfile: &Path) -> Path {
|
||||
fn make_exe_name(config: &config, testfile: &Path) -> Path {
|
||||
let mut f = output_base_name(config, testfile);
|
||||
if !os::EXE_SUFFIX.is_empty() {
|
||||
match f.filename().map_move(|s| s + os::EXE_SUFFIX.as_bytes()) {
|
||||
match f.filename().map(|s| s + os::EXE_SUFFIX.as_bytes()) {
|
||||
Some(v) => f.set_filename(v),
|
||||
None => ()
|
||||
}
|
||||
@ -752,7 +752,7 @@ fn make_out_name(config: &config, testfile: &Path, extension: &str) -> Path {
|
||||
|
||||
fn aux_output_dir_name(config: &config, testfile: &Path) -> Path {
|
||||
let mut f = output_base_name(config, testfile);
|
||||
match f.filename().map_move(|s| s + bytes!(".libaux")) {
|
||||
match f.filename().map(|s| s + bytes!(".libaux")) {
|
||||
Some(v) => f.set_filename(v),
|
||||
None => ()
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ fn check_windows_verbatim(_: &Path) -> bool { false }
|
||||
root.push(pat_root.get_ref());
|
||||
}
|
||||
|
||||
let root_len = pat_root.map_move_default(0u, |p| p.as_vec().len());
|
||||
let root_len = pat_root.map_default(0u, |p| p.as_vec().len());
|
||||
let dir_patterns = pattern.slice_from(root_len.min(&pattern.len()))
|
||||
.split_terminator_iter(is_sep).map(|s| Pattern::new(s)).to_owned_vec();
|
||||
|
||||
@ -303,7 +303,7 @@ pub fn matches(&self, str: &str) -> bool {
|
||||
*/
|
||||
pub fn matches_path(&self, path: &Path) -> bool {
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
do path.as_str().map_move_default(false) |s| {
|
||||
do path.as_str().map_default(false) |s| {
|
||||
self.matches(s)
|
||||
}
|
||||
}
|
||||
@ -321,7 +321,7 @@ pub fn matches_with(&self, str: &str, options: MatchOptions) -> bool {
|
||||
*/
|
||||
pub fn matches_path_with(&self, path: &Path, options: MatchOptions) -> bool {
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
do path.as_str().map_move_default(false) |s| {
|
||||
do path.as_str().map_default(false) |s| {
|
||||
self.matches_with(s, options)
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ pub fn new(mut source_workspace: Path,
|
||||
|
||||
let mut result = build_dir.join("src");
|
||||
result.push(&id.path.dir_path());
|
||||
result.push_str(format!("{}-{}", id.short_name, id.version.to_str()));
|
||||
result.push(format!("{}-{}", id.short_name, id.version.to_str()));
|
||||
to_try.push(result.clone());
|
||||
output_names.push(result);
|
||||
let mut other_result = build_dir.join("src");
|
||||
@ -174,17 +174,19 @@ pub fn new(mut source_workspace: Path,
|
||||
}
|
||||
match ok_d {
|
||||
Some(ref d) => {
|
||||
if d.is_parent_of(&id.path)
|
||||
|| d.is_parent_of(&versionize(&id.path, &id.version)) {
|
||||
if d.is_ancestor_of(&id.path)
|
||||
|| d.is_ancestor_of(&versionize(&id.path, &id.version)) {
|
||||
// Strip off the package ID
|
||||
source_workspace = d.clone();
|
||||
for _ in id.path.components().iter() {
|
||||
source_workspace = source_workspace.pop();
|
||||
for _ in id.path.component_iter() {
|
||||
source_workspace.pop();
|
||||
}
|
||||
// Strip off the src/ part
|
||||
source_workspace = source_workspace.pop();
|
||||
source_workspace.pop();
|
||||
// Strip off the build/<target-triple> part to get the workspace
|
||||
destination_workspace = source_workspace.pop().pop();
|
||||
destination_workspace = source_workspace.clone();
|
||||
destination_workspace.pop();
|
||||
destination_workspace.pop();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -244,9 +246,10 @@ pub fn new(mut source_workspace: Path,
|
||||
pub fn fetch_git(local: &Path, pkgid: &PkgId) -> Option<Path> {
|
||||
use conditions::git_checkout_failed::cond;
|
||||
|
||||
let cwd = os::getcwd();
|
||||
debug2!("Checking whether {} (path = {}) exists locally. Cwd = {}, does it? {:?}",
|
||||
pkgid.to_str(), pkgid.path.display(),
|
||||
os::getcwd().display(),
|
||||
cwd.display(),
|
||||
os::path_exists(&pkgid.path));
|
||||
|
||||
match safe_git_clone(&pkgid.path, &pkgid.version, local) {
|
||||
@ -400,7 +403,7 @@ fn build_crates(&self,
|
||||
// into account. I'm not sure if the workcache really likes seeing the
|
||||
// output as "Some(\"path\")". But I don't know what to do about it.
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
let result = result.map(|p|p.as_str().unwrap());
|
||||
let result = result.as_ref().map(|p|p.as_str().unwrap());
|
||||
debug2!("Result of compiling {} was {}", subpath.display(), result.to_str());
|
||||
result.to_str()
|
||||
}
|
||||
|
@ -462,7 +462,7 @@ pub fn versionize(p: &Path, v: &Version) -> Path {
|
||||
pub fn chmod_read_only(p: &Path) -> bool {
|
||||
#[fixed_stack_segment];
|
||||
unsafe {
|
||||
do p.to_str().with_c_str |src_buf| {
|
||||
do p.with_c_str |src_buf| {
|
||||
libc::chmod(src_buf, S_IRUSR as libc::c_int) == 0 as libc::c_int
|
||||
}
|
||||
}
|
||||
@ -472,7 +472,7 @@ pub fn chmod_read_only(p: &Path) -> bool {
|
||||
pub fn chmod_read_only(p: &Path) -> bool {
|
||||
#[fixed_stack_segment];
|
||||
unsafe {
|
||||
do p.to_str().with_c_str |src_buf| {
|
||||
do p.with_c_str |src_buf| {
|
||||
libc::chmod(src_buf, S_IRUSR as libc::mode_t) == 0
|
||||
as libc::c_int
|
||||
}
|
||||
|
@ -247,8 +247,9 @@ fn build_args(&self, args: ~[~str], what: &WhatToBuild) -> Option<(PkgId, Path)>
|
||||
dest_ws = determine_destination(os::getcwd(),
|
||||
self.context.use_rust_path_hack,
|
||||
workspace);
|
||||
let mut pkg_src = PkgSrc::new(workspace.clone(), false, pkgid.clone());
|
||||
dest_ws = Some(self.build(&mut pkg_src, what));
|
||||
let mut pkg_src = PkgSrc::new(workspace.clone(), dest_ws.clone(),
|
||||
false, pkgid.clone());
|
||||
self.build(&mut pkg_src, what);
|
||||
true
|
||||
};
|
||||
// n.b. If this builds multiple packages, it only returns the workspace for
|
||||
@ -430,7 +431,7 @@ fn build(&self, pkg_src: &mut PkgSrc, what_to_build: &WhatToBuild) {
|
||||
match git_result {
|
||||
CheckedOutSources => make_read_only(&out_dir),
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
_ => cond.raise((pkgid.path.as_str().unwrap(), out_dir.clone()))
|
||||
_ => cond.raise((pkgid.path.as_str().unwrap().to_owned(), out_dir.clone()))
|
||||
};
|
||||
let default_ws = default_workspace();
|
||||
debug2!("Calling build recursively with {:?} and {:?}", default_ws.display(),
|
||||
@ -562,7 +563,7 @@ fn install(&self, mut pkg_src: PkgSrc, what: &WhatToBuild) -> (~[Path], ~[(~str,
|
||||
|
||||
let result = self.install_no_build(pkg_src.build_workspace(),
|
||||
&pkg_src.destination_workspace,
|
||||
&id).map(|s| Path::new(*s));
|
||||
&id).map(|s| Path::new(s.as_slice()));
|
||||
debug2!("install: id = {}, about to call discover_outputs, {:?}",
|
||||
id.to_str(), result.map(|p| p.display().to_str()));
|
||||
installed_files = installed_files + result;
|
||||
@ -580,7 +581,7 @@ fn install_no_build(&self,
|
||||
use conditions::copy_failed::cond;
|
||||
|
||||
debug2!("install_no_build: assuming {} comes from {} with target {}",
|
||||
id.to_str(), build_workspace.to_str(), target_workspace.to_str());
|
||||
id.to_str(), build_workspace.display(), target_workspace.display());
|
||||
|
||||
// Now copy stuff into the install dirs
|
||||
let maybe_executable = built_executable_in_workspace(id, build_workspace);
|
||||
@ -631,8 +632,7 @@ fn install_no_build(&self,
|
||||
let mut target_lib = sub_target_lib
|
||||
.clone().expect(format!("I built {} but apparently \
|
||||
didn't install it!", lib.display()));
|
||||
let target_lib = target_lib
|
||||
.set_filename(lib.filename().expect("weird target lib"));
|
||||
target_lib.set_filename(lib.filename().expect("weird target lib"));
|
||||
if !(os::mkdir_recursive(&target_lib.dir_path(), U_RWX) &&
|
||||
os::copy_file(lib, &target_lib)) {
|
||||
cond.raise(((*lib).clone(), target_lib.clone()));
|
||||
|
@ -107,7 +107,9 @@ pub fn make_read_only(target: &Path) {
|
||||
pub fn git_clone_url(source: &str, target: &Path, v: &Version) {
|
||||
use conditions::git_checkout_failed::cond;
|
||||
|
||||
let outp = run::process_output("git", [~"clone", source.to_str(), target.to_str()]);
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
let outp = run::process_output("git", [~"clone", source.to_owned(),
|
||||
target.as_str().unwrap().to_owned()]);
|
||||
if outp.status != 0 {
|
||||
debug2!("{}", str::from_utf8_owned(outp.output.clone()));
|
||||
debug2!("{}", str::from_utf8_owned(outp.error));
|
||||
|
@ -88,7 +88,7 @@ fn writeFile(file_path: &Path, contents: &str) {
|
||||
|
||||
fn mk_emptier_workspace(tag: &str) -> TempDir {
|
||||
let workspace = TempDir::new(tag).expect("couldn't create temp dir");
|
||||
let package_dir = workspace.path().push("src");
|
||||
let package_dir = workspace.path().join("src");
|
||||
assert!(os::mkdir_recursive(&package_dir, U_RWX));
|
||||
workspace
|
||||
}
|
||||
@ -110,9 +110,10 @@ fn mk_workspace(workspace: &Path, short_name: &Path, version: &Version) -> Path
|
||||
|
||||
fn mk_temp_workspace(short_name: &Path, version: &Version) -> (TempDir, Path) {
|
||||
let workspace_dir = mk_empty_workspace(short_name, version, "temp_workspace");
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
let package_dir = workspace_dir.path().join_many([~"src",
|
||||
format!("{}-{}",
|
||||
short_name.to_str(),
|
||||
short_name.as_str().unwrap(),
|
||||
version.to_str())]);
|
||||
|
||||
debug2!("Created {} and does it exist? {:?}", package_dir.display(),
|
||||
@ -912,7 +913,8 @@ fn rust_path_test() {
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
command_line_test_with_env([~"install", ~"foo"],
|
||||
&cwd,
|
||||
Some(~[(~"RUST_PATH", dir_for_path.path().as_str().unwrap())]));
|
||||
Some(~[(~"RUST_PATH",
|
||||
dir_for_path.path().as_str().unwrap().to_owned())]));
|
||||
assert_executable_exists(dir_for_path.path(), "foo");
|
||||
}
|
||||
|
||||
@ -1078,7 +1080,7 @@ fn do_rebuild_dep_dates_change() {
|
||||
command_line_test([~"build", ~"foo"], workspace);
|
||||
let bar_lib_name = lib_output_file_name(workspace, "bar");
|
||||
let bar_date = datestamp(&bar_lib_name);
|
||||
debug2!("Datestamp on {} is {:?}", bar_lib_name.to_str(), bar_date);
|
||||
debug2!("Datestamp on {} is {:?}", bar_lib_name.display(), bar_date);
|
||||
touch_source_file(workspace, &dep_id);
|
||||
command_line_test([~"build", ~"foo"], workspace);
|
||||
let new_bar_date = datestamp(&bar_lib_name);
|
||||
@ -1326,6 +1328,7 @@ fn rust_path_hack_test(hack_flag: bool) {
|
||||
let workspace = workspace.path();
|
||||
let dest_workspace = mk_empty_workspace(&Path::new("bar"), &NoVersion, "dest_workspace");
|
||||
let dest_workspace = dest_workspace.path();
|
||||
let foo_path = workspace.join_many(["src", "foo-0.1"]);
|
||||
let rust_path = Some(~[(~"RUST_PATH",
|
||||
format!("{}:{}",
|
||||
dest_workspace.as_str().unwrap(),
|
||||
@ -1568,7 +1571,7 @@ fn dash_S() {
|
||||
let workspace = workspace.path();
|
||||
let test_sys = test_sysroot();
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
command_line_test([test_sysroot().as_str().unwrap().to_owned(),
|
||||
command_line_test([test_sys.as_str().unwrap().to_owned(),
|
||||
~"build",
|
||||
~"-S",
|
||||
~"foo"],
|
||||
@ -1809,7 +1812,7 @@ fn test_recursive_deps() {
|
||||
let c_id = PkgId::new("c");
|
||||
let b_workspace = create_local_package_with_dep(&b_id, &c_id);
|
||||
let b_workspace = b_workspace.path();
|
||||
writeFile(&b_workspace.join_many(["src", "c-0.1", "lib.rs"])),
|
||||
writeFile(&b_workspace.join_many(["src", "c-0.1", "lib.rs"]),
|
||||
"pub fn g() {}");
|
||||
let a_workspace = create_local_package(&a_id);
|
||||
let a_workspace = a_workspace.path();
|
||||
@ -1879,7 +1882,7 @@ fn test_target_specific_install_dir() {
|
||||
~"install",
|
||||
~"foo"],
|
||||
workspace);
|
||||
assert!(os::path_is_dir(&workspace.join_many(["lib", host_triple()])));
|
||||
assert!(os::path_is_dir(&workspace.join_many([~"lib", host_triple()])));
|
||||
assert_lib_exists(workspace, &Path::new("foo"), NoVersion);
|
||||
assert!(os::list_dir(&workspace.join("lib")).len() == 1);
|
||||
assert!(os::path_is_dir(&workspace.join("bin")));
|
||||
@ -2051,7 +2054,7 @@ fn test_installed_read_only() {
|
||||
let repo = init_git_repo(&temp_pkg_id.path);
|
||||
let repo = repo.path();
|
||||
debug2!("repo = {}", repo.display());
|
||||
let repo_subdir = repo.join_many_str(["mockgithub.com", "catamorphism", "test-pkg"]);
|
||||
let repo_subdir = repo.join_many(["mockgithub.com", "catamorphism", "test-pkg"]);
|
||||
debug2!("repo_subdir = {}", repo_subdir.display());
|
||||
|
||||
writeFile(&repo_subdir.join("main.rs"),
|
||||
@ -2077,8 +2080,8 @@ fn test_installed_read_only() {
|
||||
assert!(is_rwx(&built_lib));
|
||||
|
||||
// Make sure sources are (a) under "build" and (b) read-only
|
||||
let src1 = target_build_dir(&ws).join_many_str(["src", temp_pkg_id.to_str(), "main.rs"]);
|
||||
let src2 = target_build_dir(&ws).join_many_str(["src", temp_pkg_id.to_str(), "lib.rs"]);
|
||||
let src1 = target_build_dir(&ws).join_many([~"src", temp_pkg_id.to_str(), ~"main.rs"]);
|
||||
let src2 = target_build_dir(&ws).join_many([~"src", temp_pkg_id.to_str(), ~"lib.rs"]);
|
||||
assert!(os::path_exists(&src1));
|
||||
assert!(os::path_exists(&src2));
|
||||
assert!(is_read_only(&src1));
|
||||
@ -2091,9 +2094,9 @@ fn test_installed_local_changes() {
|
||||
let repo = init_git_repo(&temp_pkg_id.path);
|
||||
let repo = repo.path();
|
||||
debug2!("repo = {}", repo.display());
|
||||
let repo_subdir = repo.join_many_str(["mockgithub.com", "catamorphism", "test-pkg"]);
|
||||
let repo_subdir = repo.join_many(["mockgithub.com", "catamorphism", "test-pkg"]);
|
||||
debug2!("repo_subdir = {}", repo_subdir.display());
|
||||
assert!(os::mkdir_recursive(&repo.join_many_str([".rust", "src"]), U_RWX));
|
||||
assert!(os::mkdir_recursive(&repo.join_many([".rust", "src"]), U_RWX));
|
||||
|
||||
writeFile(&repo_subdir.join("main.rs"),
|
||||
"fn main() { let _x = (); }");
|
||||
@ -2109,10 +2112,10 @@ fn test_installed_local_changes() {
|
||||
// Now start a new workspace and clone it into it
|
||||
let hacking_workspace = mk_emptier_workspace("hacking_workspace");
|
||||
let hacking_workspace = hacking_workspace.path();
|
||||
let target_dir = hacking_workspace.join_many_str(["src",
|
||||
"mockgithub.com",
|
||||
"catamorphism",
|
||||
"test-pkg-0.1"]);
|
||||
let target_dir = hacking_workspace.join_many(["src",
|
||||
"mockgithub.com",
|
||||
"catamorphism",
|
||||
"test-pkg-0.1"]);
|
||||
debug2!("---- git clone {} {}", repo_subdir.display(), target_dir.display());
|
||||
|
||||
let c_res = safe_git_clone(&repo_subdir, &NoVersion, &target_dir);
|
||||
@ -2159,7 +2162,7 @@ fn test_compile_error() {
|
||||
let foo_id = PkgId::new("foo");
|
||||
let foo_workspace = create_local_package(&foo_id);
|
||||
let foo_workspace = foo_workspace.path();
|
||||
let main_crate = foo_workspace.join_many_str(["src", "foo-0.1", "main.rs"]);
|
||||
let main_crate = foo_workspace.join_many(["src", "foo-0.1", "main.rs"]);
|
||||
// Write something bogus
|
||||
writeFile(&main_crate, "pub fn main() { if 42 != ~\"the answer\" { fail!(); } }");
|
||||
let result = command_line_test_partial([~"build", ~"foo"], foo_workspace);
|
||||
|
@ -482,9 +482,9 @@ fn visit_view_item(&mut self, vi: &ast::view_item, env: ()) {
|
||||
dep.as_str().unwrap(),
|
||||
digest_only_date(dep));
|
||||
// Also, add an additional search path
|
||||
debug2!("Installed {} into {}", dep.display(),
|
||||
dep.dir_path().display());
|
||||
(self.save)(dep.dir_path());
|
||||
let dep_dir = dep.dir_path();
|
||||
debug2!("Installed {} into {}", dep.display(), dep_dir.display());
|
||||
(self.save)(dep_dir);
|
||||
}
|
||||
for &(ref what, ref dep) in inputs_disc.iter() {
|
||||
if *what == ~"file" {
|
||||
|
@ -63,7 +63,7 @@ pub fn cwd_to_workspace() -> Option<(Path, PkgId)> {
|
||||
let srcpath = path.join("src");
|
||||
if srcpath.is_ancestor_of(&cwd) {
|
||||
let rel = cwd.path_relative_from(&srcpath);
|
||||
let rel_s = rel.and_then_ref(|p|p.as_str());
|
||||
let rel_s = rel.as_ref().and_then(|p|p.as_str());
|
||||
if rel_s.is_some() {
|
||||
return Some((path, PkgId::new(rel_s.unwrap())));
|
||||
}
|
||||
|
@ -509,11 +509,11 @@ fn load_self() -> Option<~[u8]> {
|
||||
use os::win32::fill_utf16_buf_and_decode;
|
||||
do fill_utf16_buf_and_decode() |buf, sz| {
|
||||
libc::GetModuleFileNameW(0u as libc::DWORD, buf, sz)
|
||||
}.map_move(|s| s.into_bytes())
|
||||
}.map(|s| s.into_bytes())
|
||||
}
|
||||
}
|
||||
|
||||
load_self().and_then(|path| Path::new_opt(path).map(|p| { p.pop(); p }))
|
||||
load_self().and_then(|path| Path::new_opt(path).map(|mut p| { p.pop(); p }))
|
||||
}
|
||||
|
||||
|
||||
|
@ -791,7 +791,7 @@ macro_rules! t(
|
||||
(s: $path:expr, $op:ident, $exp:expr, opt) => (
|
||||
{
|
||||
let path = Path::new($path);
|
||||
let left = path.$op().map(|&x| str::from_utf8_slice(x));
|
||||
let left = path.$op().map(|x| str::from_utf8_slice(x));
|
||||
assert_eq!(left, $exp);
|
||||
}
|
||||
);
|
||||
@ -1313,7 +1313,7 @@ macro_rules! t(
|
||||
let path = Path::new($path);
|
||||
let other = Path::new($other);
|
||||
let res = path.path_relative_from(&other);
|
||||
assert_eq!(res.and_then_ref(|x| x.as_str()), $exp);
|
||||
assert_eq!(res.as_ref().and_then(|x| x.as_str()), $exp);
|
||||
}
|
||||
)
|
||||
)
|
||||
|
@ -258,7 +258,7 @@ fn append_path(me: &mut Path, path: &str) {
|
||||
// if me is verbatim, we need to pre-normalize the new path
|
||||
let path_ = if is_verbatim(me) { Path::normalize__(path, None) }
|
||||
else { None };
|
||||
let pathlen = path_.map_default(path.len(), |p| p.len());
|
||||
let pathlen = path_.as_ref().map_default(path.len(), |p| p.len());
|
||||
let mut s = str::with_capacity(me.repr.len() + 1 + pathlen);
|
||||
s.push_str(me.repr);
|
||||
let plen = me.prefix_len();
|
||||
@ -368,7 +368,7 @@ fn dirname_str<'a>(&'a self) -> Option<&'a str> {
|
||||
|
||||
#[inline]
|
||||
fn filename<'a>(&'a self) -> Option<&'a [u8]> {
|
||||
self.filename_str().map_move(|x| x.as_bytes())
|
||||
self.filename_str().map(|x| x.as_bytes())
|
||||
}
|
||||
|
||||
/// See `GenericPath::filename_str` for info.
|
||||
@ -388,13 +388,13 @@ fn filename_str<'a>(&'a self) -> Option<&'a str> {
|
||||
#[inline]
|
||||
fn filestem_str<'a>(&'a self) -> Option<&'a str> {
|
||||
// filestem() returns a byte vector that's guaranteed valid UTF-8
|
||||
self.filestem().map_move(cast::transmute)
|
||||
self.filestem().map(cast::transmute)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn extension_str<'a>(&'a self) -> Option<&'a str> {
|
||||
// extension() returns a byte vector that's guaranteed valid UTF-8
|
||||
self.extension().map_move(cast::transmute)
|
||||
self.extension().map(cast::transmute)
|
||||
}
|
||||
|
||||
fn dir_path(&self) -> Path {
|
||||
@ -728,16 +728,25 @@ fn normalize__(s: &str, prefix: Option<PathPrefix>) -> Option<~str> {
|
||||
DiskPrefix => {
|
||||
let len = prefix_len(prefix) + is_abs as uint;
|
||||
let mut s = s.slice_to(len).to_owned();
|
||||
s[0] = s[0].to_ascii().to_upper().to_byte();
|
||||
unsafe {
|
||||
str::raw::as_owned_vec(&mut s)[0] =
|
||||
s[0].to_ascii().to_upper().to_byte();
|
||||
}
|
||||
if is_abs {
|
||||
s[2] = sep as u8; // normalize C:/ to C:\
|
||||
// normalize C:/ to C:\
|
||||
unsafe {
|
||||
str::raw::as_owned_vec(&mut s)[2] = sep as u8;
|
||||
}
|
||||
}
|
||||
Some(s)
|
||||
}
|
||||
VerbatimDiskPrefix => {
|
||||
let len = prefix_len(prefix) + is_abs as uint;
|
||||
let mut s = s.slice_to(len).to_owned();
|
||||
s[4] = s[4].to_ascii().to_upper().to_byte();
|
||||
unsafe {
|
||||
str::raw::as_owned_vec(&mut s)[4] =
|
||||
s[4].to_ascii().to_upper().to_byte();
|
||||
}
|
||||
Some(s)
|
||||
}
|
||||
_ => {
|
||||
@ -2204,10 +2213,10 @@ macro_rules! t(
|
||||
let other = Path::new($other);
|
||||
let res = path.path_relative_from(&other);
|
||||
let exp = $exp;
|
||||
assert!(res.and_then_ref(|x| x.as_str()) == exp,
|
||||
assert!(res.as_ref().and_then(|x| x.as_str()) == exp,
|
||||
"`{}`.path_relative_from(`{}`): Expected {:?}, got {:?}",
|
||||
path.as_str().unwrap(), other.as_str().unwrap(), exp,
|
||||
res.and_then_ref(|x| x.as_str()));
|
||||
res.as_ref().and_then(|x| x.as_str()));
|
||||
}
|
||||
)
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user