Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mitigate 128-bit TypeId hash #300

Closed
wants to merge 2 commits into from
Closed

Conversation

direc85
Copy link
Contributor

@direc85 direc85 commented Aug 27, 2023

Obviously, this breaks Rust <1.72, but I couldn't find a neat way to conditionally include the changes using. It doesn't seem to be possible to have something like #[cfg(version >= "1.72")] or #[cfg(TYPE_ID_SIZE == 16)], or perhaps I just didn't find the correct keyword to use.

Not sure if either method is good enough for master, but at least there's something that works:

Approach 1: unsafe { transmute }

Approach 2: Custom hasher which utilizes TypeId.hash() which internally casts u128u64

Improvements and further ideas welcome 😅

Fixes #299

@rubdos
Copy link
Contributor

rubdos commented Aug 27, 2023

Would it not be better to upsize the older Rust types, instead of chopping the new one?

@direc85
Copy link
Contributor Author

direc85 commented Aug 27, 2023

As said in the issue, this is fixed already in master, I'm only affected because I'm running 0.2.5-ish due to Rust 1.52.1. Closing as irrelevant.

@direc85 direc85 closed this Aug 27, 2023
@ogoffart
Copy link
Member

thanks for your patch anyway.

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.

Compilation fails with Rust 1.72
3 participants