Fix cache key collisions for paths with separators (#12159)

Closes https://github.com/astral-sh/ruff/issues/12158

Hashing `Path` does not take into account path separators so `foo/bar`
is the same as `foobar` which is no good for our case. I'm guessing this
is an upstream bug, perhaps introduced by
45082b077b?
I'm investigating that further.
This commit is contained in:
Zanie Blue 2024-07-03 08:36:46 -04:00 committed by GitHub
parent b4f7d5b2fb
commit 47eb6ee42b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -350,7 +350,9 @@ impl<K: CacheKey + Ord, V: CacheKey> CacheKey for BTreeMap<K, V> {
impl CacheKey for Path {
#[inline]
fn cache_key(&self, state: &mut CacheKeyHasher) {
self.hash(&mut *state);
for component in self.components() {
component.hash(&mut *state);
}
}
}