Skip to content

Commit 5b8fe3e

Browse files
committed
Move platform-specific implementation of libstd/path.rs
This removes one exception in the tidy lint 'pal'.
1 parent 491b978 commit 5b8fe3e

File tree

5 files changed

+6
-3
lines changed

5 files changed

+6
-3
lines changed

src/libstd/path.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ use ops::{self, Deref};
127127

128128
use ffi::{OsStr, OsString};
129129

130-
use sys::path::{is_sep_byte, is_verbatim_sep, MAIN_SEP_STR, parse_prefix};
130+
use sys::path::{ABSOLUTE_NEEDS_PREFIX, is_sep_byte, is_verbatim_sep, MAIN_SEP_STR, parse_prefix};
131131

132132
////////////////////////////////////////////////////////////////////////////////
133133
// GENERAL NOTES
@@ -1509,7 +1509,7 @@ impl Path {
15091509
#[allow(deprecated)]
15101510
pub fn is_absolute(&self) -> bool {
15111511
// FIXME: Remove target_os = "redox" and allow Redox prefixes
1512-
self.has_root() && (cfg!(unix) || cfg!(target_os = "redox") || self.prefix().is_some())
1512+
self.has_root() && (!ABSOLUTE_NEEDS_PREFIX || self.prefix().is_some())
15131513
}
15141514

15151515
/// A path is *relative* if it is not absolute.

src/libstd/sys/redox/path.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,5 @@ pub fn parse_prefix(path: &OsStr) -> Option<Prefix> {
3737

3838
pub const MAIN_SEP_STR: &'static str = "/";
3939
pub const MAIN_SEP: char = '/';
40+
// FIXME: Change to 'true' and allow Redox prefixes
41+
pub const ABSOLUTE_NEEDS_PREFIX: bool = false;

src/libstd/sys/unix/path.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ pub fn parse_prefix(_: &OsStr) -> Option<Prefix> {
2727

2828
pub const MAIN_SEP_STR: &'static str = "/";
2929
pub const MAIN_SEP: char = '/';
30+
pub const ABSOLUTE_NEEDS_PREFIX: bool = false;

src/libstd/sys/windows/path.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,4 @@ pub fn parse_prefix<'a>(path: &'a OsStr) -> Option<Prefix> {
106106

107107
pub const MAIN_SEP_STR: &'static str = "\\";
108108
pub const MAIN_SEP: char = '\\';
109+
pub const ABSOLUTE_NEEDS_PREFIX: bool = true;

src/tools/tidy/src/pal.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ const EXCEPTION_PATHS: &'static [&'static str] = &[
6666

6767
// temporary exceptions
6868
"src/libstd/rtdeps.rs", // Until rustbuild replaces make
69-
"src/libstd/path.rs",
7069
"src/libstd/f32.rs",
7170
"src/libstd/f64.rs",
7271
"src/libstd/sys_common/mod.rs",

0 commit comments

Comments
 (0)