-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Transmute cleanup #18318
Transmute cleanup #18318
Conversation
d80fad6
to
ec8782a
Compare
index: &mut Vec<entry<i64>>) { | ||
let mut rbml_w = unsafe { rbml_w.unsafe_clone() }; | ||
// See above | ||
let ecx: &EncodeContext = unsafe { mem::transmute(ecx_ptr) }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoa, so glad to see this gone 😍
LGTM, but there's enough unsafe code here that I'd like a second look. |
@@ -798,7 +786,8 @@ fn get_metadata_section_imp(os: abi::Os, filename: &Path) -> Result<MetadataBlob | |||
let csz = llvm::LLVMGetSectionSize(si.llsi) as uint; | |||
let mut found = | |||
Err(format!("metadata not found: '{}'", filename.display())); | |||
let cvbuf: *const u8 = mem::transmute(cbuf); | |||
let cvbuf: *const u8 = mem::transmute::<*const i8, | |||
*const u8>(cbuf); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need to be a transmute
a simple as
cast should work.
ec8782a
to
1cd9de6
Compare
Some of the transmutes here are DST-related and are waiting for a new snapshot with #17178. |
@arielb1 should the r+ be removed until new snapshot lands? |
This PR is snapshot-independent. Some further cleanup is waiting on #18291. |
1cd9de6
to
795d563
Compare
@arielb1 looks like this needs to be rebased |
None of them would break by implementation-defined struct layout, but one would break with strict lifetime aliasing, and the rest are just ugly code.
795d563
to
a87078a
Compare
clean-up transmutes in librustc and libsyntax