File tree Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
25
25
### Fixed
26
26
* Soundness issue with ` NSValue ` , ` NSDictionary ` , ` NSArray ` and
27
27
` NSMutableArray ` not being ` #[repr(C)] ` .
28
+ * ** BREAKING** : ` NSObject ` is no longer ` Send ` and ` Sync ` (because its
29
+ subclasses may not be).
28
30
29
31
## 0.2.0-alpha.2 - 2021-11-22
30
32
Original file line number Diff line number Diff line change @@ -184,6 +184,16 @@ unsafe impl<T: Sync + Send> Send for NSArray<T, Shared> {}
184
184
unsafe impl < T : Sync > Sync for NSArray < T , Owned > { }
185
185
unsafe impl < T : Send > Send for NSArray < T , Owned > { }
186
186
187
+ /// ```compile_fail
188
+ /// use objc2::rc::Shared;
189
+ /// use objc2::runtime::Object;
190
+ /// use objc2_foundation::NSArray;
191
+ /// fn needs_send_sync<T: Send + Sync>() {}
192
+ /// needs_send_sync::<NSArray<Object, Shared>>();
193
+ /// ```
194
+ #[ cfg( doctest) ]
195
+ pub struct NSArrayWithObjectNotSendSync ;
196
+
187
197
unsafe impl < T : INSObject , O : Ownership > INSArray for NSArray < T , O > {
188
198
/// The `NSArray` itself (length and number of items) is always immutable,
189
199
/// but we would like to know when we're the only owner of the array, to
Original file line number Diff line number Diff line change
1
+ use core:: marker:: PhantomData ;
1
2
use core:: ptr:: NonNull ;
2
3
3
4
use objc2:: msg_send;
4
5
use objc2:: rc:: { Id , Owned , Shared } ;
5
- use objc2:: runtime:: { Bool , Class } ;
6
+ use objc2:: runtime:: { Bool , Class , Object } ;
6
7
use objc2:: Message ;
7
8
8
9
use super :: NSString ;
@@ -37,7 +38,22 @@ pub unsafe trait INSObject: Sized + Message {
37
38
}
38
39
}
39
40
40
- object ! ( unsafe pub struct NSObject ) ;
41
+ object ! ( unsafe pub struct NSObject <> {
42
+ p: PhantomData <Object >, // Temporary
43
+ } ) ;
44
+
45
+ /// ```compile_fail
46
+ /// use objc2_foundation::NSObject;
47
+ /// fn needs_sync<T: Sync>() {}
48
+ /// needs_sync::<NSObject>();
49
+ /// ```
50
+ /// ```compile_fail
51
+ /// use objc2_foundation::NSObject;
52
+ /// fn needs_send<T: Send>() {}
53
+ /// needs_send::<NSObject>();
54
+ /// ```
55
+ #[ cfg( doctest) ]
56
+ pub struct NSObjectNotSendNorSync ;
41
57
42
58
impl NSObject {
43
59
unsafe_def_fn ! ( pub fn new -> Owned ) ;
You can’t perform that action at this time.
0 commit comments