Skip to content

Commit b169ee0

Browse files
Merge #434
434: Disallow non-copy types in union types r=Dajamante a=Veykril cc #141 Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 parents ff73e42 + 7004823 commit b169ee0

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/types-and-traits.rst

+22-1
Original file line numberDiff line numberDiff line change
@@ -805,12 +805,33 @@ Union Types
805805
.. rubric:: Legality Rules
806806

807807
:dp:`fls_nskmnzq95yqm`
808-
A :t:`union type` is an :t:`abstract data type` similar to a :t:`C`-like union.
808+
A :t:`union type` is an :t:`abstract data type` that is a sum of other
809+
:t:`types`.
809810

810811
:dp:`fls_1caus8ybmfli`
811812
The :t:`name` of a :t:`union field` shall be unique within the related
812813
:s:`RecordStructDeclaration`.
813814

815+
:dp:`fls_ZJG2Q6lJYXhY`
816+
The :t:`type` of a :t:`union field` shall be either:
817+
818+
* :dp:`fls_hLTnHnZuaHve`
819+
A :t:`copy type`, or
820+
821+
* :dp:`fls_JWgSckDtN13c`
822+
A :t:`mutable reference type`, or
823+
824+
* :dp:`fls_sXZknxozJxtC`
825+
:std:`core::mem::ManuallyDrop`, or
826+
827+
* :dp:`fls_vgNK01SXacnx`
828+
A :t:`tuple type` whose :t:`[tuple field]s`' :t:`[type]s` are all valid
829+
:t:`union field` :t:`[type]s`, or
830+
831+
* :dp:`fls_bQhh3zHAKjSu`
832+
An :t:`array type` whose :t:`element type` is a valid :t:`union field`
833+
:t:`[type]s`.
834+
814835
.. rubric:: Examples
815836

816837
.. code-block:: rust

0 commit comments

Comments
 (0)