diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2021-11-19 13:06:35 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-19 13:06:35 +0900 |
| commit | f62984fca98a60cbb545a7c2bce3fc878ce1f1d3 (patch) | |
| tree | 629331df0280e98f4def1b46f0d54be5c1a047ec /library/std/src/sys | |
| parent | b542224fa568b9270c9ad00e398edf842931749e (diff) | |
| parent | ddc1d58ca83ab2c176929c47bd679cfbe8cf32f9 (diff) | |
| download | rust-f62984fca98a60cbb545a7c2bce3fc878ce1f1d3.tar.gz rust-f62984fca98a60cbb545a7c2bce3fc878ce1f1d3.zip | |
Rollup merge of #90942 - JohnTitor:should-os-error-3, r=m-ou-se
windows: Return the "Not Found" error when a path is empty Fixes #90940
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/windows/path.rs | 4 | ||||
| -rw-r--r-- | library/std/src/sys/windows/path/tests.rs | 3 |
2 files changed, 3 insertions, 4 deletions
diff --git a/library/std/src/sys/windows/path.rs b/library/std/src/sys/windows/path.rs index 460c1eff778..d0b7d9e7377 100644 --- a/library/std/src/sys/windows/path.rs +++ b/library/std/src/sys/windows/path.rs @@ -174,8 +174,8 @@ pub(crate) fn maybe_verbatim(path: &Path) -> io::Result<Vec<u16>> { const UNC_PREFIX: &[u16] = &[SEP, SEP, QUERY, SEP, U, N, C, SEP]; let mut path = to_u16s(path)?; - if path.starts_with(VERBATIM_PREFIX) || path.starts_with(NT_PREFIX) { - // Early return for paths that are already verbatim. + if path.starts_with(VERBATIM_PREFIX) || path.starts_with(NT_PREFIX) || path == &[0] { + // Early return for paths that are already verbatim or empty. return Ok(path); } else if path.len() < LEGACY_MAX_PATH { // Early return if an absolute path is less < 260 UTF-16 code units. diff --git a/library/std/src/sys/windows/path/tests.rs b/library/std/src/sys/windows/path/tests.rs index c6c84519f41..425c2011b32 100644 --- a/library/std/src/sys/windows/path/tests.rs +++ b/library/std/src/sys/windows/path/tests.rs @@ -91,7 +91,6 @@ fn verbatim() { // Make sure opening a drive will work. check("Z:", "Z:"); - // An empty path or a path that contains null are not valid paths. - assert!(maybe_verbatim(Path::new("")).is_err()); + // A path that contains null is not a valid path. assert!(maybe_verbatim(Path::new("\0")).is_err()); } |
