Skip to content

Comments

Enable clippy lints for transmutes#7673

Open
robertbastian wants to merge 1 commit intounicode-org:mainfrom
robertbastian:transmutes
Open

Enable clippy lints for transmutes#7673
robertbastian wants to merge 1 commit intounicode-org:mainfrom
robertbastian:transmutes

Conversation

@robertbastian
Copy link
Member

And clean up a lot of transmutes.

Copy link
Member

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

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

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)
Copy link
Member

Choose a reason for hiding this comment

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

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()) }
Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Member

Choose a reason for hiding this comment

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

(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()) }
Copy link
Member

Choose a reason for hiding this comment

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

nit: safety comments here too

Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants