diff options
| author | bors <bors@rust-lang.org> | 2017-08-23 13:46:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-08-23 13:46:14 +0000 |
| commit | 2bb8fca18215298487a8684a132da828fdb5a751 (patch) | |
| tree | 85c998b7c0ca6f5f97226790c95650e843566882 /src/libstd/path.rs | |
| parent | a3f0ee9a7b17d522bfc6385f841d040445730f28 (diff) | |
| parent | 96efcdf0657004e48a279a469c42fe3097b2e8be (diff) | |
| download | rust-2bb8fca18215298487a8684a132da828fdb5a751.tar.gz rust-2bb8fca18215298487a8684a132da828fdb5a751.zip | |
Auto merge of #44058 - frewsxcv:rollup, r=frewsxcv
Rollup of 8 pull requests - Successful merges: #43631, #43977, #43983, #44016, #44039, #44043, #44047, #44054 - Failed merges:
Diffstat (limited to 'src/libstd/path.rs')
| -rw-r--r-- | src/libstd/path.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 680bb057858..830b9dc475d 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -323,6 +323,11 @@ unsafe fn u8_slice_as_os_str(s: &[u8]) -> &OsStr { mem::transmute(s) } +// Detect scheme on Redox +fn has_redox_scheme(s: &[u8]) -> bool { + cfg!(target_os = "redox") && s.split(|b| *b == b'/').next().unwrap_or(b"").contains(&b':') +} + //////////////////////////////////////////////////////////////////////////////// // Cross-platform, iterator-independent parsing //////////////////////////////////////////////////////////////////////////////// @@ -1685,8 +1690,12 @@ impl Path { #[stable(feature = "rust1", since = "1.0.0")] #[allow(deprecated)] pub fn is_absolute(&self) -> bool { - // FIXME: Remove target_os = "redox" and allow Redox prefixes - self.has_root() && (cfg!(unix) || cfg!(target_os = "redox") || self.prefix().is_some()) + if !cfg!(target_os = "redox") { + self.has_root() && (cfg!(unix) || self.prefix().is_some()) + } else { + // FIXME: Allow Redox prefixes + has_redox_scheme(self.as_u8_slice()) + } } /// Returns `true` if the `Path` is relative, i.e. not absolute. @@ -2050,7 +2059,8 @@ impl Path { Components { path: self.as_u8_slice(), prefix, - has_physical_root: has_physical_root(self.as_u8_slice(), prefix), + has_physical_root: has_physical_root(self.as_u8_slice(), prefix) || + has_redox_scheme(self.as_u8_slice()), front: State::Prefix, back: State::Body, } |
