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

Weird definition of overlap #372

Open
Darksonn opened this issue Oct 27, 2022 · 2 comments
Open

Weird definition of overlap #372

Darksonn opened this issue Oct 27, 2022 · 2 comments

Comments

@Darksonn
Copy link

You define overlap as

Two values overlap when their memory locations overlap, or both values are elements of the same array.

So even if they don't overlap in memory location, but are part of the same array, they are still considered to overlap. However, you then define:

While a mutable reference is active, no other reference shall refer to a value that overlaps with the referent of the mutable reference.

But mutable references to arrays can usually be split into several references if they don't overlap in the conventional sense, but this contradicts the definition with arrays.

@jonas-schievink
Copy link
Contributor

Yeah, these rules only apply when borrow checking manually created references, so we should clarify that. &mut a[0] and &mut a[1] conflict, but let [x,y,..] = a is fine (and so is an unsafe implementation like split_at_mut).

@Veykril
Copy link
Member

Veykril commented Aug 4, 2023

We should re-phrase this in general. Phrasing this in terms of values seems a bit odd, we also don't specify that this is a borrowing restriction as outlined by Jonas.

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

No branches or pull requests

3 participants