Skip to content
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

Remove an unnecessary transmute from opaque::Encoder #93456

Merged
merged 1 commit into from
Feb 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions compiler/rustc_serialize/src/opaque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ impl serialize::Encoder for Encoder {

#[inline]
fn emit_i8(&mut self, v: i8) -> EncodeResult {
let as_u8: u8 = unsafe { std::mem::transmute(v) };
self.emit_u8(as_u8)
self.emit_u8(v as u8)
}

#[inline]
Expand Down Expand Up @@ -629,9 +628,9 @@ impl<'a> serialize::Decoder for Decoder<'a> {

#[inline]
fn read_i8(&mut self) -> i8 {
let as_u8 = self.data[self.position];
let value = self.data[self.position];
self.position += 1;
unsafe { ::std::mem::transmute(as_u8) }
value as i8
}

#[inline]
Expand Down