Skip to content

Conversation

@agmbk
Copy link

@agmbk agmbk commented Feb 6, 2026

Ensure that String and &String compute identical hashes, as well as OsStr and Path.

To resolve this, a recursive macro implements up to five &&&&& for each specialized type. String types are also included.

Previously the tests were passing only because a known type was used (ex. str::get_hash). This bypassed the type resolution occurring in generic interfaces, and missed the fact that references &String type fallback to the default implementation.

This is now verified by testing on the hash_one method that lets the compiler infers the type.

agmbk added 2 commits February 6, 2026 08:17
Ensure that `String` and `&String` compute identical hashes, as well as `OsStr` and `Path`.

To resolve this, a recursive macro implements up to five `&&&&&` for each specialized type. `String` types are also included.

Previously the tests were passing only because a known type was used (ex. `str::get_hash`). This bypassed the type resolution occurring in generic interfaces, and missed the fact that references `&String` type fallback to the default implementation.

 This is now verified by testing on the `hash_one` method that lets the compiler infers the type.
@agmbk
Copy link
Author

agmbk commented Feb 7, 2026

As a side note, the current implementation is really leaky and leads to hard-to-track-down behaviors. It is virtually impossible to predict every combination of references and types, not even considering user custom types (e.g., MyString(String)) that will fail to integrate seamlessly with the specialization.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant