Skip to content

Address issues with rustc 1.65 #31

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

Merged
merged 2 commits into from
Nov 14, 2022
Merged

Address issues with rustc 1.65 #31

merged 2 commits into from
Nov 14, 2022

Conversation

glandium
Copy link
Contributor

@glandium glandium commented Nov 4, 2022

Fixes #30

Copy link
Contributor

@baumanj baumanj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure there are other places where the isize::MAX limit of allocations needs updating (like tryhashmap_oom). It might be worth making a crate-level constant like MAX_ALLOCATION = isize::MAX as usize and using that as a point to explain the limit and link to supporting documentation.

Comment on lines +850 to +853
match FallibleVec::try_reserve(&mut vec, core::usize::MAX / std::mem::size_of::<char>()) {
Ok(_) => panic!("it should be OOM"),
_ => (),
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recognize this matches the existing code, but it strikes me as odd to use a match here rather than a simple assert like

Suggested change
match FallibleVec::try_reserve(&mut vec, core::usize::MAX / std::mem::size_of::<char>()) {
Ok(_) => panic!("it should be OOM"),
_ => (),
}
assert!(FallibleVec::try_reserve(&mut vec, core::usize::MAX / std::mem::size_of::<char>()).is_err());

For the sake of clarity, it seems worth changing both to the more idiomatic approach.

Also, based on https://rust-lang.github.io/unsafe-code-guidelines/layout/scalars.html#isize-and-usize, should this be testing the tighter bound of isize::MAX?

@vcombey vcombey merged commit 5be7cd9 into vcombey:master Nov 14, 2022
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.

Issues with rust 1.65
3 participants