You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: text/0000-maybe-dangling.md
+3-6Lines changed: 3 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -203,11 +203,6 @@ Miri is adjusted as follows:
203
203
This has the disadvantage that one risks memory leaks when all one wants to do is pass around data of some `T` without upholding reference liveness.
204
204
For instance, the third example would have to remember to call `drop` on the `buffer`.
205
205
This alternative has the advantage that we avoid introducing another type, and it is future-compatible with factoring that aspect of `ManuallyDrop` into a dedicated type in the future.
206
-
- Another tempting alternative is to attach the special meaning not to a type, but an attribute.
207
-
We could have a `#[maybe_dangling]` attribute that can be attached to ADTs, such that references and `Box` inside that type are not required to be dereferenceable or non-aliasing as the type gets moved around.
208
-
This has the advantage that user can attach the attribute to their own type and directly access the fields, so e.g. `MyType` can have a `Box<T>` field and all of the magic of `Box` is still available,
209
-
but the type can be moved around freely without worrying about aliasing. For the compiler and Miri implementation this would barely make a difference;
210
-
we would simply stop recursing into fields when encountering any type with that attribute (rather than only stopping when encountering the magic `MaybeDangling` type).
211
206
- Another alternative is to change the memory model such that the example code is fine as-is.
212
207
There are several variants of this:
213
208
-[Make all examples legal] All newtype wrappers behave the way `MaybeDangling` is specified in this RFC.
@@ -265,4 +260,6 @@ Notice that `UnsafeCell` acts "behind references" while `MaybeDangling`, like `M
0 commit comments