Make test ptr::slice_mut compliant with Tree Borrows #68
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.
Tree Borrows is a new aliasing model for Rust, which features more precise tracking of pointer aliasing. The aim is to be more lenient than Stacked Borrows, while also having less dirty hacks than SB had.
It turns out that the test
ptr::slice_mut
here relied on one such hack.The problematic code is here:
soa-derive/tests/ptr.rs
Lines 77 to 93 in ad918be
slice::as_mut_ptr()
, which (internally) creates a new mutable reference. This means that the resulting pointer can not be mixed with accesses to the original slice.However, the test does so: It first uses the pointer, then the original slice, and then again the pointer. The proper solution is to re-derive the pointer when it's needed again, which is what this PR does.