summaryrefslogtreecommitdiff
path: root/library/std/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-09-19 14:06:23 +0000
committerbors <bors@rust-lang.org>2022-09-19 14:06:23 +0000
commita55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52 (patch)
tree2de5a3c571f7f5b54f4922b644f72f33786eb0e0 /library/std/src
parentb31188e88b245f48b364c6cb186b821bd472bd8a (diff)
parent7358a9b03e5d22ea4d74d89cb00d3985fc89c773 (diff)
downloadrust-1.64.0.tar.gz
Auto merge of #102018 - pietroalbini:pa-1.64.0, r=pietroalbini1.64.0
[stable] Prepare 1.64.0 release This PR prepares the 1.64.0 stable release builds. In addition to bumping the channel and including the latest release notes changes, this PR also backports the following PRs: * #100852 * #101366 * #101468 * #101922 This PR also reverts the following PRs, as decided in https://github.com/rust-lang/rust/issues/101899#issuecomment-1250996783: * https://github.com/rust-lang/rust/pull/95295 * https://github.com/rust-lang/rust/pull/99136 (followup to the previous PR) r? `@ghost` cc `@rust-lang/release`
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/sys/windows/path.rs9
-rw-r--r--library/std/src/sys/windows/path/tests.rs29
2 files changed, 20 insertions, 18 deletions
diff --git a/library/std/src/sys/windows/path.rs b/library/std/src/sys/windows/path.rs
index a0f82207099..beeca1917a9 100644
--- a/library/std/src/sys/windows/path.rs
+++ b/library/std/src/sys/windows/path.rs
@@ -198,14 +198,7 @@ fn parse_next_component(path: &OsStr, verbatim: bool) -> (&OsStr, &OsStr) {
match path.bytes().iter().position(|&x| separator(x)) {
Some(separator_start) => {
- let mut separator_end = separator_start + 1;
-
- // a series of multiple separator characters is treated as a single separator,
- // except in verbatim paths
- while !verbatim && separator_end < path.len() && separator(path.bytes()[separator_end])
- {
- separator_end += 1;
- }
+ let separator_end = separator_start + 1;
let component = &path.bytes()[..separator_start];
diff --git a/library/std/src/sys/windows/path/tests.rs b/library/std/src/sys/windows/path/tests.rs
index 2f7ec433bf2..6eab38cabfd 100644
--- a/library/std/src/sys/windows/path/tests.rs
+++ b/library/std/src/sys/windows/path/tests.rs
@@ -31,16 +31,6 @@ fn test_parse_next_component() {
parse_next_component(OsStr::new(r"servershare"), false),
(OsStr::new(r"servershare"), OsStr::new(""))
);
-
- assert_eq!(
- parse_next_component(OsStr::new(r"server/\//\/\\\\/////\/share"), false),
- (OsStr::new(r"server"), OsStr::new(r"share"))
- );
-
- assert_eq!(
- parse_next_component(OsStr::new(r"server\\\\\\\\\\\\\\share"), true),
- (OsStr::new(r"server"), OsStr::new(r"\\\\\\\\\\\\\share"))
- );
}
#[test]
@@ -126,3 +116,22 @@ fn test_windows_prefix_components() {
assert_eq!(drive.as_os_str(), OsStr::new("C:"));
assert_eq!(components.as_path(), Path::new(""));
}
+
+/// See #101358.
+///
+/// Note that the exact behaviour here may change in the future.
+/// In which case this test will need to adjusted.
+#[test]
+fn broken_unc_path() {
+ use crate::path::Component;
+
+ let mut components = Path::new(r"\\foo\\bar\\").components();
+ assert_eq!(components.next(), Some(Component::RootDir));
+ assert_eq!(components.next(), Some(Component::Normal("foo".as_ref())));
+ assert_eq!(components.next(), Some(Component::Normal("bar".as_ref())));
+
+ let mut components = Path::new("//foo//bar//").components();
+ assert_eq!(components.next(), Some(Component::RootDir));
+ assert_eq!(components.next(), Some(Component::Normal("foo".as_ref())));
+ assert_eq!(components.next(), Some(Component::Normal("bar".as_ref())));
+}