Closed
Description
This is some drive by code review as requested 😄
Issue 1) It looks like the code is not correctly connecting the lifetime of the borrow of the slice with the lifetime that belongs to the reference that comes from the transmute. Here's a testcase that shows an aliasing violation.. we can mutate the data while we have a reference to it!
By the way, for pointers, prefer just using casts instead of transmuting. The same caveat with lifetimes still applies though.
The best way to make sure the lifetimes match up is using a function. For example like copy_lifetime
, a function you can copy.
Issue 2) Unrestricted transmute. The user's type parameter is trusted, and the user can get bogus results by giving the wrong type.
Metadata
Metadata
Assignees
Labels
No labels