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

Add sound implementation of Bytes for &[u8] #308

Closed
Thomasdezeeuw opened this issue Oct 15, 2020 · 2 comments · Fixed by #415
Closed

Add sound implementation of Bytes for &[u8] #308

Thomasdezeeuw opened this issue Oct 15, 2020 · 2 comments · Fixed by #415
Labels
enhancement An improvement of the API. priority:medium Medium priority issue.
Milestone

Comments

@Thomasdezeeuw
Copy link
Owner

See rust-lang/rfcs#2930 (comment) and rust-lang/rfcs#2930 (comment).

Example:

let mut buf = [0u8];
let maybe = unsafe { &mut *((&mut buf) as *mut [u8] as *mut [MaybeUninit<u8>]) };
// After this line `buf` will contain uninitialized value, which is UB
maybe[0] = MaybeUninit::uninit();
@Thomasdezeeuw Thomasdezeeuw added bug A problem. priority:high High priority issue. labels Oct 15, 2020
Thomasdezeeuw added a commit that referenced this issue Oct 18, 2020
@Thomasdezeeuw
Copy link
Owner Author

This should also revert all the changes in the tests/docs from 4f8731c.

@Thomasdezeeuw Thomasdezeeuw changed the title Bytes::as_bytes implementation for &[u8] is unsound Add sound implementation of Bytes for &[u8] Nov 23, 2020
@Thomasdezeeuw Thomasdezeeuw added enhancement An improvement of the API. and removed bug A problem. priority:high High priority issue. labels Nov 23, 2020
@Thomasdezeeuw
Copy link
Owner Author

Changing to issue to track adding back an implementation of Bytes for &[u8].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement of the API. priority:medium Medium priority issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant