Open SSheldon opened 10 years ago
The ideal fix for this would be to make NSObjects not Sized
; then the example code wouldn't even compile. Unfortunately, it doesn't seem that there's a way to make a struct not Sized
without the struct using "fat" (two-word) references, which would be incorrect for an NSObject.
If rust-lang/rfcs#709 were accepted, this could be resolved by marking NSObjects as NotSized
.
The unsized types RFC was postponed as rust-lang/rfcs#813.
If rust-lang/rfcs#1861 is accepted, we could fix this by making Object an opaque extern type.
The extern types RFC was accepted and implemented! Stabilization tracked in rust-lang/rust#43467.
Getting mutable references to void types is undefined behaviour to begin with, will file an issue.
For example, the following code:
Expected output:
Actual output:
We cannot have the expected output happen, because an NSObject's memory address cannot change after it has been constructed.