about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--library/std/src/path.rs8
-rw-r--r--library/std/src/sys/unix/path.rs1
2 files changed, 9 insertions, 0 deletions
diff --git a/library/std/src/path.rs b/library/std/src/path.rs
index 7e1135365cd..cf2cd5adc48 100644
--- a/library/std/src/path.rs
+++ b/library/std/src/path.rs
@@ -2892,6 +2892,14 @@ impl cmp::PartialEq for Path {
 impl Hash for Path {
     fn hash<H: Hasher>(&self, h: &mut H) {
         let bytes = self.as_u8_slice();
+        let prefix_len = match parse_prefix(&self.inner) {
+            Some(prefix) => {
+                prefix.hash(h);
+                prefix.len()
+            }
+            None => 0,
+        };
+        let bytes = &bytes[prefix_len..];
 
         let mut component_start = 0;
         let mut bytes_hashed = 0;
diff --git a/library/std/src/sys/unix/path.rs b/library/std/src/sys/unix/path.rs
index 840a7ae0426..717add9ec48 100644
--- a/library/std/src/sys/unix/path.rs
+++ b/library/std/src/sys/unix/path.rs
@@ -11,6 +11,7 @@ pub fn is_verbatim_sep(b: u8) -> bool {
     b == b'/'
 }
 
+#[inline]
 pub fn parse_prefix(_: &OsStr) -> Option<Prefix<'_>> {
     None
 }