Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Veykril committed Dec 9, 2024
1 parent 22cee9e commit 3055f43
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ Language changes in Rust 1.82.0

* `Patterns matching empty types can now be omitted in common cases <https://github.com/rust-lang/rust/pull/122792>`_

* New section: :ref:`fls_mcxF9y5u66sZ`

* Changed paragraphs: :p:`fls_9fjspnefoyvz`, :p:`fls_uq7ftuuq1sig`, :p:`fls_cfoy86mkmqa4`, :p:`fls_rnppz6y5z8pi`, :p:`fls_x0bmzl1315gq`, :p:`fls_MK83WE0iDqNf`

* `Enforce supertrait outlives obligations when using trait impls <https://github.com/rust-lang/rust/pull/124336>`_

* No change: the concrete type inference resolution is not part of the FLS
Expand Down
24 changes: 24 additions & 0 deletions src/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7685,6 +7685,30 @@ visibility modifier
A :dt:`visibility modifier` sets the :t:`visibility` of the :t:`name` of an
:t:`item`.

.. _fls_dLlUt8PrXAls:

visible emptiness
^^^^^^^^^^^^^^^^^

:dp:`fls_shXDYqnUy2Pb`
:dt:`Visible emptiness <visible emptiness>` is a property of :t:`[type]s` and :t:`[enum variant]s` that have no :t:`[value]s` that are fully observable.

.. _fls_EnT5zRuwviWM:

visible empty enum variant
^^^^^^^^^^^^^^^^^^^^^^^^^^

:dp:`fls_MQiPWNwdk95I`
A :dt:`visible empty enum variant` is an :t:`enum variant` subject to :t:`visible emptiness`.

.. _fls_HYWQ0lJS3TET:

visible empty type
^^^^^^^^^^^^^^^^^^

:dp:`fls_OLVD0u9w68Gl`
A :dt:`visible empty type` is a :t:`type` subject to :t:`visible emptiness`.

.. _fls_iplp3gvfbcpw:

weak keyword
Expand Down
15 changes: 6 additions & 9 deletions src/patterns.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,11 @@ Refutability
match all possible values of a :t:`type`.

:dp:`fls_9fjspnefoyvz`
An :t:`irrefutable pattern` is a :t:`pattern` that always matches the :t:`value`
it is being matched against.
An :t:`irrefutable pattern` is a :t:`pattern` that always matches any :t:`value` of its :t:`type`.

:dp:`fls_uq7ftuuq1sig`
A :t:`refutable pattern` is a :t:`pattern` that has a possibility of not
matching the :t:`value` it is being matched against.
matching a :t:`value` of a its :t:`type`

:dp:`fls_mnbyt7jfYAZ9`
A :t:`pattern` that is not an :t:`irrefutable pattern` is a
Expand Down Expand Up @@ -385,12 +384,10 @@ to an :t:`associated constant`.
A :t:`path pattern` is an :t:`irrefutable pattern` when it refers to:

* :dp:`fls_cfoy86mkmqa4`
A :t:`constant` whose :t:`type` is an :t:`irrefutable pattern`, or
An :t:`irrefutable constant`,

* :dp:`fls_rnppz6y5z8pi`
An :t:`enum variant` of an :t:`enum type` with a single :t:`enum variant`
where the :t:`[type]s` of all :t:`[field]s` are :t:`[irrefutable pattern]s`,
or
An :t:`enum variant` of an :t:`enum type` with zero or more :t:`[visibly empty enum variant]s` and one non-:t:`visibly empty enum variant` where the :t:`[type]s` of all :t:`[field]s` are not subject to :t:`visible emptiness`, or

* :dp:`fls_ag6m4mvpturw`
A :t:`struct` where the :t:`[type]s` of all :t:`[field]s` are
Expand Down Expand Up @@ -570,7 +567,7 @@ A :t:`reference pattern` is a :t:`pattern` that dereferences a :t:`pointer` that
is being matched.

:dp:`fls_x0bmzl1315gq`
A :t:`reference pattern` is an :t:`irrefutable pattern`.
A :t:`reference pattern` is an :t:`irrefutable pattern` when its nested :t:`pattern` itself is an :t:`irrefutable pattern`.

:dp:`fls_fedo8zhgpla5`
The :t:`type` of a :t:`reference pattern` is determined as follows:
Expand Down Expand Up @@ -756,7 +753,7 @@ A :t:`struct pattern` is an :t:`irrefutable pattern` if
A :t:`struct type` or a :t:`union type`, or

* :dp:`fls_MK83WE0iDqNf`
An :t:`enum variant` of an :t:`enum` with a single :t:`enum variant`.
An :t:`enum variant` of an :t:`enum type` with zero or more :t:`[visibly empty enum variant]s` and one non-:t:`visibly empty enum variant` where the :t:`[type]s` of all :t:`[field]s` are not subject to :t:`visible emptiness`.

.. _fls_nruvg0es3kx7:

Expand Down
47 changes: 47 additions & 0 deletions src/types-and-traits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2204,6 +2204,53 @@ be modified through :t:`[immutable reference]s`.
A :t:`type` is subject to :t:`interior mutability` when it contains a
:std:`core::cell::UnsafeCell`.

.. _fls_mcxF9y5u66sZ:

Visible Emptiness
~~~~~~~~~~~~~~~~~

.. rubric:: Legality Rules

:dp:`fls_SD4yUEQ9hHa3`
:t:`Visible emptiness <visible emptiness>` is a property of :t:`[type]s` and :t:`[enum variant]s` that have no :t:`[value]s` that are fully observable.

:dp:`fls_GeoneCP5TYwf`
A :t:`visible empty type` is a :t:`type` subject to :t:`visible emptiness`.

:dp:`fls_A2W4v53ihTGx`
A :t:`visible empty enum variant` is an :t:`enum variant` subject to :t:`visible emptiness`.

:dp:`fls_AXOtKdSQR4AF`
A :t:`type` is subject to :t:`visible emptiness` as follows:

* :dp:`fls_ZfnYORORz40y`
The :t:`type` is the :t:`never type`.

* :dp:`fls_TE2GBnZX2YFW`
The :t:`type` is a :t:`zero-variant enum type`.

* :dp:`fls_GNFzLMH8RBUC`
The :t:`type` is an :t:`enum type` not subject to :t:`attribute` :c:`non_exhaustive` with all :t:`[enum variant]s` are subject to :t:`visible emptiness`.

* :dp:`fls_fSNrRsgzLd0E`
The :t:`type` is a :t:`struct type` not subject to :t:`attribute` :c:`non_exhaustive` with at least one :t:`visible <visibility>` :t:`field` whose :t:`type` is subject to :t:`visible emptiness`.

* :dp:`fls_R65LmGTvSlIm`
The :t:`type` is a :t:`tuple type` with at least one of the contained :t:`[type]s` is subject to :t:`visible emptiness`.

* :dp:`fls_yiPv3wKYkSRl`
The :t:`type` is an :t:`array type` with a non-zero :t:`size operand` and an :t:`element type` that is subject to :t:`visible emptiness`.


:dp:`fls_S9QL6yVF5LFI`
A :t:`enum variant` is subject to :t:`visible emptiness` as follows:

* :dp:`fls_xegU2TFXypcu`
The respective :t:`enum type` is not subject to :t:`attribute` :c:`non_exhaustive`.

* :dp:`fls_2CWUWbYT9KcT`
The :t:`type` of at least one of the :t:`enum variant`'s visible <visibility> :t:`[field]s` is subject to :t:`visible emptiness`.

.. _fls_lv7w7aalpwm5:

Type Inference
Expand Down

0 comments on commit 3055f43

Please sign in to comment.