Skip to content

Commit 93ca34a

Browse files
committed
Add a regression test to ensure AutoreleasePool is not Send nor Sync
1 parent ff261e6 commit 93ca34a

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/rc/autorelease.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,21 @@ pub struct AutoreleasePool {
2121
context: *mut c_void,
2222
}
2323

24+
/// ```rust,compile_fail
25+
/// use objc::rc::AutoreleasePool;
26+
/// fn needs_sync<T: Send>() {}
27+
/// needs_sync::<AutoreleasePool>();
28+
/// ```
29+
/// ```rust,compile_fail
30+
/// use objc::rc::AutoreleasePool;
31+
/// fn needs_send<T: Send>() {}
32+
/// needs_send::<AutoreleasePool>();
33+
/// ```
34+
#[cfg(doctest)]
35+
pub struct AutoreleasePoolNotSendNorSync;
36+
2437
impl AutoreleasePool {
25-
/// Construct a new autoreleasepool.
38+
/// Construct a new autorelease pool.
2639
///
2740
/// Use the [`autoreleasepool`] block for a safe alternative.
2841
///
@@ -36,7 +49,7 @@ impl AutoreleasePool {
3649
#[doc(alias = "objc_autoreleasePoolPush")]
3750
unsafe fn new() -> Self {
3851
// TODO: Make this function pub when we're more certain of the API
39-
AutoreleasePool {
52+
Self {
4053
context: objc_autoreleasePoolPush(),
4154
}
4255
}

0 commit comments

Comments
 (0)