From 1386fdb49fc3dbaf400e640dba5ae88f71adaa3b Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 31 Oct 2024 14:14:46 +0100 Subject: [PATCH 01/16] Add changelog skeleton for 1.82 --- src/changelog.rst | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/changelog.rst b/src/changelog.rst index 5b2d6e1a..abadf180 100644 --- a/src/changelog.rst +++ b/src/changelog.rst @@ -18,6 +18,40 @@ with the change that has been applied due to it. just the language changes that had an impact to the FLS. See the `release notes`_ for a full list of changes. + +Language changes in Rust 1.82.0 +------------------------------- + +* `Don't make statement nonterminals match pattern nonterminals `_ + +* `Patterns matching empty types can now be omitted in common cases `_ + +* `Enforce supertrait outlives obligations when using trait impls `_ + +* `\`addr_of(_mut)!\` macros and the newly stabilized \`&raw (const|mut)\` are now safe to use with all static items `_ + +* `size_of_val_raw: for length 0 this is safe to call `_ + +* `Reorder trait bound modifiers *after* \`for<...>\` binder in trait bounds `_ + +* `Stabilize opaque type precise capturing (RFC 3617) `_ + +* `Stabilize \`&raw const\` and \`&raw mut\` operators (RFC 2582) `_ + +* `Stabilize unsafe extern blocks (RFC 3484) `_ + +* `Stabilize nested field access in \`offset_of!\` `_ + +* `Do not require \`T\` to be live when dropping \`[T; 0]\` `_ + +* `Stabilize \`const\` operands in inline assembly `_ + +* `Stabilize floating-point arithmetic in \`const fn\` `_ + +* `Stabilize explicit opt-in to unsafe attributes `_ + +* `Document NaN bit patterns guarantees `_ + Language changes in Rust 1.81.0 ------------------------------- From 750b682b45272c913193ee72fc8c17992e692b11 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 31 Oct 2024 14:18:32 +0100 Subject: [PATCH 02/16] Specify #120211 changes --- src/changelog.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/changelog.rst b/src/changelog.rst index abadf180..0a040f82 100644 --- a/src/changelog.rst +++ b/src/changelog.rst @@ -24,6 +24,8 @@ Language changes in Rust 1.82.0 * `Don't make statement nonterminals match pattern nonterminals `_ + * No change: Exact parsing behavior of non-terminals within declarative macros is not specified + * `Patterns matching empty types can now be omitted in common cases `_ * `Enforce supertrait outlives obligations when using trait impls `_ From dba1a34495033516cb929e08044473640ad0242d Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 31 Oct 2024 14:21:44 +0100 Subject: [PATCH 03/16] Specify #122792 changes --- src/changelog.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/changelog.rst b/src/changelog.rst index 0a040f82..65643ae4 100644 --- a/src/changelog.rst +++ b/src/changelog.rst @@ -30,6 +30,8 @@ Language changes in Rust 1.82.0 * `Enforce supertrait outlives obligations when using trait impls `_ + * No change: the concrete type inference resolution is not part of the FLS + * `\`addr_of(_mut)!\` macros and the newly stabilized \`&raw (const|mut)\` are now safe to use with all static items `_ * `size_of_val_raw: for length 0 this is safe to call `_ From b597ac51ba4c751adf5381540c2c5d0d1243d0bb Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 31 Oct 2024 14:23:13 +0100 Subject: [PATCH 04/16] Specify #125834 changes --- src/changelog.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/changelog.rst b/src/changelog.rst index 65643ae4..d93b560a 100644 --- a/src/changelog.rst +++ b/src/changelog.rst @@ -34,6 +34,8 @@ Language changes in Rust 1.82.0 * `\`addr_of(_mut)!\` macros and the newly stabilized \`&raw (const|mut)\` are now safe to use with all static items `_ + * No change: `addr_of` is not specified as it is a library defined macro, `&raw (const|mut)` appears as a new feature separately below + * `size_of_val_raw: for length 0 this is safe to call `_ * `Reorder trait bound modifiers *after* \`for<...>\` binder in trait bounds `_ From ee188ce89c24be9d34abc099fa82276f2bb113c9 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 31 Oct 2024 14:24:30 +0100 Subject: [PATCH 05/16] Specify #126152 changes --- src/changelog.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/changelog.rst b/src/changelog.rst index d93b560a..a039549e 100644 --- a/src/changelog.rst +++ b/src/changelog.rst @@ -38,6 +38,8 @@ Language changes in Rust 1.82.0 * `size_of_val_raw: for length 0 this is safe to call `_ + * No change: `size_of_val_raw` is a library defined function + * `Reorder trait bound modifiers *after* \`for<...>\` binder in trait bounds `_ * `Stabilize opaque type precise capturing (RFC 3617) `_ From c94ea31c5f32cc4d7b9f8d8a3273ed980e36c3dc Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 31 Oct 2024 14:29:27 +0100 Subject: [PATCH 06/16] Specify #127054 changes --- src/changelog.rst | 2 ++ src/types-and-traits.rst | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/changelog.rst b/src/changelog.rst index a039549e..ea9391f1 100644 --- a/src/changelog.rst +++ b/src/changelog.rst @@ -42,6 +42,8 @@ Language changes in Rust 1.82.0 * `Reorder trait bound modifiers *after* \`for<...>\` binder in trait bounds `_ + * Changed syntax: :s:`TraitBound` + * `Stabilize opaque type precise capturing (RFC 3617) `_ * `Stabilize \`&raw const\` and \`&raw mut\` operators (RFC 2582) `_ diff --git a/src/types-and-traits.rst b/src/types-and-traits.rst index ffd3d083..b715762e 100644 --- a/src/types-and-traits.rst +++ b/src/types-and-traits.rst @@ -2839,7 +2839,7 @@ Trait and Lifetime Bounds $$($$ TraitBound $$)$$ TraitBound ::= - $$?$$? ForGenericParameterList? TypePath + ($$?$$ | ForGenericParameterList)? TypePath ForGenericParameterList ::= $$for$$ GenericParameterList From 809c80bc0dcec4f4f9aa114db16ca3000b62e9b2 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 31 Oct 2024 14:49:57 +0100 Subject: [PATCH 07/16] Specify #127679 --- src/changelog.rst | 4 +++ src/expressions.rst | 67 +++++++++++++++++++++++++++++++++++++++++++-- src/glossary.rst | 11 ++++++++ 3 files changed, 80 insertions(+), 2 deletions(-) diff --git a/src/changelog.rst b/src/changelog.rst index ea9391f1..8eb270c4 100644 --- a/src/changelog.rst +++ b/src/changelog.rst @@ -48,6 +48,10 @@ Language changes in Rust 1.82.0 * `Stabilize \`&raw const\` and \`&raw mut\` operators (RFC 2582) `_ + * New section: :ref:`fls_vXGuvRWOLbEE` + + * New paragraphs: :p:`fls_K7SbApHPmwjM` + * `Stabilize unsafe extern blocks (RFC 3484) `_ * `Stabilize nested field access in \`offset_of!\` `_ diff --git a/src/expressions.rst b/src/expressions.rst index 1a08b39b..42350a2a 100644 --- a/src/expressions.rst +++ b/src/expressions.rst @@ -482,6 +482,9 @@ The following :t:`[construct]s` are :t:`[place expression context]s`: * :dp:`fls_Ufz9W5vyZkv3` The :t:`operand` of a :t:`borrow expression`, +* :dp:`fls_K7SbApHPmwjM` + The :t:`operand` of a :t:`raw borrow expression`, + * :dp:`fls_KxWIzoh9WwK7` The :t:`operand` of a :t:`dereference expression`, @@ -927,6 +930,7 @@ Operator Expressions | ErrorPropagationExpression | LazyBooleanExpression | NegationExpression + | RawBorrowExpression | TypeCastExpression .. rubric:: Legality Rules @@ -971,11 +975,11 @@ state, or simply :t:`borrowed`. The :t:`type` of a :t:`borrow expression` is determined as follows: * :dp:`fls_5b2x5ri2w54r` - If the :t:`borrow expression` denotes a :t:`shared reference`, then the + If the :t:`borrow expression` denotes an :t:`immutable borrow expression`, then the :t:`type` is ``&T``, where ``T`` is the :t:`type` of the :t:`operand`. * :dp:`fls_agl09ia869rk` - If the :t:`borrow expression` denotes a :t:`mutable reference`, then the + If the :t:`borrow expression` denotes a :t:`mutable borrow expression`, then the :t:`type` is ``&mut T``, where ``T`` is the :t:`type` of the :t:`operand`. :dp:`fls_8cvmee9bzs40` @@ -2057,6 +2061,65 @@ The :t:`evaluation` of a :t:`lazy or expression` proceeds as follows: false && panic!() this || that +.. _fls_vXGuvRWOLbEE: + +Raw Borrow Expression +~~~~~~~~~~~~~~~~~~~~~ + +.. rubric:: Syntax + +.. syntax:: + + RawBorrowExpression ::= + $$&$$ $$raw$$ ($$const$$ | $$mut$$) Operand + +.. rubric:: Legality Rules + +:dp:`fls_TS6DvMon5h27` +A :t:`raw borrow expression` is an :t:`expression` that creates a :t:`raw pointer` to the memory location of its :t:`operand` without incurring a :t:`borrow`. + +:dp:`fls_UtjWrE2qeplQ` +An :dt:`immutable raw borrow expression` is a :t:`raw borrow expression` that has :t:`keyword` ``const``. + +:dp:`fls_4e7EE4a8Yvmy` +A :dt:`mutable raw borrow expression` is a :t:`raw borrow expression` that has :t:`keyword` ``mut``. + +:dp:`fls_gOXUWePymgGV` +When the :t:`operand` of a :t:`raw borrow expression` is a :t:`place expression`, the :t:`raw borrow expression` produces a :t:`raw pointer` to the memory location indicated by the :t:`operand`. + +:dp:`fls_YBC8GrIBzZbi` +It is a static error if the :t:`operand` of a :t:`raw borrow expression` is a :t:`temporary`. + +:dp:`fls_Twkre8IzUa8S` +The :t:`type` of a :t:`raw borrow expression` is determined as follows: + +* :dp:`fls_Ki4FOzJMqtvJ` + If the :t:`raw borrow expression` denotes an :t:`immutable raw borrow expression`, then the :t:`type` is ``*const T``, where ``T`` is the :t:`type` of the :t:`operand`. + +* :dp:`fls_DJxQDBsO9hc7` + If the :t:`raw borrow expression` denotes a :t:`mutable raw borrow expression`, then the :t:`type` is ``*mut T``, where ``T`` is the :t:`type` of the :t:`operand`. + +:dp:`fls_WlXB0AHifCdd` +The :t:`value` of a :t:`raw borrow expression` is the address of its :t:`operand`. + +.. rubric:: Dynamic Semantics + +:dp:`fls_qQrV8QuGGcVO` +The :t:`evaluation` of a :t:`raw borrow expression` evaluates its :t:`operand`. + +.. rubric:: Examples + +.. code-block:: rust + + let mut answer = 42; + +:dp:`fls_dTABiwAPGhdZ` +Mutable raw borrow. + +.. syntax:: + + let ref_answer = &raw mut answer; + .. _fls_1qhsun1vyarz: Type Cast Expressions diff --git a/src/glossary.rst b/src/glossary.rst index a2c0b140..2c6a8c9b 100644 --- a/src/glossary.rst +++ b/src/glossary.rst @@ -5357,6 +5357,17 @@ an included :t:`range expression high bound`. :dp:`fls_krei7lc6lo8q` See :s:`RangeToInclusiveExpression`. +.. _fls_YLhE2qpzYXRK: + +raw borrow expression +^^^^^^^^^^^^^^^^^^^^^ + +:dp:`fls_Fe39wLb0vvEg` +A :dt:`raw borrow expression` is an :t:`expression` that creates a :t:`raw pointer` to the memory location of its :t:`operand` without incurring a :t:`borrow`. + +:dp:`fls_I71jq8BGyLqi` +See :s:`RawBorrowExpression`. + .. _fls_ipeh92kh17ze: raw byte string literal From 3d2209e08b6fc261b5ed7b30f960cc83482995c2 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 31 Oct 2024 14:54:54 +0100 Subject: [PATCH 08/16] Specify #128284 changes --- src/changelog.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/changelog.rst b/src/changelog.rst index 8eb270c4..e3f9d888 100644 --- a/src/changelog.rst +++ b/src/changelog.rst @@ -56,6 +56,8 @@ Language changes in Rust 1.82.0 * `Stabilize nested field access in \`offset_of!\` `_ + * No change: `offset_of` is a library defined macro + * `Do not require \`T\` to be live when dropping \`[T; 0]\` `_ * `Stabilize \`const\` operands in inline assembly `_ From bb57d513aabe3c6cd2a40986fe1351c45618e83f Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 31 Oct 2024 14:56:16 +0100 Subject: [PATCH 09/16] Specify #128438 changes --- src/changelog.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/changelog.rst b/src/changelog.rst index e3f9d888..769eead4 100644 --- a/src/changelog.rst +++ b/src/changelog.rst @@ -60,6 +60,8 @@ Language changes in Rust 1.82.0 * `Do not require \`T\` to be live when dropping \`[T; 0]\` `_ + * No change: The drop interaction with the borrow checker is not specified as the borrow checker is not specified in the FLS + * `Stabilize \`const\` operands in inline assembly `_ * `Stabilize floating-point arithmetic in \`const fn\` `_ From e686ac8a413a8c6269c1d68dbc58c0d5b1b11862 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 31 Oct 2024 15:07:01 +0100 Subject: [PATCH 10/16] Specify #128570 changes --- src/changelog.rst | 6 ++++++ src/inline-assembly.rst | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/changelog.rst b/src/changelog.rst index 769eead4..bf49d8af 100644 --- a/src/changelog.rst +++ b/src/changelog.rst @@ -64,6 +64,12 @@ Language changes in Rust 1.82.0 * `Stabilize \`const\` operands in inline assembly `_ + * Note: These changes affect content that is informational. + + * New syntax: :s:`ConstRegisterExpression` + + * New paragraphs: :p:`fls_81Ju1TEqJ48K`, :p:`fls_j9XOoXDmN5Dq`, :p:`fls_jU8zg4k8dFsY` + * `Stabilize floating-point arithmetic in \`const fn\` `_ * `Stabilize explicit opt-in to unsafe attributes `_ diff --git a/src/inline-assembly.rst b/src/inline-assembly.rst index 9754da23..d2206ca4 100644 --- a/src/inline-assembly.rst +++ b/src/inline-assembly.rst @@ -616,6 +616,7 @@ Register Arguments RegisterExpression ::= InputOutputRegisterExpression | SimpleRegisterExpression + | ConstRegisterExpression InputOutputRegisterExpression ::= InputRegisterExpression $$=>$$ OutputRegisterExpression @@ -631,6 +632,9 @@ Register Arguments Expression | UnderscoreExpression + ConstRegisterExpression ::= + $$const$$ Expression + .. rubric:: Legality Rules :dp:`fls_455dmnp4cxqv` @@ -682,6 +686,9 @@ initial :t:`value` of a :t:`register`. An :t:`output register expression` is an :t:`expression` that is assigned the :t:`value` of a :t:`register`. +:dp:`fls_81Ju1TEqJ48K` +A :dt:`const register expression` is an :t:`expression` that is evaluated at compile-time. + :dp:`fls_kkrcyk96w8x1` An :t:`input-output register expression` is a :t:`construct` that specifies both an :t:`input register expression` and an :t:`output register expression`. @@ -690,9 +697,11 @@ both an :t:`input register expression` and an :t:`output register expression`. A :t:`simple register expression` is either an :t:`expression` or an :t:`underscore expression`. -:dp:`fls_vu30cuq4y0ht` -A :t:`register expression` is either an :t:`input-output register expression` -or a :t:`simple register expression`. +:dp:`fls_j9XOoXDmN5Dq` +A :t:`register expression` is either an :t:`input-output register expression`, a :t:`simple register expression` or a :t:`const register expression`. + +:dp:`fls_jU8zg4k8dFsY` +The :t:`type` of a :t:`const register expression` shall be an :t:`integer type`. :dp:`fls_66owmltvhnu4` The :t:`type` of an :t:`input register expression`, From e3b23087d223c50f5e0e77964576eedbf1d26459 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 31 Oct 2024 15:12:13 +0100 Subject: [PATCH 11/16] Specify #129559 changes --- src/changelog.rst | 2 ++ src/types-and-traits.rst | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/changelog.rst b/src/changelog.rst index bf49d8af..a595e94f 100644 --- a/src/changelog.rst +++ b/src/changelog.rst @@ -76,6 +76,8 @@ Language changes in Rust 1.82.0 * `Document NaN bit patterns guarantees `_ + * New paragraph: :p:`fls_nuFAwLHOdQBx` + Language changes in Rust 1.81.0 ------------------------------- diff --git a/src/types-and-traits.rst b/src/types-and-traits.rst index b715762e..144d59b4 100644 --- a/src/types-and-traits.rst +++ b/src/types-and-traits.rst @@ -379,6 +379,11 @@ Floating Point Types :dp:`fls_yqflrq9s6p6n` :t:`Type` :c:`f64` is equivalent to the IEEE 754-2008 binary64 :t:`type`. +.. rubric:: Dynamic Semantics + +:dp:`fls_nuFAwLHOdQBx` +Operations on values of :t:`floating point types` may not preserve the sign bit in case of the value being a IEEE floating-point ``NaN``. + .. _fls_3qnpv2z7yjil: Integer Types From 41de15cc31203111daad6abe1f7a10885d209450 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 4 Nov 2024 15:30:35 +0100 Subject: [PATCH 12/16] Specify #128771 changes --- src/attributes.rst | 43 +++++++++++++++++++++++++++++++++++++++++++ src/changelog.rst | 2 ++ 2 files changed, 45 insertions(+) diff --git a/src/attributes.rst b/src/attributes.rst index 80ef645b..eea216e7 100644 --- a/src/attributes.rst +++ b/src/attributes.rst @@ -157,6 +157,7 @@ Built-in Attributes | TestContent | TrackCallerContent | TypeLengthLimitContent + | UnsafeContent | UsedContent | WindowsSubsystemContent @@ -226,6 +227,9 @@ The following :t:`[built-in attribute]s` are :dt:`[diagnostics attribute]s`: * :dp:`fls_NrTL2FruARAv` :t:`Attribute` ``expect``. +* :dp:`fls_4d2ArC50kNWL` + :t:`Attribute` ``unsafe``. + :dp:`fls_3fxhz0olhbcy` The following :t:`[built-in attribute]s` are :dt:`[documentation attribute]s`: @@ -1358,6 +1362,45 @@ related :t:`type`. second_field: i8 } +.. _fls_19LnTi3WabFd: + +Attribute ``unsafe`` +^^^^^^^^^^^^^^^^^^^^ + +.. rubric:: Syntax + +.. syntax:: + + UnsafeContent ::= + $$unsafe$$ $$($$ BuiltinAttributeContent $$)$$ + +.. rubric:: Legality Rules + +:dp:`fls_5pjo3nGOxbVw` +:t:`Attribute` :c:`unsafe` shall apply to what the contained :t:`attribute` applies to. + +:dp:`fls_gpxlWbQUNsj8` +:t:`Attribute` :c:`unsafe` behaves like the contained :t:`attribute`. + +:dp:`fls_PhrfxSBvXTPV` +The contained :t:`attribute` shall be one of: + +* :dp:`fls_pCSew95bKJJ5` + :t:`attribute` :c:`no_mangle`, + + :dp:`fls_NRLgmOXxuljQ` + :t:`attribute` :c:`export_name`, or + + :dp:`fls_ykpxNByUDyHG` + :t:`attribute` :c:`link_section`, + +.. rubric:: Examples + +.. code-block:: rust + + #[unsafe(no_mangle)] + pub fn clear_name() {} + .. _fls_7skf24auayqy: Attribute ``used`` diff --git a/src/changelog.rst b/src/changelog.rst index a595e94f..f5f17663 100644 --- a/src/changelog.rst +++ b/src/changelog.rst @@ -74,6 +74,8 @@ Language changes in Rust 1.82.0 * `Stabilize explicit opt-in to unsafe attributes `_ + * New section: :ref:`fls_19LnTi3WabFd` + * `Document NaN bit patterns guarantees `_ * New paragraph: :p:`fls_nuFAwLHOdQBx` From 0e784c55eb7eee72db75b4a0f8329b42f07c4745 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Tue, 3 Dec 2024 11:19:59 +0100 Subject: [PATCH 13/16] Specify #127672 changes --- src/changelog.rst | 6 ++++++ src/glossary.rst | 11 +++++++++++ src/types-and-traits.rst | 28 +++++++++++++++++++++++++--- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/src/changelog.rst b/src/changelog.rst index f5f17663..635e40d8 100644 --- a/src/changelog.rst +++ b/src/changelog.rst @@ -46,6 +46,12 @@ Language changes in Rust 1.82.0 * `Stabilize opaque type precise capturing (RFC 3617) `_ + * Changed syntax: :s:`ImplTraitTypeSpecification`, :s:`ImplTraitTypeSpecificationOneBound` + + * New syntax: :s:`UseCaptures`, :s:`UseCapturesGenericArgs`, , :s:`UseCapturesGenericArg` + + * New paragraphs: :p:`fls_69hqMjvNno9u`, :p:`fls_OnyR0Wsfk7KI`, :p:`fls_KgH6c5cC4S0G`, :p:`fls_iT9WCNfUZQnC` + * `Stabilize \`&raw const\` and \`&raw mut\` operators (RFC 2582) `_ * New section: :ref:`fls_vXGuvRWOLbEE` diff --git a/src/glossary.rst b/src/glossary.rst index 2c6a8c9b..07267c5e 100644 --- a/src/glossary.rst +++ b/src/glossary.rst @@ -7555,6 +7555,17 @@ unsuffixed integer An :dt:`unsuffixed integer` is an :t:`integer literal` without an :t:`integer suffix`. +.. _fls_Z8qvOkP4Zfj5: + +use capture +^^^^^^^^^^^ + +:dp:`fls_eZyPXG27Zwcg` +An :dt:`use capture` is a :t:`generic parameter` referenced via keyword $$use$$ within an :t:`anonymous return type`. + +:dp:`fls_Z8qvOkP4Zfj5` +See :s:`UseCaptures`. + .. _fls_fow1bnvduafi: use import diff --git a/src/types-and-traits.rst b/src/types-and-traits.rst index 144d59b4..591d000e 100644 --- a/src/types-and-traits.rst +++ b/src/types-and-traits.rst @@ -1113,10 +1113,20 @@ Impl Trait Types .. syntax:: ImplTraitTypeSpecification ::= - $$impl$$ TypeBoundList + $$impl$$ UseCaptures? TypeBoundList ImplTraitTypeSpecificationOneBound ::= - $$impl$$ TraitBound + $$impl$$ UseCaptures? TraitBound + + UseCaptures ::= + $$<$$ UseCapturesGenericArgs? $$>$$ + + UseCapturesGenericArgs ::= + UseCapturesGenericArg ($$,$$ UseCapturesGenericArg)* $$,$$? + + UseCapturesGenericArg ::= + Lifetime + | Identifier .. rubric:: Legality Rules @@ -1146,6 +1156,18 @@ of the :t:`return type`'s :t:`function` and its parent :t:`trait` or :dp:`fls_ECjhEI7eCwAj` An :t:`impl trait type` shall not contain :t:`[opt-out trait bound]s`. +:dp:`fls_69hqMjvNno9u` +An :t:`use capture` is a :t:`generic parameter` referenced via keyword ``use`` within an :t:`anonymous return type`. + +:dp:`fls_OnyR0Wsfk7KI` +:t:`[use capture]s` shall only be used within :t:`[anonymous return type]s`. + +:dp:`fls_KgH6c5cC4S0G` +An :t:`anonymous return type` that does not specify a list of :t:`[use capture]s` implicitly :t:`[use capture]s` all :t:`[type parameter]s` and :t:`[constant parameter]s` that are in :t:`scope`. + +:dp:`fls_iT9WCNfUZQnC` +An :t:`anonymous return type` behaves as if it contained all its :t:`[use capture]s`. + .. rubric:: Examples .. code-block:: rust @@ -2309,7 +2331,7 @@ any resulting :t:`type` information via :t:`type unification`. :dp:`fls_v5dWGuBKvQSJ` When an :t:`associated type` ``::Assoc`` is referenced within a :t:`type inference root` (either explicitly within the source code, or via the -inferece rules below), an :t:`obligation` requiring that ``Type`` implements +inference rules below), an :t:`obligation` requiring that ``Type`` implements ``Trait`` is introduced. :dp:`fls_SZgixDCAx6PQ` From 821e5f3485f1bd0339480483d66af644c167c08c Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Tue, 3 Dec 2024 11:59:39 +0100 Subject: [PATCH 14/16] Specify #127921 changes --- src/changelog.rst | 12 +++++++++++- src/ffi.rst | 13 ++++++------- src/functions.rst | 7 +++++-- src/items.rst | 4 ++++ src/lexical-elements.rst | 4 ++++ src/values.rst | 5 ++++- 6 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/changelog.rst b/src/changelog.rst index 635e40d8..d241067d 100644 --- a/src/changelog.rst +++ b/src/changelog.rst @@ -48,7 +48,7 @@ Language changes in Rust 1.82.0 * Changed syntax: :s:`ImplTraitTypeSpecification`, :s:`ImplTraitTypeSpecificationOneBound` - * New syntax: :s:`UseCaptures`, :s:`UseCapturesGenericArgs`, , :s:`UseCapturesGenericArg` + * New syntax: :s:`UseCaptures`, :s:`UseCapturesGenericArgs`, :s:`UseCapturesGenericArg` * New paragraphs: :p:`fls_69hqMjvNno9u`, :p:`fls_OnyR0Wsfk7KI`, :p:`fls_KgH6c5cC4S0G`, :p:`fls_iT9WCNfUZQnC` @@ -60,6 +60,16 @@ Language changes in Rust 1.82.0 * `Stabilize unsafe extern blocks (RFC 3484) `_ + * New syntax: :s:`ItemSafety` + + * Changed syntax: :s:`WeakKeyword`, :s:`FunctionQualifierList`, :s:`StaticDeclaration` + + * New paragraphs: :p:`fls_8ltVLtAfvy0m`, :p:`fls_WRpcVF1fLEpr`, :p:`fls_8ltVLtAfvy0m` + + * Changed paragraphs: :p:`fls_g0JEluWqBpNc`, :p:`fls_7ucwmzqtittv`, :p:`fls_4dje9t5y2dia`, :p:`fls_l88r9fj82650`, :p:`fls_fo9with6xumo` + + * Removed paragraph :p:`fls_iaimuqcclstl` + * `Stabilize nested field access in \`offset_of!\` `_ * No change: `offset_of` is a library defined macro diff --git a/src/ffi.rst b/src/ffi.rst index fd31133e..95725dfb 100644 --- a/src/ffi.rst +++ b/src/ffi.rst @@ -160,7 +160,10 @@ External Blocks :dp:`fls_4dje9t5y2dia` An :t:`external block` is a :t:`construct` that provides the declarations of -foreign :t:`[function]s` as unchecked imports. +:t:`[external function]s` and :t:`[external static]s` as unchecked imports. + +:dp:`fls_8ltVLtAfvy0m` +An :t:`unsafe external block` is an :t:`external block` subject to keyword ``unsafe``. :dp:`fls_Nz0l16hMxqTd` The :t:`ABI` of an :t:`external block` is determined as follows: @@ -171,10 +174,6 @@ The :t:`ABI` of an :t:`external block` is determined as follows: * :dp:`fls_PBsepNHImJKH` Otherwise the :t:`ABI` is the :t:`extern C ABI`. -:dp:`fls_iaimuqcclstl` -The ``unsafe`` :t:`keyword` of an :t:`external block` is rejected, but may -still be consumed by :t:`[macro]s`. - .. rubric:: Examples .. code-block:: rust @@ -201,7 +200,7 @@ External Functions An :t:`external function` is an unchecked import of a foreign :t:`function`. :dp:`fls_l88r9fj82650` -An :t:`external function` shall be invoked from an :t:`unsafe context`. +An :t:`external function` shall be invoked from an :t:`unsafe context` unless it is defined in an :t:`unsafe external block` and subject to :s:`ItemSafety` with keyword ``safe``. :dp:`fls_qwchgvvnp0qe` An :t:`external function` shall not specify a :s:`FunctionQualifierList`. @@ -240,7 +239,7 @@ An :t:`external static` inherits the :t:`ABI` of its enclosing :t:`external block`. :dp:`fls_fo9with6xumo` -An :t:`external static` shall be referenced from an :t:`unsafe context`. +An :t:`external static` shall be referenced from an :t:`unsafe context` unless it is defined in an :t:`unsafe external block` and subject to :s:`ItemSafety` with keyword ``safe``. :dp:`fls_tr7purzcldn0` An :t:`external static` shall not specify a :t:`static initializer`. diff --git a/src/functions.rst b/src/functions.rst index d42fca96..3e2f7e7f 100644 --- a/src/functions.rst +++ b/src/functions.rst @@ -16,7 +16,7 @@ Functions FunctionQualifierList $$fn$$ Name GenericParameterList? $$($$ FunctionParameterList? $$)$$ ReturnType? WhereClause? (FunctionBody | ;) FunctionQualifierList ::= - $$const$$? $$async$$? $$unsafe$$? AbiSpecification? + $$const$$? $$async$$? ItemSafety? AbiSpecification? FunctionParameterList ::= (FunctionParameter ($$,$$ FunctionParameter)* $$,$$?) @@ -171,7 +171,10 @@ is equivalent to :t:`function` } :dp:`fls_7ucwmzqtittv` -An :t:`unsafe function` is a :t:`function` subject to :t:`keyword` ``unsafe``. +An :t:`unsafe function` is a :t:`function` subject to an :s:`ItemSafety` with :t:`keyword` ``unsafe``. + +:dp:`fls_8ltVLtAfvy0m` +A :t:`function` shall only be subject to an :s:`ItemSafety` with :t:`keyword` ``safe`` if it is an :t:`external function` in an :t:`unsafe external block`. :dp:`fls_5hn8fkf7rcvz` The invocation of an :t:`unsafe function` shall require :t:`unsafe context`. diff --git a/src/items.rst b/src/items.rst index b037c22b..0bd9c6db 100644 --- a/src/items.rst +++ b/src/items.rst @@ -36,6 +36,10 @@ Items MacroRulesDeclaration | TerminatedMacroInvocation + ItemSafety ::= + $$unsafe$$ + | $$safe$$ + .. rubric:: Legality Rules :dp:`fls_s3b1cba9lfj5` diff --git a/src/lexical-elements.rst b/src/lexical-elements.rst index abc4ab2f..8ee5560c 100644 --- a/src/lexical-elements.rst +++ b/src/lexical-elements.rst @@ -1535,6 +1535,7 @@ Weak Keywords $$macro_rules$$ | $$'static$$ | $$union$$ + | $$safe$$ .. rubric:: Legality Rules @@ -1554,3 +1555,6 @@ Word ``'static`` acts as a :t:`keyword` only when used in the context of a Word ``union`` acts as a :t:`keyword` only when used in the context of a :s:`UnionDeclaration`. +:dp:`fls_g0JEluWqBpNc` +Word ``safe`` acts as a :t:`keyword` only when used as a qualifier of :s:`Function` or :s:`Static` in the context of a :s:`ExternalBlock`. + diff --git a/src/values.rst b/src/values.rst index 67cf5c0c..0ca2e8e7 100644 --- a/src/values.rst +++ b/src/values.rst @@ -140,7 +140,7 @@ Statics .. syntax:: StaticDeclaration ::= - $$static$$ $$mut$$? Name TypeAscription StaticInitializer? $$;$$ + ItemSafety? $$static$$ $$mut$$? Name TypeAscription StaticInitializer? $$;$$ StaticInitializer ::= $$=$$ Expression @@ -163,6 +163,9 @@ The :t:`type specification` of a :t:`static` shall have ``'static`` The :t:`type` of a :t:`static` shall implement the :std:`core::marker::Sized` :t:`trait`. +:dp:`fls_WRpcVF1fLEpr` +A :t:`static` shall only be subject to an :s:`ItemSafety` if it is an :t:`external static` in an :t:`unsafe external block`. + :dp:`fls_doi4z6u55bi7` A :t:`mutable static` is a :t:`static` with :t:`keyword` ``mut`` whose :t:`value` can be modified. From 22cee9e27194137e8cecd97311f0577adbd49085 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Tue, 3 Dec 2024 12:13:17 +0100 Subject: [PATCH 15/16] Specify #128596 changes --- src/changelog.rst | 4 ++++ src/expressions.rst | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/changelog.rst b/src/changelog.rst index d241067d..9071988c 100644 --- a/src/changelog.rst +++ b/src/changelog.rst @@ -88,6 +88,10 @@ Language changes in Rust 1.82.0 * `Stabilize floating-point arithmetic in \`const fn\` `_ + * New paragraph: :p:`fls_lSxXWxJn0vMO` + + * Removed paragraph: :p:`fls_9mrrosm8jnn7` + * `Stabilize explicit opt-in to unsafe attributes `_ * New section: :ref:`fls_19LnTi3WabFd` diff --git a/src/expressions.rst b/src/expressions.rst index 42350a2a..e270a446 100644 --- a/src/expressions.rst +++ b/src/expressions.rst @@ -280,11 +280,6 @@ explicitly invokes an :t:`associated trait function` or uses :t:`[arithmetic operator]s` of non-builtin :t:`[type]s` that invoke :std:`core::ops` :t:`[trait]s`. -:dp:`fls_9mrrosm8jnn7` -An :t:`arithmetic expression` that operates with :t:`[floating-point value]s` is -not considered a :t:`constant expression` when it appears inside the -:t:`function body` of a :t:`constant function`. - :dp:`fls_fmqar6o1bwqk` It is a static error if the :t:`size operand` of an :t:`array repetition constructor` or an :t:`array type` depends on @@ -938,6 +933,11 @@ Operator Expressions :dp:`fls_ursc5ynymoy` An :t:`operator expression` is an :t:`expression` that involves an operator. +.. rubric:: Dynamic Semantics + +:dp:`fls_lSxXWxJn0vMO` +An :t:`operator expression` that operates with :t:`[floating-point value]s` run as a :t:`constant expression` is allowed to yield different :t:`[value]s` compared to when run as a non-:t:`constant expression`. + .. _fls_qztk0bkju9u: Borrow Expression From 3055f43ab9cb1c73512fbc1a2e8bdea606c4585c Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 5 Dec 2024 12:12:04 +0100 Subject: [PATCH 16/16] Specify 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..08658414 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` +: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_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 diff --git a/src/patterns.rst b/src/patterns.rst index 4f46fb01..bf6b4671 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` itself 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..a26b51d7 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`. + +* :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