Skip to content

Commit

Permalink
rust/cxx: Fix clippy lint around use of transmute
Browse files Browse the repository at this point in the history
Casting the pointer and then synthesizing a reference from it
is apparently better:

https://rust-lang.github.io/rust-clippy/stable/index.html#transmute_ptr_to_ref
  • Loading branch information
cgwalters committed Aug 1, 2022
1 parent bcf5588 commit 9cf99ad
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion rust/src/cxxrsutil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ macro_rules! impl_wrap {

fn reborrow_cxx(&'a self) -> &Self::ReWrapped {
let p: *const $sys = self.to_glib_none().0;
unsafe { std::mem::transmute(p) }
let p = p as *const Self::ReWrapped;
unsafe { &*p }
}
}
};
Expand Down

0 comments on commit 9cf99ad

Please sign in to comment.