We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4f5ed82 commit 425432bCopy full SHA for 425432b
src/bytes.rs
@@ -1940,8 +1940,11 @@ impl Inner {
1940
1941
#[inline]
1942
fn inline_len(&self) -> usize {
1943
- let p: &usize = unsafe { mem::transmute(&self.arc) };
1944
- (p & INLINE_LEN_MASK) >> INLINE_LEN_OFFSET
+ // This is undefind behavior due to a data race, but experimental
+ // evidence shows that it works in practice (discussion:
1945
+ // https://internals.rust-lang.org/t/bit-wise-reasoning-for-atomic-accesses/8853).
1946
+ let p: *const usize = unsafe { mem::transmute(&self.arc) };
1947
+ (unsafe { *p } & INLINE_LEN_MASK) >> INLINE_LEN_OFFSET
1948
}
1949
1950
/// Set the length of the inline buffer. This is done by writing to the
0 commit comments