Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Union initialization and Drop #2514

Merged
merged 12 commits into from
Oct 17, 2018
Prev Previous commit
Next Next commit
unresolved question: move out of dropping union
  • Loading branch information
RalfJung committed Sep 17, 2018
commit 0971718c65fa0fa02a1fd6ef0772bd92ae5b635b
7 changes: 7 additions & 0 deletions text/0000-union-initialization-and-drop.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,3 +365,10 @@ we maybe try harder, e.g. lint against using `*` below a union type when
describing a place? That would make people write `let v = &mut u.f; *v =
Vec::new();`. It is not clear that this helps in terms of pointing out that an
automatic drop may be happening.

We could allow moving out of a union field even if it implements `Drop`. That
would have the effect of making the union considered uninitialized, i.e., it
would not be dropped implicitly when it goes out of scope. However, it might be
useful to not let people do this accidentally. The same effect can always be
achieved by having a dropless union wrapped in a newtype `struct` with the
desired `Drop`.