diff --git a/library/std/src/path/tests.rs b/library/std/src/path/tests.rs index ff94fda5a227b..896d6c2a64c60 100644 --- a/library/std/src/path/tests.rs +++ b/library/std/src/path/tests.rs @@ -873,12 +873,12 @@ pub fn test_decompositions_windows() { ); t!("\\\\.\\foo/bar", - iter: ["\\\\.\\foo/bar", "\\"], + iter: ["\\\\.\\foo", "\\", "bar"], has_root: true, is_absolute: true, - parent: None, - file_name: None, - file_stem: None, + parent: Some("\\\\.\\foo/"), + file_name: Some("bar"), + file_stem: Some("bar"), extension: None ); diff --git a/library/std/src/sys/windows/path.rs b/library/std/src/sys/windows/path.rs index dda3ed68cfc95..05b16eea45fbf 100644 --- a/library/std/src/sys/windows/path.rs +++ b/library/std/src/sys/windows/path.rs @@ -62,7 +62,8 @@ pub fn parse_prefix(path: &OsStr) -> Option> { } // \\?\cat_pics _ => { - let idx = path.iter().position(|&b| b == b'\\').unwrap_or(path.len()); + let idx = + path.iter().position(|&b| is_verbatim_sep(b)).unwrap_or(path.len()); let slice = &path[..idx]; return Some(Verbatim(unsafe { u8_slice_as_os_str(slice) })); } @@ -70,7 +71,7 @@ pub fn parse_prefix(path: &OsStr) -> Option> { } } else if let Some(path) = path.strip_prefix(b".\\") { // \\.\COM42 - let idx = path.iter().position(|&b| b == b'\\').unwrap_or(path.len()); + let idx = path.iter().position(|&b| is_sep_byte(b)).unwrap_or(path.len()); let slice = &path[..idx]; return Some(DeviceNS(unsafe { u8_slice_as_os_str(slice) })); }