rust/library
bors c00a4648a4 Auto merge of #78833 - CDirkx:parse_prefix, r=dtolnay
Refactor and fix `parse_prefix` on Windows

This PR is an extension of #78692 as well as a general refactor of `parse_prefix`:

**Fixes**:
There are two errors in the current implementation of `parse_prefix`:

Firstly, in the current implementation only `\` is recognized as a separator character in device namespace prefixes. This behavior is only correct for verbatim paths; `"\\.\C:/foo"` should be parsed as `"C:"` instead of `"C:/foo"`.

Secondly, the current implementation only handles single separator characters. In non-verbatim paths a series of separator characters should be recognized as a single boundary, e.g. the UNC path `"\\localhost\\\\\\C$\foo"` should be parsed as `"\\localhost\\\\\\C$"` and then `UNC(server: "localhost", share: "C$")`, but currently it is not parsed at all, because it starts being parsed as `\\localhost\` and then has an invalid empty share location.

Paths like `"\\.\C:/foo"` and `"\\localhost\\\\\\C$\foo"` are valid on Windows, they are equivalent to just `"C:\foo"`.

**Refactoring**:
All uses of `&[u8]` within `parse_prefix` are extracted to helper functions and`&OsStr` is used instead. This reduces the number of places unsafe is used:
- `get_first_two_components` is adapted to the more general `parse_next_component` and used in more places
- code for parsing drive prefixes is extracted to `parse_drive`
2020-12-16 00:47:50 +00:00
..
alloc Auto merge of #78682 - glandium:issue78471, r=lcnr 2020-12-15 06:32:10 +00:00
backtrace@af078ecc0b std: Update the backtrace crate submodule 2020-11-20 11:56:07 -08:00
core Rollup merge of #79360 - wchargin:wchargin-doc-iter-by-reference, r=m-ou-se 2020-12-13 11:05:22 +09:00
panic_abort Drop support for cloudabi targets 2020-11-22 17:11:41 -05:00
panic_unwind Drop support for cloudabi targets 2020-11-22 17:11:41 -05:00
proc_macro Auto merge of #79336 - camelid:rename-feature-oibit-to-auto, r=oli-obk 2020-11-25 07:25:19 +00:00
profiler_builtins Fix warning whe building profiler_builtins crate 2020-09-04 15:10:29 +02:00
rtstartup Rename optin_builtin_traits to auto_traits 2020-11-23 14:14:06 -08:00
rustc-std-workspace-alloc mv std libs to library/ 2020-07-27 19:51:13 -05:00
rustc-std-workspace-core mv std libs to library/ 2020-07-27 19:51:13 -05:00
rustc-std-workspace-std mv std libs to library/ 2020-07-27 19:51:13 -05:00
std Auto merge of #78833 - CDirkx:parse_prefix, r=dtolnay 2020-12-16 00:47:50 +00:00
stdarch@f1ed22803f Update stdarch submodule 2020-12-11 00:00:00 +00:00
term mv std libs to library/ 2020-07-27 19:51:13 -05:00
test Dogfood 'str_split_once()` in the std lib 2020-12-07 14:24:05 -07:00
unwind Drop support for cloudabi targets 2020-11-22 17:11:41 -05:00