mirror of
https://github.com/RGBCube/cstree
synced 2025-07-27 09:07:44 +00:00
Fix Stacked Borrows violations (Miri) (#37)
Co-authored-by: Domenic Quirl <DomenicQuirl@protonmail.com>
This commit is contained in:
parent
2ffeb0e166
commit
21dcf99f04
2 changed files with 6 additions and 12 deletions
|
@ -21,7 +21,7 @@ fxhash = "0.2.1"
|
|||
parking_lot = "0.11.2"
|
||||
|
||||
# Arc
|
||||
triomphe = "0.1.3"
|
||||
triomphe = "0.1.7"
|
||||
sptr = "0.3.2"
|
||||
|
||||
[dependencies.serde]
|
||||
|
|
|
@ -170,15 +170,6 @@ impl<L: Language, D> SyntaxNode<L, D> {
|
|||
unsafe { &*self.data }
|
||||
}
|
||||
|
||||
/// # Safety:
|
||||
/// Caller must ensure that the access to the underlying data is unique (no active _mutable or immutable_
|
||||
/// references).
|
||||
#[inline]
|
||||
#[allow(clippy::mut_from_ref)]
|
||||
unsafe fn data_mut(&self) -> &mut NodeData<L, D> {
|
||||
&mut *self.data
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(super) fn clone_uncounted(&self) -> Self {
|
||||
Self { data: self.data }
|
||||
|
@ -346,8 +337,11 @@ impl<L: Language, D> SyntaxNode<L, D> {
|
|||
Kind::Root(green, _resolver) => green.into(),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
// safety: we have just created `ret` and have not shared it
|
||||
unsafe { ret.data_mut() }.green = green;
|
||||
// safety: we have just created `ret` and have not shared it.
|
||||
// Also, we use `addr_of_mut` here in order to not have to go through a `&mut *ret.data`,
|
||||
// which would invalidate the reading provenance of `green`, since `green` is contained in
|
||||
// the date once we have written it here.
|
||||
unsafe { ptr::addr_of_mut!((*ret.data).green).write(green) };
|
||||
ret
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue