commit_hash stringlengths 40 40 | author stringlengths 1 57 | date timestamp[s]date 2010-07-26 04:45:09 2026-04-14 18:21:10 | message stringlengths 8 1.39M | diff stringlengths 68 51.2k | files_changed int64 1 136 | insertions int64 0 2.35k | deletions int64 0 1.9k |
|---|---|---|---|---|---|---|---|
29c5674941801d8ece41795f2a68364a41aabbbb | Ifeanyi Orizu | 2025-09-09T19:21:54 | Add weaker UnwindSafe impls for shared Arc pointers
Following the example of the standard library, it is ok for shared
pointer types to be UnwindSafe when the pointee is only RefUnwindSafe.
This is because UnwindSafe's purpose is to warn against the possibility
of broken invariants being witnessed through the type, wh... | diff --git a/src/arc.rs b/src/arc.rs
index f0de431..1396826 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -11,6 +11,7 @@ use core::iter::FromIterator;
use core::marker::PhantomData;
use core::mem::{ManuallyDrop, MaybeUninit};
use core::ops::Deref;
+use core::panic::{RefUnwindSafe, UnwindSafe};
use core::ptr::{self, N... | 5 | 15 | 0 |
5ae7e641e20d6153ceefd0ff7f9a6b7dc159861e | Ifeanyi Orizu | 2025-09-09T16:03:51 | Add elided lifetimes to return types | diff --git a/src/arc_union.rs b/src/arc_union.rs
index 259aa4f..adf054b 100644
--- a/src/arc_union.rs
+++ b/src/arc_union.rs
@@ -62,7 +62,7 @@ impl<A, B> ArcUnion<A, B> {
}
/// Returns an enum representing a borrow of either A or B.
- pub fn borrow(&self) -> ArcUnionBorrow<A, B> {
+ pub fn borrow(&sel... | 1 | 3 | 3 |
7464b454450792e7bc029a08240c36a80647f714 | Geoffry Song | 2025-06-16T18:50:31 | Update comment around Arc::drop_inner fence
After #114 this is using a fence and not a load, so adjust the comment accordingly
(by copying the comment from the stdlib).
I removed upstream's comment about possibly using a load instead of a fence though; | diff --git a/src/arc.rs b/src/arc.rs
index e553dbc..f0de431 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -631,13 +631,11 @@ impl<T: ?Sized> Arc<T> {
return;
}
- // FIXME(bholley): Use the updated comment when [2] is merged.
- //
- // This load is needed to prevent reordering ... | 1 | 10 | 7 |
7501eda4977f400283e25bc408a012195e18a5e0 | cxworks | 2025-05-07T15:58:29 | Change the acq load to explict acq fence | diff --git a/src/arc.rs b/src/arc.rs
index b1179d5..e553dbc 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -651,7 +651,7 @@ impl<T: ?Sized> Arc<T> {
//
// [1]: (www.boost.org/doc/libs/1_55_0/doc/html/atomic/usage_examples.html)
// [2]: https://github.com/rust-lang/rust/pull/41714
- self.i... | 1 | 1 | 1 |
28f12907867e132128cfbc51678116579a9da623 | Toby Lawrence | 2025-01-04T20:24:43 | Address PR feedback. | diff --git a/src/arc.rs b/src/arc.rs
index 28d88d7..cf40380 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -13,7 +13,7 @@ use core::mem::{ManuallyDrop, MaybeUninit};
use core::ops::Deref;
use core::ptr::{self, NonNull};
use core::sync::atomic;
-use core::sync::atomic::Ordering::{Acquire, AcqRel, Relaxed, Release};
+use... | 1 | 37 | 9 |
5a20cd2418419a28bae8cd73d8da262cbd4e2713 | Frank Steffahn | 2025-01-02T21:58:29 | more comments on layout | diff --git a/src/thin_arc.rs b/src/thin_arc.rs
index 0a229d6..7158924 100644
--- a/src/thin_arc.rs
+++ b/src/thin_arc.rs
@@ -28,6 +28,18 @@ use crate::header::HeaderSliceWithLengthUnchecked;
/// via `HeaderSliceWithLengthProtected`.
#[repr(transparent)]
pub struct ThinArc<H, T> {
+ // We can pointer-cast between ... | 1 | 16 | 0 |
1d85bc2c6ebfe6f38971bf9f7e72fdd910cafb66 | Toby Lawrence | 2025-01-01T19:07:41 | get test running when std isn't disabled | diff --git a/src/arc.rs b/src/arc.rs
index 8c73723..28d88d7 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -1180,17 +1180,16 @@ mod tests {
assert_eq!(42, *arc_unique);
}
+ #[cfg(feature = "std")]
#[test]
fn into_unique_data_race() {
- use std::thread;
-
// Exists to be exercis... | 1 | 3 | 4 |
24911a8a27d45b8498a06c158edb0b0b33f60bf3 | Toby Lawrence | 2025-01-01T18:59:43 | tweak to compensate for 2015 edition | diff --git a/src/arc.rs b/src/arc.rs
index c2a9e33..8c73723 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -1182,13 +1182,15 @@ mod tests {
#[test]
fn into_unique_data_race() {
+ use std::thread;
+
// Exists to be exercised by Miri to check for data races.
let a = Arc::new(0);
... | 1 | 4 | 2 |
850939926b0f492781a0a343bda279fd4888f751 | Frank Steffahn | 2024-12-31T21:23:34 | Reword comment that still referenced str and the (removed) general non-slice case | diff --git a/src/header.rs b/src/header.rs
index 5afc418..c606fb2 100644
--- a/src/header.rs
+++ b/src/header.rs
@@ -256,8 +256,7 @@ impl<T> From<Vec<T>> for Arc<[T]> {
#[derive(Debug, Hash, Eq, PartialEq, Ord, PartialOrd)]
#[repr(transparent)]
pub struct HeaderSliceWithLengthProtected<H, T> {
- // Invariant: if ... | 1 | 1 | 2 |
479769a35c97086cff3375cbc92795dced1fb083 | Frank Steffahn | 2024-12-31T18:14:19 | unify ThinArc::into_raw and ::ptr implementations | diff --git a/src/thin_arc.rs b/src/thin_arc.rs
index 10ffa29..0a229d6 100644
--- a/src/thin_arc.rs
+++ b/src/thin_arc.rs
@@ -157,7 +157,7 @@ impl<H, T> ThinArc<H, T> {
/// within it -- for memory reporting.
#[inline]
pub fn ptr(&self) -> *const c_void {
- self.ptr.as_ptr() as *const ArcInner<T> as... | 1 | 2 | 2 |
5e9b442fd7e86b9776db0a5a52d02727ea34911d | Frank Steffahn | 2024-12-31T18:11:43 | Add debug-assertion of `protected_into_thin` also to `with_arc_mut` | diff --git a/src/thin_arc.rs b/src/thin_arc.rs
index dbb0a52..10ffa29 100644
--- a/src/thin_arc.rs
+++ b/src/thin_arc.rs
@@ -96,6 +96,16 @@ impl<H, T> ThinArc<H, T> {
impl<'a, H, T> Drop for DropGuard<'a, H, T> {
fn drop(&mut self) {
+ // This guard is only dropped when the same d... | 1 | 17 | 0 |
28f33f2f1d611ae2ea3efd038b4f819462472bd7 | Frank Steffahn | 2024-12-31T18:11:07 | limit direct accesses to ThinArc.ptr field, by making thin_to_thick do the access; also remove additional conversion step from Drop for ThinArc | diff --git a/src/thin_arc.rs b/src/thin_arc.rs
index 41c225a..dbb0a52 100644
--- a/src/thin_arc.rs
+++ b/src/thin_arc.rs
@@ -4,7 +4,6 @@ use core::fmt;
use core::hash::{Hash, Hasher};
use core::iter::{ExactSizeIterator, Iterator};
use core::marker::PhantomData;
-use core::mem;
use core::mem::ManuallyDrop;
use core... | 1 | 10 | 25 |
7bf5aa489a9d0828d0254db638240aaccfb7d3c2 | Frank Steffahn | 2024-12-31T16:59:27 | more consistent use of existing internal APIs | diff --git a/src/thin_arc.rs b/src/thin_arc.rs
index 8cbb37a..41c225a 100644
--- a/src/thin_arc.rs
+++ b/src/thin_arc.rs
@@ -279,7 +279,7 @@ impl<H, T> Arc<HeaderSliceWithLengthUnchecked<H, T>> {
#[inline]
fn from_protected(a: Arc<HeaderSliceWithLengthProtected<H, T>>) -> Self {
// Safety: HeaderSlic... | 1 | 7 | 17 |
5418c47cfbf5252434061c4c6f1086a2b7bf67cb | Frank Steffahn | 2024-12-31T16:48:52 | change HeaderSliceWithLen... to only contain actual slice type | diff --git a/src/header.rs b/src/header.rs
index e24fd89..5afc418 100644
--- a/src/header.rs
+++ b/src/header.rs
@@ -251,19 +251,19 @@ impl<T> From<Vec<T>> for Arc<[T]> {
///
/// Safety-usable invariants:
///
-/// - This is guaranteed to have the same representation as `HeaderSlice<HeaderWithLength<H>, T>` (i.e. `He... | 3 | 29 | 29 |
93aa3099a238ff06960d539721837e100766307e | Toby Lawrence | 2024-12-29T15:51:35 | Add Arc::into_unique for converting back to UniqueArc. | diff --git a/src/arc.rs b/src/arc.rs
index b1179d5..c2a9e33 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -13,7 +13,7 @@ use core::mem::{ManuallyDrop, MaybeUninit};
use core::ops::Deref;
use core::ptr::{self, NonNull};
use core::sync::atomic;
-use core::sync::atomic::Ordering::{Acquire, Relaxed, Release};
+use core::s... | 1 | 84 | 1 |
d2febb4a551f65b85fe85c5ac93601d9ef782852 | Manish Goregaokar | 2024-12-25T22:22:11 | Handle replacing | diff --git a/src/thin_arc.rs b/src/thin_arc.rs
index 4f7fddc..9778b39 100644
--- a/src/thin_arc.rs
+++ b/src/thin_arc.rs
@@ -107,7 +107,11 @@ impl<H, T> ThinArc<H, T> {
// Expose the transient Arc to the callback, which may clone it if it wants
// and forward the result to the user
- f(&mut t... | 1 | 5 | 1 |
3f421fd6b8f60747b10b53f3a68e49a9450326b1 | Manish Goregaokar | 2024-12-25T22:05:44 | protected | diff --git a/src/header.rs b/src/header.rs
index 5d14df9..e24fd89 100644
--- a/src/header.rs
+++ b/src/header.rs
@@ -255,15 +255,15 @@ impl<T> From<Vec<T>> for Arc<[T]> {
/// - For `T` that is `[U]` or `str`, the header length (`.length()` is checked to be the slice length)
#[derive(Debug, Hash, Eq, PartialEq, Ord, ... | 2 | 50 | 34 |
197193f1fbd1c19e973c668ad3d91601682bec96 | Manish Goregaokar | 2024-12-25T22:03:09 | rm alias | diff --git a/src/header.rs b/src/header.rs
index f2ba31b..4b3d13a 100644
--- a/src/header.rs
+++ b/src/header.rs
@@ -263,10 +263,6 @@ pub struct HeaderSliceWithLengthChecked<H, T: ?Sized> {
pub type HeaderSliceWithLengthUnchecked<H, T> = HeaderSlice<HeaderWithLength<H>, T>;
-// Backcompat alias for `HeaderSliceWit... | 1 | 0 | 4 |
1b65f3487ee04cb08ca6cde3ed42b7521c30953c | Manish Goregaokar | 2024-12-25T18:09:02 | Seprate HeaderSliceWithLength into checked and unchecked variants | diff --git a/src/header.rs b/src/header.rs
index 185231f..f2ba31b 100644
--- a/src/header.rs
+++ b/src/header.rs
@@ -245,17 +245,64 @@ impl<T> From<Vec<T>> for Arc<[T]> {
}
}
-pub(crate) type HeaderSliceWithLength<H, T> = HeaderSlice<HeaderWithLength<H>, T>;
+/// A type wrapping `HeaderSlice<HeaderWithLength<H>... | 3 | 133 | 40 |
d302445ffd9dc8a863dde1d4bec0894e114efa5f | Manish Goregaokar | 2024-12-25T17:46:41 | Revert "Add Arc::into_unique for converting back to UniqueArc."
This reverts commit 281803d38ddb5f8c8c06c9ad856883de81233884.
Reverts #103. See #106 | diff --git a/src/arc.rs b/src/arc.rs
index 8906254..b1179d5 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -146,56 +146,6 @@ impl<T> Arc<T> {
pub fn try_unwrap(this: Self) -> Result<T, Self> {
Self::try_unique(this).map(UniqueArc::into_inner)
}
-
- /// Converts the `Arc` to `UniqueArc` if the `Arc` h... | 1 | 0 | 67 |
9a9b2e1140efa4c0a6c384eaa89bb61d05061dd8 | Tristan Guichaoua | 2024-12-19T12:17:11 | implement `Serialize` and `Deserialize` for `UniqueArc` | diff --git a/src/unique_arc.rs b/src/unique_arc.rs
index 5afdd6c..14e2b8a 100644
--- a/src/unique_arc.rs
+++ b/src/unique_arc.rs
@@ -8,6 +8,9 @@ use core::ops::{Deref, DerefMut};
use core::ptr::{self, addr_of_mut, NonNull};
use core::sync::atomic::AtomicUsize;
+#[cfg(feature = "serde")]
+use serde::{Deserialize, Se... | 1 | 23 | 0 |
281803d38ddb5f8c8c06c9ad856883de81233884 | Toby Lawrence | 2024-11-25T16:50:48 | Add Arc::into_unique for converting back to UniqueArc. | diff --git a/src/arc.rs b/src/arc.rs
index b1179d5..8906254 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -146,6 +146,56 @@ impl<T> Arc<T> {
pub fn try_unwrap(this: Self) -> Result<T, Self> {
Self::try_unique(this).map(UniqueArc::into_inner)
}
+
+ /// Converts the `Arc` to `UniqueArc` if the `Arc` h... | 1 | 67 | 0 |
b5b1b05b721f1ee70baa25d0791405f89b435014 | Manish Goregaokar | 2024-10-14T16:15:38 | Make the actual read happen | diff --git a/src/arc.rs b/src/arc.rs
index 5c47d13..61bfd18 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -893,7 +893,7 @@ mod tests {
uninit.write(String::from("nonononono"));
// Read invalidated reference to trigger UB
- let _ = *x;
+ let _read = &*x;
}
#[test]
@@ -909,7 +9... | 1 | 2 | 2 |
a9614f96c0eb04818cea5f98416b05ca34d9e383 | GnomedDev | 2024-10-12T18:23:59 | Add may_dangle to Arc::drop conditionally | diff --git a/Cargo.toml b/Cargo.toml
index e111899..f742cb5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -15,6 +15,8 @@ rust-version = "1.76"
std = []
default = ["serde", "stable_deref_trait", "std"]
+unstable_dropck_eyepatch = []
+
[package.metadata.docs.rs]
all-features = true
diff --git a/src/arc.rs b/src/arc... | 3 | 21 | 4 |
3b66e099a5d9590fe48e57f2d6769c996702382f | GnomedDev | 2024-10-12T17:24:55 | Fix clippy warnings | diff --git a/src/arc.rs b/src/arc.rs
index 6b523f2..5c47d13 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -14,7 +14,6 @@ use core::ops::Deref;
use core::ptr::{self, NonNull};
use core::sync::atomic;
use core::sync::atomic::Ordering::{Acquire, Relaxed, Release};
-use core::{isize, usize};
#[cfg(feature = "serde")]
... | 4 | 6 | 12 |
c80cca43356de7109ec4fc3069c4e9e7ef971e6d | Manish Goregaokar | 2024-10-07T04:02:16 | Publish 0.1.14 | diff --git a/Cargo.toml b/Cargo.toml
index 819028d..e111899 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "triomphe"
-version = "0.1.13"
+version = "0.1.14"
authors = ["Manish Goregaokar <manishsmail@gmail.com>", "The Servo Project Developers"]
license = "MIT OR Apache-2.0"
repository =... | 1 | 1 | 1 |
879873ec3f96b5e217fc3d2c6e3d0d48dbce4acf | Arthur Silva | 2024-09-29T08:53:47 | Bump version to 0.1.13 | diff --git a/Cargo.toml b/Cargo.toml
index 8154716..819028d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "triomphe"
-version = "0.1.12"
+version = "0.1.13"
authors = ["Manish Goregaokar <manishsmail@gmail.com>", "The Servo Project Developers"]
license = "MIT OR Apache-2.0"
repository =... | 1 | 1 | 1 |
2fa198dbf25a1ed5c277c0177131754fcd9ee2bc | Arthur Silva | 2024-09-26T18:30:04 | incorporate review feedback | diff --git a/src/unique_arc.rs b/src/unique_arc.rs
index c49249f..5afdd6c 100644
--- a/src/unique_arc.rs
+++ b/src/unique_arc.rs
@@ -5,7 +5,7 @@ use core::iter::FromIterator;
use core::marker::PhantomData;
use core::mem::{ManuallyDrop, MaybeUninit};
use core::ops::{Deref, DerefMut};
-use core::ptr::{self, NonNull};
... | 1 | 15 | 14 |
e1b5c625ce2bce5d197aee111b61cad1f7efd406 | Arthur Silva | 2024-08-18T16:22:14 | Add UniqueArc::from_header_and_uninit_slice | diff --git a/src/unique_arc.rs b/src/unique_arc.rs
index 45a9e90..c49249f 100644
--- a/src/unique_arc.rs
+++ b/src/unique_arc.rs
@@ -183,6 +183,33 @@ impl<T> UniqueArc<[MaybeUninit<T>]> {
}
}
+impl<H, T> UniqueArc<HeaderSlice<H, [MaybeUninit<T>]>> {
+ /// Creates an Arc for a HeaderSlice using the given head... | 1 | 62 | 1 |
12f3f7b07d954c83ac456601d889c39c0bd6f6bb | Arthur Silva | 2024-08-18T16:23:56 | Add ThinArc::with_arc_mut | diff --git a/src/thin_arc.rs b/src/thin_arc.rs
index 61c529c..21a1430 100644
--- a/src/thin_arc.rs
+++ b/src/thin_arc.rs
@@ -69,6 +69,26 @@ impl<H, T> ThinArc<H, T> {
f(&transient)
}
+ /// Temporarily converts |self| into a bonafide Arc and exposes it to the
+ /// provided callback. The refcount i... | 1 | 50 | 0 |
626454bd93d323b964c54bcb7657998a2ba2e285 | Manish Goregaokar | 2024-06-17T18:50:50 | Bump to 0.1.13 | diff --git a/Cargo.toml b/Cargo.toml
index 8154716..819028d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "triomphe"
-version = "0.1.12"
+version = "0.1.13"
authors = ["Manish Goregaokar <manishsmail@gmail.com>", "The Servo Project Developers"]
license = "MIT OR Apache-2.0"
repository =... | 1 | 1 | 1 |
ba018d9a0a5338daa8fa5b4995d5d38ea593a012 | Simon Sapin | 2024-06-17T09:22:12 | Derive Copy and Clone HeaderSlice and HeaderWithLength
We (apollo-compiler) have an AST where most nodes are wrapped in,
approximately:
```rust
struct Node<T>(triomphe::Arc<(SourceSpan, T)>);
```
`Arc` allows subtrees to be shared without deep cloning,
and `Arc::make_mut` is used extensively for mutability
with clon... | diff --git a/src/header.rs b/src/header.rs
index 9999462..e546715 100644
--- a/src/header.rs
+++ b/src/header.rs
@@ -13,7 +13,7 @@ use super::{Arc, ArcInner};
/// Structure to allow Arc-managing some fixed-sized data and a variably-sized
/// slice in a single allocation.
-#[derive(Debug, Eq, PartialEq, Hash, Partia... | 1 | 31 | 2 |
3887e04236cf94b3d400527caccd6ec2ee62a5f5 | Manish Goregaokar | 2024-05-29T00:02:50 | Bump to 0.1.12 | diff --git a/Cargo.toml b/Cargo.toml
index fd049df..f16b0ee 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "triomphe"
-version = "0.1.11"
-authors = ["The Servo Project Developers"]
+version = "0.1.12"
+authors = ["Manish Goregaokar <manishsmail@gmail.com>", "The Servo Project Developers"]
... | 1 | 2 | 2 |
2de2ca41188901fa43cbd1a28dbff6c44c08da6d | Stepan Koltsov | 2024-04-17T21:56:09 | Remove sized requirement from Arc::from_raw
`ptr.byte_sub` is stable since 1.75.0.
The tricky part here is figuring out offset of `ArcInner.data` for
DST. This PR assumes that raw pointer is coming from existing `Arc`
so it is safe to convert to reference. I'm not 100% sure this is
always correct.
Correct version w... | diff --git a/src/arc.rs b/src/arc.rs
index 0446de2..6b523f2 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -39,6 +39,26 @@ pub(crate) struct ArcInner<T: ?Sized> {
unsafe impl<T: ?Sized + Sync + Send> Send for ArcInner<T> {}
unsafe impl<T: ?Sized + Sync + Send> Sync for ArcInner<T> {}
+impl<T: ?Sized> ArcInner<T> {
+ ... | 2 | 66 | 53 |
dfc9e61b68c297bb060c3763424dedd91c1f8704 | Stepan Koltsov | 2024-04-18T23:11:30 | Document PartialEq for Arc bug
If `T` is not `Eq`, we cannot use pointer comparison properly.
But removing pointer comparison kills performance, maybe it is for
the best. | diff --git a/src/arc.rs b/src/arc.rs
index a5f09d8..0446de2 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -647,6 +647,7 @@ impl<T: ?Sized> Drop for Arc<T> {
impl<T: ?Sized + PartialEq> PartialEq for Arc<T> {
fn eq(&self, other: &Arc<T>) -> bool {
+ // TODO: pointer equality is incorrect if `T` is not `Eq`.... | 1 | 10 | 0 |
6df7026d9b99bbbc49d1fcbe4f874e464aee1025 | Stepan Koltsov | 2024-04-18T22:43:18 | Simplify/fix Arc::from_iter
When exact size iterator is not empty, `.next()` is called twice
after iteration ends, and the second call is allowed to return
`Some` for non-fused iterator.
Also less code, and probably faster because fewer branches and
smaller binary size. | diff --git a/src/header.rs b/src/header.rs
index 403f0ba..9999462 100644
--- a/src/header.rs
+++ b/src/header.rs
@@ -42,21 +42,15 @@ impl<H, T> Arc<HeaderSlice<H, [T]>> {
// Note that any panics here (i.e. from the iterator) are safe, since
// we'll just leak the uninitialized memory.
... | 1 | 8 | 14 |
3e77905d8ab21b8d17018c3784085076963a7c94 | Stepan Koltsov | 2024-04-18T15:46:37 | All features for docs.rs | diff --git a/Cargo.toml b/Cargo.toml
index 792d97f..fd049df 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,6 +12,9 @@ categories = ["concurrency", "data-structures"]
std = []
default = ["serde", "stable_deref_trait", "std"]
+[package.metadata.docs.rs]
+all-features = true
+
[dependencies]
serde = { version = "1.... | 1 | 3 | 0 |
e0b7dd21d3ddc69798d3dd97b1404c1c45b78689 | Stepan Koltsov | 2024-04-17T21:13:55 | Use ptr::addr_eq instead of == in Arc::ptr_eq
- This is what `std::sync::Arc` does
- This is behavior change
- Previous behavior was unreliable because compiler could merge/duplicate vtables
- Doing mostly to reduce the number of compiler warnings
- New code requires Rust >= 1.76.0 | diff --git a/src/arc.rs b/src/arc.rs
index 78f5bf3..a5f09d8 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -257,11 +257,11 @@ impl<T: ?Sized> Arc<T> {
let _ = Box::from_raw(self.ptr());
}
- /// Test pointer equality between the two Arcs, i.e. they must be the _same_
- /// allocation
+ /// Returns ... | 1 | 3 | 3 |
d2b95c99f9f70fe005438a0520e2730ed8cf65d8 | Stepan Koltsov | 2024-04-17T21:10:10 | Cleanup after strong_count implementation | diff --git a/src/thin_arc.rs b/src/thin_arc.rs
index 168a006..61c529c 100644
--- a/src/thin_arc.rs
+++ b/src/thin_arc.rs
@@ -8,7 +8,6 @@ use core::mem::ManuallyDrop;
use core::ops::Deref;
use core::ptr;
use core::usize;
-use ArcBorrow;
use super::{Arc, ArcInner, HeaderSliceWithLength, HeaderWithLength};
@@ -142... | 1 | 1 | 2 |
3e4fc38d1771712c69ce485279c696fe36f647da | Stepan Koltsov | 2024-04-17T17:09:32 | *::strong_count
API similar to `std::sync::Arc`.
`ArcBorrow::strong_count` is made to take `&Self` rather than `Self`
for consistency with `ArcBorrow::ptr_eq`, although I think by value
might be more appropriate. Maybe change everything in version 0.2? | diff --git a/src/arc.rs b/src/arc.rs
index c059667..78f5bf3 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -211,6 +211,19 @@ impl<T: ?Sized> Arc<T> {
self.p.as_ptr() as *const ArcInner<T> as *const c_void
}
+ /// The reference count of this `Arc`.
+ ///
+ /// The number does not include borrowed p... | 5 | 87 | 0 |
3de92feb4f094e7ad6668d1d4e5ce22e9a4b09f8 | Frank Steffahn | 2024-01-09T17:43:24 | Relax the requirements for Send/Sync impl of UniqueArc | diff --git a/src/unique_arc.rs b/src/unique_arc.rs
index 8ace713..45a9e90 100644
--- a/src/unique_arc.rs
+++ b/src/unique_arc.rs
@@ -39,6 +39,11 @@ use super::{Arc, ArcInner};
#[repr(transparent)]
pub struct UniqueArc<T: ?Sized>(Arc<T>);
+// Uniquene ownership means that we can support weaker bounds than `T: Send +... | 1 | 5 | 0 |
108fe849d24accafb8690507b10d1be47e8d6804 | Frank Steffahn | 2024-01-09T17:38:42 | Lift the `T: 'static` bound from `ArcBorrow::with_arc` | diff --git a/src/arc_borrow.rs b/src/arc_borrow.rs
index 4e0e77f..f4b17fb 100644
--- a/src/arc_borrow.rs
+++ b/src/arc_borrow.rs
@@ -66,7 +66,6 @@ impl<'a, T> ArcBorrow<'a, T> {
pub fn with_arc<F, U>(&self, f: F) -> U
where
F: FnOnce(&Arc<T>) -> U,
- T: 'static,
{
// Synthesize t... | 1 | 0 | 1 |
b41af992d643548937dc71448f2ef8d2b7d6f3a7 | Frank Steffahn | 2024-01-09T16:39:09 | Also apply fixes to cfg'd code. | diff --git a/src/arc_borrow.rs b/src/arc_borrow.rs
index d69026c..261b126 100644
--- a/src/arc_borrow.rs
+++ b/src/arc_borrow.rs
@@ -116,15 +116,13 @@ unsafe impl<'lt, T: 'lt, U: ?Sized + 'lt> unsize::CoerciblePtr<U> for ArcBorrow<
type Output = ArcBorrow<'lt, U>;
fn as_sized_ptr(&mut self) -> *mut T {
- ... | 1 | 2 | 4 |
a4c8883754ed2da1a9b91ae1596f58f55bfd8486 | Frank Steffahn | 2024-01-09T15:52:14 | Add the (now sound) Sync&Send impls for ArcBorrow | diff --git a/src/arc_borrow.rs b/src/arc_borrow.rs
index e36c468..d69026c 100644
--- a/src/arc_borrow.rs
+++ b/src/arc_borrow.rs
@@ -25,6 +25,9 @@ use super::Arc;
#[repr(transparent)]
pub struct ArcBorrow<'a, T: ?Sized + 'a>(pub(crate) NonNull<T>, pub(crate) PhantomData<&'a T>);
+unsafe impl<'a, T: ?Sized + Sync + ... | 1 | 3 | 0 |
b9bd14a73b511d523b04dcb4b34549b02b5e6cb6 | Frank Steffahn | 2024-01-09T15:43:51 | Make Rust 1.51 supported again | diff --git a/src/arc.rs b/src/arc.rs
index 3fb1bf4..c059667 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -202,12 +202,7 @@ impl<T: ?Sized> Arc<T> {
/// and can be converted into more `Arc<T>`s if necessary.
#[inline]
pub fn borrow_arc(&self) -> ArcBorrow<'_, T> {
- unsafe {
- ArcBorrow(
... | 2 | 4 | 9 |
09015b61fbfcd020c518c81aff326121d89ec07b | Frank Steffahn | 2024-01-09T15:35:55 | Fix provenance issues around ArcBorrow | diff --git a/src/arc.rs b/src/arc.rs
index 97cca63..3fb1bf4 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -202,7 +202,12 @@ impl<T: ?Sized> Arc<T> {
/// and can be converted into more `Arc<T>`s if necessary.
#[inline]
pub fn borrow_arc(&self) -> ArcBorrow<'_, T> {
- ArcBorrow(&**self)
+ unsaf... | 4 | 31 | 18 |
71cea13826e4cf59c82ff194e002b0b5291fcd27 | Frank Steffahn | 2023-10-12T11:18:30 | Add test that actually uses `ArcBorrow`
when run with miri, this demonstrates UB in the current implementation, due to provenance of references | diff --git a/src/arc_borrow.rs b/src/arc_borrow.rs
index 4e0e77f..ffb340e 100644
--- a/src/arc_borrow.rs
+++ b/src/arc_borrow.rs
@@ -116,3 +116,11 @@ unsafe impl<'lt, T: 'lt, U: ?Sized + 'lt> unsize::CoerciblePtr<U> for ArcBorrow<
ArcBorrow(inner.0.replace_ptr(new))
}
}
+
+#[test]
+fn clone_arc_borrow() ... | 1 | 8 | 0 |
4762f635fc4416c5b46ccdfb2ded76c6f739f5ff | Arthur Silva | 2023-11-29T16:44:53 | chore: 0.1.11 | diff --git a/Cargo.toml b/Cargo.toml
index 6e896b7..792d97f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "triomphe"
-version = "0.1.10"
+version = "0.1.11"
authors = ["The Servo Project Developers"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/Manishearth/triomphe" | 1 | 1 | 1 |
4b219e3f85b450fdd53e3891ea40682f68963c90 | Arthur Silva | 2023-11-29T11:32:30 | Remove length check from ThinSlice::clone (#76) | diff --git a/src/thin_arc.rs b/src/thin_arc.rs
index 19bb399..b4e8dcd 100644
--- a/src/thin_arc.rs
+++ b/src/thin_arc.rs
@@ -38,6 +38,7 @@ unsafe impl<H: Sync + Send, T: Sync + Send> Sync for ThinArc<H, T> {}
// Synthesize a fat pointer from a thin pointer.
//
// See the comment around the analogous operation in fro... | 1 | 22 | 3 |
d8013f7837a24e1fe9eeed4a20140065c54dc554 | Manish Goregaokar | 2023-11-26T08:42:20 | Bump to 0.1.10 (0.1.9 was already published for some reason) | diff --git a/Cargo.toml b/Cargo.toml
index 0c113bf..6e896b7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "triomphe"
-version = "0.1.9"
+version = "0.1.10"
authors = ["The Servo Project Developers"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/Manishearth/triomphe" | 1 | 1 | 1 |
5afb7058d4aa99f7885586cffbc1e029347343e4 | David Barsky | 2023-11-25T16:48:46 | chore: bump to 0.1.9 | diff --git a/Cargo.toml b/Cargo.toml
index 74ffbc0..0c113bf 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "triomphe"
-version = "0.1.8"
+version = "0.1.9"
authors = ["The Servo Project Developers"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/Manishearth/triomphe" | 1 | 1 | 1 |
4762e2c14de2e49b9f98251011e7594eaded6701 | EricLBuehler | 2023-10-24T09:18:45 | Update safety section | diff --git a/src/arc_borrow.rs b/src/arc_borrow.rs
index d53e1a5..4e0e77f 100644
--- a/src/arc_borrow.rs
+++ b/src/arc_borrow.rs
@@ -46,6 +46,8 @@ impl<'a, T> ArcBorrow<'a, T> {
/// e.g. if we obtain such a reference over FFI
/// TODO: should from_ref be relaxed to unsized types? It can't be
/// converte... | 1 | 2 | 0 |
e20eca421c9446409e677737e4775dee8da66f48 | EricLBuehler | 2023-10-23T21:36:38 | Remove one safety section | diff --git a/src/arc_borrow.rs b/src/arc_borrow.rs
index ae2bd1c..d53e1a5 100644
--- a/src/arc_borrow.rs
+++ b/src/arc_borrow.rs
@@ -46,9 +46,6 @@ impl<'a, T> ArcBorrow<'a, T> {
/// e.g. if we obtain such a reference over FFI
/// TODO: should from_ref be relaxed to unsized types? It can't be
/// converte... | 1 | 0 | 3 |
d5745609744ab3c395877921f4c4df9ebbd9393b | EricLBuehler | 2023-10-22T19:16:39 | Add safety sections, fix clippy warnings | diff --git a/src/arc.rs b/src/arc.rs
index 34fcb2a..97cca63 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -77,6 +77,10 @@ impl<T> Arc<T> {
/// by the atomic count.
///
/// It is recommended to use OffsetArc for this
+ ///
+ /// # Safety
+ /// - The given pointer must be a valid pointer to `T` tha... | 3 | 17 | 6 |
19735819c699e170fb01e9d806e2e182bfc25369 | Viktor Szépe | 2023-10-22T19:15:02 | Fix a typo in lib.rs | diff --git a/src/lib.rs b/src/lib.rs
index c6e33d9..7b3886c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -80,7 +80,7 @@ pub use unique_arc::*;
#[cfg(feature = "std")]
use std::process::abort;
-// `no_std`-compatible abort by forcing a panic while already panicing.
+// `no_std`-compatible abort by forcing a panic whi... | 1 | 1 | 1 |
261aebabe3e85943e2127ef7c0da3d6045a22988 | Frank Steffahn | 2023-10-12T11:03:12 | Fix accidental html tags in docs using `Arc<T>` with generic argument | diff --git a/src/arc.rs b/src/arc.rs
index ecc5582..34fcb2a 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -29,7 +29,7 @@ use crate::{abort, ArcBorrow, HeaderSlice, OffsetArc, UniqueArc};
/// necessarily) at _exactly_ `MAX_REFCOUNT + 1` references.
const MAX_REFCOUNT: usize = (isize::MAX) as usize;
-/// The object all... | 2 | 4 | 4 |
4488d19f1895d21476f22c90b8a57522c90853e7 | Manish Goregaokar | 2023-07-05T22:25:37 | Fix unsoundness in OffsetArc::make_mut() if clone panics | diff --git a/src/offset_arc.rs b/src/offset_arc.rs
index 9345416..4d7707e 100644
--- a/src/offset_arc.rs
+++ b/src/offset_arc.rs
@@ -105,16 +105,20 @@ impl<T> OffsetArc<T> {
T: Clone,
{
unsafe {
- // extract the OffsetArc as an owned variable
+ // extract the OffsetArc as an... | 1 | 12 | 8 |
620628ef4d4cc130c3a2e2ad2d444d3b28f6d881 | daddinuz | 2023-05-21T17:02:13 | BREAKING CHANGE - semantic change of PartialOrd/Ord for HeaderSliceWithLength | diff --git a/src/arc.rs b/src/arc.rs
index 31b65b6..ecc5582 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -945,51 +945,87 @@ mod tests {
#[test]
fn arc_eq_and_cmp() {
- let x = Arc::from_header_and_iter("AB", b"CD".iter());
- let y = Arc::from_header_and_iter("ab", b"cd".iter());
- let z ... | 3 | 158 | 71 |
dce67d3fcb8a332d9a5008ca5be3191d815c681d | daddinuz | 2023-05-17T14:13:31 | PartialOrd + Ord for HeaderSlice, HeaderWithLength and ThinArc | diff --git a/src/arc.rs b/src/arc.rs
index 0abb26c..31b65b6 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -942,4 +942,54 @@ mod tests {
assert_eq!([17, 19], *arc);
assert_eq!(1, Arc::count(&arc));
}
+
+ #[test]
+ fn arc_eq_and_cmp() {
+ let x = Arc::from_header_and_iter("AB", b"CD".ite... | 3 | 117 | 2 |
176aac50451b55f07206bbf4a9e57b4eb1ca63d9 | Stiopa Koltsov | 2023-02-03T00:49:44 | Arc::from_raw_slice
Fixes #56 | diff --git a/src/arc.rs b/src/arc.rs
index 686e644..0abb26c 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -145,6 +145,25 @@ impl<T> Arc<T> {
}
}
+impl<T> Arc<[T]> {
+ /// Reconstruct the `Arc<[T]>` from a raw pointer obtained from `into_raw()`.
+ ///
+ /// [`Arc::from_raw`] should accept unsized types, b... | 1 | 28 | 0 |
067689d10a463874dd0db17039d61ec700da5ccc | Stiopa Koltsov | 2023-02-14T04:10:53 | Message to assertion in IteratorAsExactSizeIterator
Follow-up to #58 | diff --git a/src/iterator_as_exact_size_iterator.rs b/src/iterator_as_exact_size_iterator.rs
index 504f507..12936f7 100644
--- a/src/iterator_as_exact_size_iterator.rs
+++ b/src/iterator_as_exact_size_iterator.rs
@@ -10,7 +10,11 @@ impl<I: Iterator> IteratorAsExactSizeIterator<I> {
#[inline]
pub(crate) fn new... | 1 | 10 | 2 |
2e3df46ada04f1cabc285503c95b7889ac250282 | Stiopa Koltsov | 2023-02-03T01:22:14 | Arc::from_iter
(Also `UniqueArc::from_iter`.)
Fixes #55. | diff --git a/src/arc.rs b/src/arc.rs
index 6fe022c..686e644 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -7,6 +7,7 @@ use core::convert::From;
use core::ffi::c_void;
use core::fmt;
use core::hash::{Hash, Hasher};
+use core::iter::FromIterator;
use core::marker::PhantomData;
use core::mem::{ManuallyDrop, MaybeUninit... | 4 | 89 | 0 |
bd7d53eb81e33763eacbd55aea264975b50b2f5d | Stiopa Koltsov | 2022-11-22T16:20:07 | Mute warning
The warning was:
```
warning: unused return value of `Box::<T>::from_raw` that must be used
--> src/header.rs:238:13
|
238 | Box::<ManuallyDrop<T>>::from_raw(src as _);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: call `drop(from_raw(ptr))` if you int... | diff --git a/src/header.rs b/src/header.rs
index e35ec48..6bc2d82 100644
--- a/src/header.rs
+++ b/src/header.rs
@@ -235,7 +235,7 @@ impl<T> From<Box<T>> for Arc<T> {
// Safety:
// - `src` has been got from `Box::into_raw`
// - `ManuallyDrop<T>` is guaranteed to have the same layo... | 1 | 1 | 1 |
e8b881c9c6199c3ffd0d93522086e5836b7e7f30 | Manish Goregaokar | 2022-09-06T16:36:40 | Bump to 0.1.8 | diff --git a/Cargo.toml b/Cargo.toml
index dbfa621..74ffbc0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "triomphe"
-version = "0.1.7"
+version = "0.1.8"
authors = ["The Servo Project Developers"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/Manishearth/triomphe" | 1 | 1 | 1 |
5b30f1874094600caea441c4997ff2e055ad2852 | Maybe Waffle | 2022-07-08T16:27:16 | Add more functions for making arc unique | diff --git a/src/arc.rs b/src/arc.rs
index f1db164..0822e8e 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -332,7 +332,7 @@ impl<T: ?Sized> Deref for Arc<T> {
}
}
-impl<T: Clone + ?Sized> Arc<T> {
+impl<T: Clone> Arc<T> {
/// Makes a mutable reference to the `Arc`, cloning if necessary
///
/// This ... | 1 | 36 | 2 |
7792d30f2e4b5b5ae814d70640989e1f13bc751f | Maybe Waffle | 2022-07-08T16:10:17 | Simplify `new_uninit_slice` | diff --git a/src/unique_arc.rs b/src/unique_arc.rs
index 81b698f..79555fc 100644
--- a/src/unique_arc.rs
+++ b/src/unique_arc.rs
@@ -1,13 +1,12 @@
-use alloc::{
- alloc::{alloc, Layout},
- boxed::Box,
-};
+use alloc::{alloc::Layout, boxed::Box};
use core::convert::TryFrom;
use core::marker::PhantomData;
-use co... | 1 | 14 | 29 |
4fc5a7ee220450c6061e86610a16728751edb6b7 | Maybe Waffle | 2022-07-08T16:05:20 | Fix `no_std` importsallocate_for_header_and_slice | diff --git a/src/header.rs b/src/header.rs
index 1f60ebe..e35ec48 100644
--- a/src/header.rs
+++ b/src/header.rs
@@ -1,4 +1,7 @@
use alloc::alloc::Layout;
+use alloc::boxed::Box;
+use alloc::string::String;
+use alloc::vec::Vec;
use core::iter::{ExactSizeIterator, Iterator};
use core::marker::PhantomData;
use core:... | 1 | 6 | 0 |
76b4af0f4a7593fe7ea26944e5a16bc1af53131d | Maybe Waffle | 2022-07-08T16:03:02 | Refactor out `allocate_for_header_and_slice` | diff --git a/src/arc.rs b/src/arc.rs
index 65fd3e6..31f35aa 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -20,7 +20,7 @@ use serde::{Deserialize, Serialize};
#[cfg(feature = "stable_deref_trait")]
use stable_deref_trait::{CloneStableDeref, StableDeref};
-use crate::{abort, ArcBorrow, OffsetArc, UniqueArc};
+use crate... | 2 | 39 | 72 |
179ecb1c98a19369567a7c811db993555bc44944 | Maybe Waffle | 2022-07-08T15:53:27 | Add tests for `Arc::from_header_and_vec` | diff --git a/src/header.rs b/src/header.rs
index 0c0d28a..45d4a31 100644
--- a/src/header.rs
+++ b/src/header.rs
@@ -336,6 +336,14 @@ mod tests {
assert_eq!(arc.slice, [1u16, 2, 3, 4, 5, 6, 7]);
}
+ #[test]
+ fn from_header_and_vec_smoke() {
+ let arc = Arc::from_header_and_vec((42u32, 17u8... | 1 | 16 | 0 |
db22685e6360f000fc38775e5d38cdba07767239 | Maybe Waffle | 2022-07-08T15:50:45 | Add `Arc::from_header_and_vec` | diff --git a/src/header.rs b/src/header.rs
index 5c20eea..0c0d28a 100644
--- a/src/header.rs
+++ b/src/header.rs
@@ -141,6 +141,58 @@ impl<H, T> Arc<HeaderSlice<H, [T]>> {
phantom: PhantomData,
}
}
+
+ /// Creates an Arc for a HeaderSlice using the given header struct and
+ /// vec to g... | 1 | 54 | 34 |
a3fa7e7cc81f2c7da5a1f1a56913c5e9c79c516d | Maybe Waffle | 2022-07-08T15:36:18 | Add conversions from `Box` and `Vec` to `Arc` | diff --git a/src/header.rs b/src/header.rs
index cd12b1b..5c20eea 100644
--- a/src/header.rs
+++ b/src/header.rs
@@ -1,8 +1,8 @@
use alloc::alloc::Layout;
use core::iter::{ExactSizeIterator, Iterator};
use core::marker::PhantomData;
-use core::mem;
-use core::ptr::{self, NonNull};
+use core::mem::{self, ManuallyDrop... | 1 | 99 | 2 |
e43742aadd37bc156f9d29b251661cf6025792d0 | Maybe Waffle | 2022-07-08T15:23:51 | Refactor out allocation code | diff --git a/src/arc.rs b/src/arc.rs
index f1db164..65fd3e6 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -1,4 +1,6 @@
+use alloc::alloc::handle_alloc_error;
use alloc::boxed::Box;
+use core::alloc::Layout;
use core::borrow;
use core::cmp::Ordering;
use core::convert::From;
@@ -8,7 +10,7 @@ use core::hash::{Hash, Has... | 2 | 135 | 90 |
ce0acd74881ddb66fa78f1a6c50e34613970b7d1 | Maybe Waffle | 2022-07-08T13:37:41 | Add some basic conversions
- `&[T: Copy]` -> `Arc<[T]>`
- `&str` -> `Arc<str>`
- `String` -> `Arc<str>` | diff --git a/src/header.rs b/src/header.rs
index 83b989e..5d62742 100644
--- a/src/header.rs
+++ b/src/header.rs
@@ -224,6 +224,24 @@ impl<T: ?Sized> From<Arc<T>> for Arc<HeaderSlice<(), T>> {
}
}
+impl<T: Copy> From<&[T]> for Arc<[T]> {
+ fn from(slice: &[T]) -> Self {
+ Arc::from_header_and_slice(()... | 1 | 18 | 0 |
cd5732c1ed9d7a3b6c0df82a39135c3707b0e411 | Maybe Waffle | 2022-07-08T13:18:42 | Add `Arc<HeaderSlice<(), T>>` <-> `Arc<T>` conversions | diff --git a/src/header.rs b/src/header.rs
index 1a694ba..83b989e 100644
--- a/src/header.rs
+++ b/src/header.rs
@@ -205,13 +205,32 @@ impl<H> HeaderWithLength<H> {
}
}
+impl<T: ?Sized> From<Arc<HeaderSlice<(), T>>> for Arc<T> {
+ fn from(this: Arc<HeaderSlice<(), T>>) -> Self {
+ debug_assert_eq!(
+ ... | 1 | 33 | 1 |
bd598f4b70dce8a291822da425d075be644f76b3 | Maybe Waffle | 2022-07-07T18:59:01 | Make error for non-unique arc nicer
With this error will point to the caller, rather than to the source. | diff --git a/src/arc.rs b/src/arc.rs
index 33761f5..f1db164 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -243,12 +243,7 @@ impl<T> Arc<MaybeUninit<T>> {
)]
#[track_caller]
pub fn write(&mut self, val: T) -> &mut T {
- UniqueArc::write(
- Self::try_as_unique(self).unwrap_or_else(|this| {
... | 1 | 10 | 9 |
e2e28acf3ef5992c4dc507a733f0aa6ef2a61cbd | Maybe Waffle | 2022-07-07T18:53:35 | Add test | diff --git a/src/arc.rs b/src/arc.rs
index 215ac3d..33761f5 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -692,6 +692,22 @@ mod tests {
let _ = &*x;
}
+ #[test]
+ #[allow(deprecated)]
+ #[should_panic = "`Arc` must be unique in order for this operation to be safe"]
+ fn maybeuninit_slice_ub_to... | 1 | 16 | 0 |
7ecb4de64cff933ddc853fad65641d6999bede45 | Maybe Waffle | 2022-07-07T18:50:46 | Fix UB in `Arc::<[MaybeUninit<T>]>::as_mut_slice` | diff --git a/src/arc.rs b/src/arc.rs
index d18a92e..215ac3d 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -1,5 +1,4 @@
-use alloc::{alloc::alloc, boxed::Box};
-use core::alloc::Layout;
+use alloc::boxed::Box;
use core::borrow;
use core::cmp::Ordering;
use core::convert::From;
@@ -7,7 +6,6 @@ use core::ffi::c_void;
us... | 2 | 59 | 40 |
d85786b95c86284b80dcacea3c151e189011fe38 | Maybe Waffle | 2022-07-07T17:13:57 | Remove `#[cfg(feature = "std")]` from impl `Arc<[MaybeUninit<T>]>` | diff --git a/src/arc.rs b/src/arc.rs
index 6abd99b..d18a92e 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -1,4 +1,4 @@
-use alloc::boxed::Box;
+use alloc::{alloc::alloc, boxed::Box};
use core::alloc::Layout;
use core::borrow;
use core::cmp::Ordering;
@@ -15,9 +15,6 @@ use core::sync::atomic;
use core::sync::atomic::O... | 1 | 1 | 5 |
89fdb1c8b83c940256cb7dd6867b97e86bd7211a | Maybe Waffle | 2022-07-07T18:33:12 | Remove uses of `mem::forget` if favour of `ManuallyDrop` | diff --git a/src/arc.rs b/src/arc.rs
index 331ba9e..6abd99b 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -103,16 +103,11 @@ impl<T> Arc<T> {
F: FnOnce(&OffsetArc<T>) -> U,
{
// Synthesize transient Arc, which never touches the refcount of the ArcInner.
+ // Store transient in `ManuallyDrop`... | 2 | 9 | 17 |
410a78133492a6c23c698943fb3c22addb56b439 | Maybe Waffle | 2022-07-07T16:47:12 | Add a test | diff --git a/src/header.rs b/src/header.rs
index 1b65c8d..1a694ba 100644
--- a/src/header.rs
+++ b/src/header.rs
@@ -258,4 +258,21 @@ mod tests {
let s: &[u8] = &[0u8; 255];
crate::Arc::from_header_and_iter((), s.iter().copied());
}
+
+ #[test]
+ fn from_header_and_str_smoke() {
+ le... | 1 | 17 | 0 |
15a80f3edb3b79216f8acf50aa0abb7ce54d5fdc | Maybe Waffle | 2022-07-07T16:29:46 | Add `Arc::from_header_and_str` | diff --git a/src/arc.rs b/src/arc.rs
index 9f9dc3f..331ba9e 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -198,11 +198,17 @@ impl<T: ?Sized> Arc<T> {
self.p.as_ptr() as *const ArcInner<T> as *const c_void
}
+ #[inline]
+ pub(super) fn into_raw_inner(this: Self) -> *mut ArcInner<T> {
+ let thi... | 2 | 21 | 1 |
edcae52269f32b878720dd1a032f9ed1db19460e | Maybe Waffle | 2022-07-07T16:28:19 | passed by cleanup: remove useless `T: Sized` bounds
Remove `T: Sized` bounds from `Arc::`
- `into_raw
- `as_ptr`
- `borrow_arc`
- `heap_ptr` | diff --git a/src/arc.rs b/src/arc.rs
index 3b9e4ed..9f9dc3f 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -79,30 +79,6 @@ impl<T> Arc<T> {
}
}
- /// Convert the Arc<T> to a raw pointer, suitable for use across FFI
- ///
- /// Note: This returns a pointer to the data T, which is offset in the allo... | 1 | 41 | 39 |
8b752b364fa84a8cfac0effca1ad1938efc49a2f | Manish Goregaokar | 2022-07-06T15:31:22 | Bump to 0.1.7 | diff --git a/Cargo.toml b/Cargo.toml
index 099627d..dbfa621 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "triomphe"
-version = "0.1.6"
+version = "0.1.7"
authors = ["The Servo Project Developers"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/Manishearth/triomphe" | 1 | 1 | 1 |
7e4637ab2c1cecf6fc0b2a3b92ecb9727f61c41b | Manish Goregaokar | 2022-07-06T15:29:52 | std import | diff --git a/src/header.rs b/src/header.rs
index ad9f72f..385b1f3 100644
--- a/src/header.rs
+++ b/src/header.rs
@@ -236,7 +236,7 @@ mod tests {
#[test]
fn issue_13_empty() {
- crate::Arc::from_header_and_iter((), std::iter::empty::<usize>());
+ crate::Arc::from_header_and_iter((), iter::empty... | 1 | 1 | 1 |
8b73068d18699940a7b98961e8b7e882cf74e116 | Manish Goregaokar | 2022-07-06T15:27:46 | fix test failure | diff --git a/src/arc.rs b/src/arc.rs
index 896a4c1..ac2fbd4 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -659,6 +659,7 @@ mod tests {
use core::mem::MaybeUninit;
#[cfg(feature = "unsize")]
use unsize::{CoerceUnsize, Coercion};
+ use alloc::string::String;
#[test]
fn try_unwrap() { | 1 | 1 | 0 |
29b2b65fbbb6acdc7d24df9a756b28ae75c2fe59 | Maybe Waffle | 2022-07-06T12:33:52 | Remove useless assert | diff --git a/src/header.rs b/src/header.rs
index 5bb736d..ad9f72f 100644
--- a/src/header.rs
+++ b/src/header.rs
@@ -100,12 +100,6 @@ impl<H, T> Arc<HeaderSlice<H, [T]>> {
);
}
- // Return the fat Arc.
- assert_eq!(
- mem::size_of::<Self>(),
- mem::size_of::<u... | 1 | 0 | 12 |
21aae05d40cbe2eb78c88275a05799b903372b03 | Maybe Waffle | 2022-07-06T12:29:41 | Add tests for `from_header_and_{slice,iter}` | diff --git a/src/header.rs b/src/header.rs
index b164cbf..5bb736d 100644
--- a/src/header.rs
+++ b/src/header.rs
@@ -204,3 +204,56 @@ impl<H> HeaderWithLength<H> {
}
pub(crate) type HeaderSliceWithLength<H, T> = HeaderSlice<HeaderWithLength<H>, T>;
+
+#[cfg(test)]
+mod tests {
+ use core::iter;
+
+ use crate:... | 1 | 53 | 0 |
05e4fe2cdecb1aea3695a7913a391555a45fbb06 | Maybe Waffle | 2022-07-06T11:25:43 | Fix UB in `Arc::<MaybeUninit<_>>::write`
Previously `write` would write even to a shared `Arc` which caused UB,
as demonstrated by the `maybeuninit_ub_to_proceed` test.
This commit makes `write` panic on non-unique `Arc`s and adds similar
functionality to `UniqueArc` where it's always safe. | diff --git a/src/arc.rs b/src/arc.rs
index 0f9413d..896a4c1 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -242,12 +242,22 @@ impl<T> Arc<MaybeUninit<T>> {
}
/// Calls `MaybeUninit::write` on the value contained.
+ ///
+ /// ## Panics
+ ///
+ /// If the `Arc` is not unique.
+ #[deprecated(
+ ... | 2 | 87 | 6 |
7fe27194502bc6d868f0fe609b1f7b33da891b0d | Ben Kimock | 2022-07-01T20:11:47 | Fix provenance issues in as_ptr and new_uninit_slice
The root cause of these changes is the same: we need to avoid
round-tripping pointers through a reference to the Arc's `T` so that we
can use said pointer to access the metadata/reference count. | diff --git a/Cargo.lock b/Cargo.lock
index c338e07..4966a3a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -28,7 +28,7 @@ checksum = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8"
[[package]]
name = "triomphe"
-version = "0.1.5"
+version = "0.1.6"
dependencies = [
"arc-swap",
"serde",
diff --g... | 5 | 16 | 8 |
b1d1d5b583cfc5ae59571ffacfc3d0b67c7ed72a | Vlad Krasnov | 2022-06-06T16:57:41 | Bump to 0.1.6 | diff --git a/Cargo.toml b/Cargo.toml
index 22f4b84..099627d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "triomphe"
-version = "0.1.5"
+version = "0.1.6"
authors = ["The Servo Project Developers"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/Manishearth/triomphe" | 1 | 1 | 1 |
d88e026f28fc205859fe3a2b7fae354beab7635a | Nugine | 2022-01-31T03:04:50 | Add some comments for `offset_of!` | diff --git a/src/lib.rs b/src/lib.rs
index e2e18b1..13d568b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -35,8 +35,11 @@ extern crate stable_deref_trait;
extern crate unsize;
/// Calculates the offset of the specified field from the start of the named struct.
+/// This macro is impossible to be const until feature(c... | 1 | 3 | 0 |
b4b741ebe972615287f87314eb007df56892c0eb | Nugine | 2022-01-30T17:28:38 | Replace `memoffset::offset_of` with internal impl | diff --git a/Cargo.lock b/Cargo.lock
index 9646cd9..c338e07 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -14,15 +14,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
-[[package]]
-name = "memoffset"
-v... | 3 | 22 | 14 |
1120c6f0f6d4fceca055d5f9520f07d71f2baa98 | Vlad Krasnov | 2022-01-06T13:33:15 | An optimized method to create Arc from a slice
When a slice is available it is faster to copy it
using `ptr::copy_nonoverlapping` than by doing
`ptr::write` for each element. | diff --git a/src/header.rs b/src/header.rs
index 888b8e5..5fdda71 100644
--- a/src/header.rs
+++ b/src/header.rs
@@ -114,6 +114,74 @@ impl<H, T> Arc<HeaderSlice<H, [T]>> {
}
}
}
+
+ /// Creates an Arc for a HeaderSlice using the given header struct and
+ /// iterator to generate the sli... | 2 | 95 | 0 |
5652851ec240a024adf090dd83747e6995a99534 | Manish Goregaokar | 2021-12-21T08:28:00 | Bump to 0.1.5 | diff --git a/Cargo.toml b/Cargo.toml
index f8828b0..6bcf09a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "triomphe"
-version = "0.1.4"
+version = "0.1.5"
authors = ["The Servo Project Developers"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/Manishearth/triomphe" | 1 | 1 | 1 |
86267884cebec024e4f81b8326c1293bb0230d6e | Jiahao XU | 2021-12-21T05:16:43 | Impl `fmt::Debug` & `fmt::Pointer` for `ThinArc`
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> | diff --git a/src/thin_arc.rs b/src/thin_arc.rs
index 0efa396..91af11c 100644
--- a/src/thin_arc.rs
+++ b/src/thin_arc.rs
@@ -1,4 +1,5 @@
use core::ffi::c_void;
+use core::fmt;
use core::hash::{Hash, Hasher};
use core::iter::{ExactSizeIterator, Iterator};
use core::marker::PhantomData;
@@ -207,6 +208,18 @@ impl<H: H... | 1 | 13 | 0 |
e050c057f9661462a748091c66e259391c839b9c | Manish Goregaokar | 2021-12-15T04:15:00 | Bump version | diff --git a/Cargo.toml b/Cargo.toml
index 6564211..f8828b0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "triomphe"
-version = "0.1.3"
+version = "0.1.4"
authors = ["The Servo Project Developers"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/Manishearth/triomphe" | 1 | 1 | 1 |
f93ca368fb29aa7916c149c1b3d38516775f8300 | Jiahao XU | 2021-09-29T14:13:48 | Add new methods for MaybeUninit in Arc
Add methods:
- `Arc<MaybeUninit<T>>::new_uninit() -> Self`
- `Arc<MaybeUninit<T>>::write(&mut self, T) -> &mut T`
- `Arc<MaybeUninit<T>>::as_mut_ptr(&mut self) -> *mut MaybeUninit<T>`
- `Arc<MaybeUninit<T>>::assume_init(self) -> Arc<T>`
- `Arc<[MaybeUninit<T>]>::new_uninit... | diff --git a/src/arc.rs b/src/arc.rs
index 98e1033..1d15b9a 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -1,4 +1,5 @@
use alloc::boxed::Box;
+use core::alloc::Layout;
use core::borrow;
use core::cmp::Ordering;
use core::convert::From;
@@ -7,12 +8,17 @@ use core::fmt;
use core::hash::{Hash, Hasher};
use core::marke... | 1 | 129 | 1 |
f3e922febbfcf77d3d2dc45f7293dbcd11322650 | Jiahao XU | 2021-08-06T12:41:09 | Make `from_raw` and `into_raw` API of `ThinArc` more similar to the one of `Arc`
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> | diff --git a/src/arc_swap_support.rs b/src/arc_swap_support.rs
index 13f9c5c..e743fb7 100644
--- a/src/arc_swap_support.rs
+++ b/src/arc_swap_support.rs
@@ -9,7 +9,7 @@ unsafe impl<H, T> RefCnt for ThinArc<H, T> {
#[inline]
fn into_ptr(me: Self) -> *mut Self::Base {
- ThinArc::into_raw(me).as_ptr()
+... | 2 | 8 | 9 |
85930c98f2359b66311d189f4f4c53d9c731fb10 | Jiahao XU | 2021-08-06T11:33:24 | Fix regression: Fix test coerce_to_slice in mod arc
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> | diff --git a/src/arc.rs b/src/arc.rs
index f2629ba..98e1033 100644
--- a/src/arc.rs
+++ b/src/arc.rs
@@ -571,7 +571,7 @@ mod tests {
fn coerce_to_slice() {
let x = Arc::new([0u8; 4]);
let y: Arc<[u8]> = x.clone().unsize(Coercion::to_slice());
- assert_eq!(x.as_ptr(), y.as_ptr());
+ ... | 1 | 1 | 1 |
bf0991f780f98e0df952a9e393bc50f6a9cc3ce4 | Jiahao XU | 2021-08-06T11:31:06 | Fix format by running `cargo fmt`
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> | diff --git a/src/arc_swap_support.rs b/src/arc_swap_support.rs
index 3f9aec1..13f9c5c 100644
--- a/src/arc_swap_support.rs
+++ b/src/arc_swap_support.rs
@@ -1,8 +1,8 @@
use arc_swap::RefCnt;
+use crate::{Arc, ThinArc};
use core::ffi::c_void;
use core::ptr::NonNull;
-use crate::{Arc, ThinArc};
unsafe impl<H, T> ... | 3 | 8 | 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.