Skip to content

Commit 2293886

Browse files
committed
Minor fixes
1 parent 7d36c5f commit 2293886

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/diff/graph.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub struct SyntaxRefOrId<'a> {
3535
phantom: PhantomData<&'a Syntax<'a>>,
3636
}
3737

38-
impl SyntaxRefOrId<'_> {
38+
impl<'a> SyntaxRefOrId<'a> {
3939
pub fn is_ref(&self) -> bool {
4040
self.data & 1 == 0
4141
}
@@ -44,7 +44,7 @@ impl SyntaxRefOrId<'_> {
4444
self.data & 1 == 1
4545
}
4646

47-
pub fn get_ref<'a>(&self) -> Option<&'a Syntax<'a>> {
47+
pub fn get_ref(&self) -> Option<&'a Syntax<'a>> {
4848
if self.is_ref() {
4949
Some(unsafe { transmute_copy(&self.data) })
5050
} else {
@@ -56,7 +56,7 @@ impl SyntaxRefOrId<'_> {
5656
impl<'a> From<&'a Syntax<'a>> for SyntaxRefOrId<'a> {
5757
fn from(s: &'a Syntax<'a>) -> Self {
5858
Self {
59-
data: unsafe { transmute_copy(&s) },
59+
data: s as *const _ as _,
6060
phantom: PhantomData,
6161
}
6262
}
@@ -77,10 +77,8 @@ fn next_sibling_syntax<'a>(syntax: &'a Syntax<'a>) -> SyntaxRefOrId<'a> {
7777
}
7878

7979
fn next_child_syntax<'a>(syntax: &'a Syntax<'a>, children: &[&'a Syntax<'a>]) -> SyntaxRefOrId<'a> {
80-
children
81-
.get(0)
82-
.copied()
83-
.map_or(Some(syntax.id()).into(), |s| s.into())
80+
let child = children.get(0).copied();
81+
child.map_or(Some(syntax.id()).into(), |s| s.into())
8482
}
8583

8684
/// A vertex in a directed acyclic graph that represents a diff.

0 commit comments

Comments
 (0)