-
Notifications
You must be signed in to change notification settings - Fork 359
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
Miri complains about undefined behavior when using index_mut
instead of square brackets to access disjoined array elements
#2906
Comments
This is a known weakness of Stacked Borrows, but is intentional: Tree Borrows handles such situations better than Stacked Borrows. Can you check whether (For the time being it is preferable to make your code work with both Stacked Borrows and Tree Borrows; we are considering both of these models to evaluate their trade-off: Tree Borrows sacrifices some optimizations to make this code legal.) |
But nominally, square bracket array access desugars to
|
At the MIR level for arrays and slices |
Yeah, primitive indexing is special. Tree Borrows doesn't fundamentally fix that specialness, it just makes the Closing as an instance of rust-lang/unsafe-code-guidelines#133. |
Right, I had heard about that and was wondering if it was related. So the first inner block in |
As far as I am concerned it is not a feature but just a fact we have to learn to live with. E.g. |
This code:
has Miri report an invalid retag at the second
std::mem::swap
even though the first and second code block look like they should be equivalent at least semantically. Error message:Is this a Miri bug, or somehow intentional?
The text was updated successfully, but these errors were encountered: