Enable clippy lints for transmutes#7673
Enable clippy lints for transmutes#7673robertbastian wants to merge 1 commit intounicode-org:mainfrom
Conversation
0b7b5ef to
be1a005
Compare
be1a005 to
e53948d
Compare
Manishearth
left a comment
There was a problem hiding this comment.
I'm not sure of the value of clippy::transmute_ptr_to_ptr, I think I find the transmute call easier to read.
|
|
||
| unsafe { ::core::ptr::read(ptr) } | ||
| unsafe fn make(from: Self::Output) -> Self { | ||
| ::core::mem::transmute::<Self::Output, Self>(from) |
There was a problem hiding this comment.
worry: I'm not convinced this will always work. Probably fine, can revert if it's a problem.
| let word = self.0; | ||
| let result = word | (((word + 0x3f3f_3f3f) & !(word + 0x2525_2525) & 0x8080_8080) >> 2); | ||
| Self(result) | ||
| unsafe { AsciiByte::to_ascii_byte_array(&result.to_ne_bytes()) } |
There was a problem hiding this comment.
nit: safety comments, please. I legitimately don't understand what's going on here, safety wise.
Sufficient to prove that the above does not produce anything out of range, don't need to prove that it actually lowercases.
There was a problem hiding this comment.
(yes, I know the previous code was worse)
| & 0x8080_8080_8080_8080) | ||
| >> 2); | ||
| Self(result) | ||
| unsafe { AsciiByte::to_ascii_byte_array(&result.to_ne_bytes()) } |
There was a problem hiding this comment.
nit: safety comments here too
sffc
left a comment
There was a problem hiding this comment.
Lots of unsafe code changing here. I will default to letting @Manishearth review all this but let me know if you want an extra look.
And clean up a lot of transmutes.