From 5823ae28441bffd75a71e788fe05b0019668e5e6 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 5 Dec 2024 12:12:04 +0100 Subject: [PATCH] Describe rust-lang/rust#122792 --- src/changelog.rst | 4 ++++ src/glossary.rst | 24 ++++++++++++++++++++ src/patterns.rst | 15 +++++-------- src/types-and-traits.rst | 47 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 9 deletions(-) diff --git a/src/changelog.rst b/src/changelog.rst index 9071988c..2fe2594c 100644 --- a/src/changelog.rst +++ b/src/changelog.rst @@ -28,6 +28,10 @@ Language changes in Rust 1.82.0 * `Patterns matching empty types can now be omitted in common cases `_ + * 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 `_ * No change: the concrete type inference resolution is not part of the FLS diff --git a/src/glossary.rst b/src/glossary.rst index 07267c5e..0094fef5 100644 --- a/src/glossary.rst +++ b/src/glossary.rst @@ -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` +A :dt:`visible empty type` is a :t:`type` subject to :t:`visible emptiness`. + +.. _fls_EnT5zRuwviWM: + +visible empty enum variant +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +:dp:`fls_MQiPWNwdk95I` +:dt:`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_HYWQ0lJS3TET: + +visible empty type +^^^^^^^^^^^^^^^^^^ + +:dp:`fls_OLVD0u9w68Gl` +A :dt:`visible empty enum variant` is an :t:`enum variant` subject to :t:`visible emptiness`. + .. _fls_iplp3gvfbcpw: weak keyword diff --git a/src/patterns.rst b/src/patterns.rst index 4f46fb01..2ae74ad8 100644 --- a/src/patterns.rst +++ b/src/patterns.rst @@ -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 @@ -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 @@ -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` is an :t:`irrefutable pattern`. :dp:`fls_fedo8zhgpla5` The :t:`type` of a :t:`reference pattern` is determined as follows: @@ -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: diff --git a/src/types-and-traits.rst b/src/types-and-traits.rst index 591d000e..bc8c25b3 100644 --- a/src/types-and-traits.rst +++ b/src/types-and-traits.rst @@ -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 ` 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 ` :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`, and + +* :dp:`fls_2CWUWbYT9KcT` + The :t:`type` of at least one of the :t:`enum variant`'s visible :t:`[field]s` is subject to :t:`visible emptiness`. + .. _fls_lv7w7aalpwm5: Type Inference