Skip to content

Commit

Permalink
Auto merge of #101617 - Dylan-DPC:rollup-iiy4ipc, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Rollup of 5 pull requests

Successful merges:

 - #101366 (Restore old behaviour on broken UNC paths)
 - #101492 (Suggest adding array lengths to references to arrays if possible)
 - #101529 (Fix the example code and doctest for Formatter::sign_plus)
 - #101573 (update `ParamKindOrd`)
 - #101612 (Fix code generation of `Rvalue::Repeat` with 128 bit values)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Sep 9, 2022
2 parents 33e8c7e + 11a18da commit 8aff01d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
9 changes: 1 addition & 8 deletions std/src/sys/windows/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
29 changes: 19 additions & 10 deletions std/src/sys/windows/path/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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())));
}

0 comments on commit 8aff01d

Please sign in to comment.