Skip to content

Fix unsound_collection_transmute #8648

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

Merged
merged 1 commit into from
Apr 8, 2022

Conversation

Jarcho
Copy link
Contributor

@Jarcho Jarcho commented Apr 6, 2022

fixes #7706

changelog: Better check size and alignment requirements in unsound_collection_transmute

@rust-highfive
Copy link

r? @xFrednet

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Apr 6, 2022
Copy link
Member

@xFrednet xFrednet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thank you for the fix

@xFrednet
Copy link
Member

xFrednet commented Apr 8, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Apr 8, 2022

📌 Commit d5e887c has been approved by xFrednet

@bors
Copy link
Contributor

bors commented Apr 8, 2022

⌛ Testing commit d5e887c with merge b029a86...

@bors
Copy link
Contributor

bors commented Apr 8, 2022

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: xFrednet
Pushing b029a86 to master...

@bors bors merged commit b029a86 into rust-lang:master Apr 8, 2022
@Kixiron
Copy link
Member

Kixiron commented Jun 18, 2022

This is an incorrect "fix", the layout of Vec is not specified so Vec<T> and Vec<MaybeUninit<T>> can have different layouts

@Jarcho
Copy link
Contributor Author

Jarcho commented Jun 18, 2022

True, but the lint isn't to check for that. It's to check for when the contained type has a different size/alignment. The Vec toVec transmute is formally unsound, but "works" (In this case, works in every version of rust so far).

The transmute_undefined_repr lint catches the rest. It's in the nursery now, but at some point it'll work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vec<MaybeUninit<u8>> transmute to Vec<u8>
5 participants