Stream: t-lang/wg-unsafe-code-guidelines

Topic: Common Stacked Borrows violations


RalfJ (May 28 2019 at 11:11, on Zulip):

I found that two kinds of Stacked Borrows errors are particularly common: creating &mut that accidentally "kill" other pointers (might also happen with & but seems to be less of an issue there), and casting a reference to a raw pointer that laters gets used to access things "next to" that reference (most common: using &slice[0] as *const _ instead of slice.as_ptr()). I collected those here and here. If you know other cases of these, please let me know!

In particular I feel I have seen more of these "slice" issues... was that in questions by you @Jake Goulding ?

Jake Goulding (May 28 2019 at 12:51, on Zulip):

I don't recall there being multiple. Just this most recent one

RalfJ (May 28 2019 at 12:54, on Zulip):

that would be the "too much asserting of uniqueness" thing then, not "too weak raw ptrs"

RalfJ (May 28 2019 at 12:54, on Zulip):

I thought I had more cases of as_ptr elsewhere... maybe I misremember.

Last update: Nov 20 2019 at 13:40UTC