File tree Expand file tree Collapse file tree 4 files changed +20
-3
lines changed Expand file tree Collapse file tree 4 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,8 @@ pub unsafe trait RefEncode {
147
147
const ENCODING_REF : Encoding < ' static > ;
148
148
}
149
149
150
+ // TODO: Implement for `PhantomData` and `PhantomPinned`?
151
+
150
152
/// Simple helper for implementing [`Encode`].
151
153
macro_rules! encode_impls {
152
154
( $( $t: ty => $e: ident, ) * ) => ( $(
@@ -318,6 +320,7 @@ unsafe impl<T: RefEncode + ?Sized> RefEncode for ManuallyDrop<T> {
318
320
// core::cell::Ref?
319
321
// core::cell::RefCell?
320
322
// core::cell::RefMut?
323
+ // core::panic::AssertUnwindSafe<T>
321
324
322
325
// SAFETY: `Pin` is `repr(transparent)`.
323
326
unsafe impl < T : Encode > Encode for Pin < T > {
@@ -341,6 +344,8 @@ unsafe impl<T: RefEncode> RefEncode for Wrapping<T> {
341
344
const ENCODING_REF : Encoding < ' static > = T :: ENCODING_REF ;
342
345
}
343
346
347
+ // TODO: core::num::Saturating when that is stabilized
348
+
344
349
// TODO: core::cmp::Reverse?
345
350
346
351
/// Helper for implementing `Encode`/`RefEncode` for pointers to types that
Original file line number Diff line number Diff line change @@ -37,6 +37,11 @@ extern "C" {
37
37
/// (and would probably give us a bit better performance), but it gets
38
38
/// unwieldy _very_ quickly, so I chose the much more stable option.
39
39
///
40
+ /// Another thing to remember: While Rust's and Objective-C's unwinding
41
+ /// mechanisms are similar now, Rust's is explicitly unspecified, and they
42
+ /// may diverge significantly in the future; so handling this in pure Rust
43
+ /// (using mechanisms like core::intrinsics::r#try) is not an option!
44
+ ///
40
45
/// [manual-asm]: https://gitlab.com/objrs/objrs/-/blob/b4f6598696b3fa622e6fddce7aff281770b0a8c2/src/exception.rs
41
46
fn rust_objc_try_catch_exception (
42
47
f : extern "C" fn ( * mut c_void ) ,
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ use crate::ffi;
18
18
/// pool on the current thread.
19
19
#[ derive( Debug ) ]
20
20
pub struct AutoreleasePool {
21
+ /// This is an opaque handle, and is not guaranteed to be neither a valid
22
+ /// nor aligned pointer.
21
23
context : * mut c_void ,
22
24
// May pointer to data that is mutated (even though we hold shared access)
23
25
p : PhantomData < * mut UnsafeCell < c_void > > ,
@@ -140,9 +142,13 @@ impl Drop for AutoreleasePool {
140
142
/// > Not draining the pool during an unwind is apparently required by the
141
143
/// > Objective-C exceptions implementation.
142
144
///
143
- /// This was true in the past, but since [revision `371`] of objc4 (ships
144
- /// with MacOS 10.5) the exception is now retained when `@throw` is
145
- /// encountered.
145
+ /// However, we would like to do this anyway whenever possible, since the
146
+ /// unwind is probably caused by Rust, and forgetting to pop the pool will
147
+ /// likely leak memory.
148
+ ///
149
+ /// Fortunately, the above statement was true in the past, but since
150
+ /// [revision `371`] of objc4 (ships with MacOS 10.5) the exception is now
151
+ /// retained when `@throw` is encountered.
146
152
///
147
153
/// Hence it is safe to drain the pool when unwinding.
148
154
///
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ pub struct WeakId<T: ?Sized> {
25
25
/// an UnsafeCell to get a *mut without self being mutable.
26
26
///
27
27
/// TODO: Verify the need for UnsafeCell?
28
+ /// TODO: Investigate if we can avoid some allocations using `Pin`.
28
29
inner : Box < UnsafeCell < * mut T > > ,
29
30
/// WeakId inherits variance, dropck and various marker traits from
30
31
/// `Id<T, Shared>` because it can be upgraded to a shared Id.
You can’t perform that action at this time.
0 commit comments