rust/library/std/src
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
..
backtrace Add column number support to Backtrace 2020-11-15 13:09:56 +01:00
collections Rollup merge of #77996 - tkaitchuck:master, r=m-ou-se 2020-11-13 15:26:10 +01:00
env
error
f32
f64
ffi Auto merge of #78833 - CDirkx:parse_prefix, r=dtolnay 2020-12-16 00:47:50 +00:00
fs std: Fix test got_symlink_permission on Windows 2020-11-16 21:09:26 +03:00
io Auto merge of #77801 - fusion-engineering-forks:pin-mutex, r=Mark-Simulacrum 2020-12-10 23:43:20 +00:00
lazy
memchr
net Move const ip in ui test to unit test 2020-11-26 23:15:32 +09:00
num rustc_expand: Mark inner #![test] attributes as soft-unstable 2020-11-20 19:35:03 +03:00
os Take sys/vxworks/{fd,fs,io} from sys/unix instead. 2020-10-16 06:19:00 +02:00
panic
path Refactor parse_prefix on Windows 2020-11-07 16:15:48 +01:00
prelude
process
sync Convert a bunch of intra-doc links 2020-11-07 12:50:57 -08:00
sys Auto merge of #78833 - CDirkx:parse_prefix, r=dtolnay 2020-12-16 00:47:50 +00:00
sys_common Auto merge of #77618 - fusion-engineering-forks:windows-parker, r=Amanieu 2020-12-14 16:41:14 +00:00
thread Drop support for cloudabi targets 2020-11-22 17:11:41 -05:00
time Duration::zero() -> Duration::ZERO 2020-10-21 20:44:03 -07:00
alloc.rs Rename AllocRef to Allocator and (de)alloc to (de)allocate 2020-12-04 14:47:15 +01:00
ascii.rs
backtrace.rs Add column number support to Backtrace 2020-11-15 13:09:56 +01:00
env.rs
error.rs Rename LayoutErr to LayoutError outside of core 2020-10-08 00:40:10 -04:00
f32.rs Rollup merge of #77027 - termhn:mul_add_doc_change, r=m-ou-se 2020-12-10 21:32:59 -08:00
f64.rs Rollup merge of #77027 - termhn:mul_add_doc_change, r=m-ou-se 2020-12-10 21:32:59 -08:00
fs.rs Drop support for cloudabi targets 2020-11-22 17:11:41 -05:00
future.rs
keyword_docs.rs Rollup merge of #79398 - pickfire:keyword, r=Dylan-DPC 2020-12-13 11:05:30 +09:00
lazy.rs Add (internal-only) SyncOnceCell::get_or_init_pin. 2020-12-08 22:57:50 +01:00
lib.rs Rollup merge of #79809 - Eric-Arellano:split-once, r=matklad 2020-12-10 21:33:08 -08:00
macros.rs Use ? in core/std macros 2020-10-26 07:15:37 +09:00
memchr.rs
num.rs
panic.rs Add tracking issue number for panic_any. 2020-10-28 21:23:45 +01:00
panicking.rs Merge set_panic and set_print into set_output_capture. 2020-11-10 21:58:13 +01:00
path.rs Clean up intra-doc links in std::path 2020-10-27 20:54:30 -07:00
primitive_docs.rs doc: apply suggestions 2020-12-11 10:09:40 -05:00
process.rs Auto merge of #78439 - lzutao:rm-clouldabi, r=Mark-Simulacrum 2020-11-23 19:01:19 +00:00
rt.rs
time.rs Drop support for cloudabi targets 2020-11-22 17:11:41 -05:00