Merged
Conversation
The previous use of `get_unchecked` was UB according to https://doc.rust-lang.org/nightly/std/primitive.slice.html#safety-2 and rust-lang/rust#120594 exposed this leading to a panic caught by out tests as: ``` cargo test --all ... thread 'fold::tests::ident_transformation_in_defs' panicked at library/core/src/panicking.rs:155:5: unsafe precondition(s) violated: hint::assert_unchecked must never be called when the condition is false thread caused non-unwinding panic. aborting. error: test failed, to rerun pass `-p garando_syntax --lib` ... ``` Fixes rust-lang/rust#120910
jsirois
commented
Feb 12, 2024
| // move the read_i'th item out of the vector and map it | ||
| // to an iterator | ||
| let e = ptr::read(self.get_unchecked(read_i)); | ||
| let e = ptr::read(self.as_mut_ptr().offset(read_i as isize)); |
Contributor
Author
There was a problem hiding this comment.
I did not comment these casts but I'm a noob to this sort of manipulation in Rust.
My reading of https://doc.rust-lang.org/reference/type-layout.html#primitive-data-layout, though, particularly "usize and isize have a size big enough to contain every address on the target platform.", seems to suggest this is always OK.
|
@JohnTitor Would it be possible to get a new release of garando_syntax with this change? It seems like there are some other unreleased changes, like 5c993df, which is a semver breakage and might also require a new version of ctest2? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The previous use of
get_uncheckedwas UB according tohttps://doc.rust-lang.org/nightly/std/primitive.slice.html#safety-2
and rust-lang/rust#120594 exposed this leading
to a panic caught by tests as:
Fixes rust-lang/rust#120910