Skip to content

Eq returns true but hashes are different for some verbatim paths on Windows #161651

Description

@sunshowers

I tried this code (on Windows):

use std::{
    hash::{BuildHasher, RandomState},
    path::Path,
};

fn main() {
    let path1 = Path::new(r"\\?\C:/foo");
    let path2 = Path::new(r"\\?\C:\foo");

    let hasher = RandomState::new();

    println!("{path1:?} == {path2:?}: {}", path1 == path2);
    println!(
        "hash({path1:?}) == hash({path2:?}): {}",
        hasher.hash_one(path1) == hasher.hash_one(path2)
    );
}

I expected to see this happen:

"\\\\?\\C:/foo" == "\\\\?\\C:\\foo": false
hash("\\\\?\\C:/foo") == hash("\\\\?\\C:\\foo"): false

i.e paths to not be equal, since these are UNC paths that should not be normalized.

Instead, this happened:

"\\\\?\\C:/foo" == "\\\\?\\C:\\foo": true
hash("\\\\?\\C:/foo") == hash("\\\\?\\C:\\foo"): false

This violates the requirement that if two values of a type are equal, their corresponding hashes should be equal.

Meta

rustc --version --verbose:

rustc 1.100.0-nightly (fb6531d55 2026-08-23)
binary: rustc
commit-hash: fb6531d550e0075b9eb9a51464f404805eec87d9
commit-date: 2026-08-23
host: aarch64-pc-windows-msvc
release: 1.100.0-nightly
LLVM version: 23.1.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.O-windowsOperating system: WindowsT-libsRelevant to the library team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions