Skip to content

Commit

Permalink
Remove transmute_copy
Browse files Browse the repository at this point in the history
  • Loading branch information
QuarticCat committed Sep 30, 2022
1 parent b0ab6c8 commit 5043858
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/diff/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use std::{
cmp::min,
hash::{Hash, Hasher},
marker::PhantomData,
mem::transmute_copy,
};
use strsim::normalized_levenshtein;

Expand Down Expand Up @@ -45,7 +44,7 @@ impl<'a> SyntaxRefOrId<'a> {

pub fn get_ref(&self) -> Option<&'a Syntax<'a>> {
if self.is_ref() {
Some(unsafe { transmute_copy(&self.data) })
Some(unsafe { &*(self.data as *const _) })
} else {
None
}
Expand Down Expand Up @@ -230,9 +229,9 @@ pub struct EnteredDelimiter<'a> {
impl<'a> From<&EnteredDelimiter<'a>> for EnteredDelimiterEnum<'a> {
fn from(delim: &EnteredDelimiter<'a>) -> Self {
if delim.data & 1 == 0 {
PopEither(unsafe { transmute_copy(&delim.data) })
PopEither(unsafe { &*(delim.data as *const _) })
} else {
PopBoth(unsafe { transmute_copy(&(delim.data ^ 1)) })
PopBoth(unsafe { &*((delim.data ^ 1) as *const _) })
}
}
}
Expand Down

0 comments on commit 5043858

Please sign in to comment.