Skip to content

Code in E0139 explanation is not valid anymore #27946

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

Closed
nagisa opened this issue Aug 22, 2015 · 1 comment
Closed

Code in E0139 explanation is not valid anymore #27946

nagisa opened this issue Aug 22, 2015 · 1 comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@nagisa
Copy link
Member

nagisa commented Aug 22, 2015

let result: SomeType = mem::uninitialized();
unsafe { copy_nonoverlapping(&v, &result) };
result // `v` transmuted to type `SomeType`

std::ptr::copy_nonoverlapping takes 3 arguments, but only 2 are provided. It also does not typecheck anymore either.

@steveklabnik steveklabnik added A-docs E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. labels Aug 24, 2015
@apasel422
Copy link
Contributor

I think this example should just be removed, as std::ptr::copy_nonoverlapping requires its source and destination types to be the same. For a "real" manual transmute, someone could transmute the pointers to *const u8 and *mut u8 and then pass the correct number of bytes as the third argument to that function.

nagisa added a commit to nagisa/rust that referenced this issue Aug 24, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Aug 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

3 participants