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 5b2d6e1a..0feb8aff 100644 --- a/src/changelog.rst +++ b/src/changelog.rst @@ -18,6 +18,134 @@ 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.83.0 +------------------------------- + +* `Stabilize \`&mut\`, \`*mut\`, \`&Cell\`, and \`*const Cell\` in const. `_ + + * Changed paragraphs: :p:`fls_to4e7imq2c0w`, :p:`fls_6g7c1kjrmfnr`, :p:`fls_hkbwa8xx2fwx` + +* `Allow creating references to statics in \`const\` initializers. `_ + + * No change: This previous restriction is not specified in the FLS + +* `Implement raw lifetimes and labels (\`'r#ident\`). `_ + + * Changed syntax: :s:`Lifetime` + +* `Define behavior when atomic and non-atomic reads race. `_ + + * No change: Already covered by the definition of :t:`data race`. + +* `Non-exhaustive structs may now be empty. `_ + + * Removed paragraph: :p:`fls_2CWUWbYT9KcT` + + * Changed paragraph: :p:`fls_fSNrRsgzLd0E`, :p:`fls_S9QL6yVF5LFI` + +* `Disallow implicit coercions from places of type \`!\` `_ + + * No change: The FLS does not specify type inference to such a degree + +* `\`const extern\` functions can now be defined for other calling conventions. `_ + + * No change: This previous restriction is not specified in the FLS + +* `Stabilize \`expr_2021\` macro fragment specifier in all editions. `_ + + * Changed syntax: :s:`MacroFragmentSpecifier` + + * Changed paragraphs: :p:`fls_k00bck2k8tde`, :p:`fls_PxR9vNHsaFnI` + +* `The \`non_local_definitions\` lint now fires on less code and warns by default. `_ + + * No change: Lints are not part of the FLS + +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 `_ + + * 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 + +* `\`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 `_ + + * No change: `size_of_val_raw` is a library defined function + +* `Reorder trait bound modifiers *after* \`for<...>\` binder in trait bounds `_ + + * Changed syntax: :s:`TraitBound` + +* `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` + + * New paragraphs: :p:`fls_K7SbApHPmwjM` + +* `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 + +* `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 `_ + + * 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\` `_ + + * New paragraph: :p:`fls_lSxXWxJn0vMO` + + * Removed paragraph: :p:`fls_9mrrosm8jnn7` + +* `Stabilize explicit opt-in to unsafe attributes `_ + + * New section: :ref:`fls_19LnTi3WabFd` + +* `Document NaN bit patterns guarantees `_ + + * New paragraph: :p:`fls_nuFAwLHOdQBx` + Language changes in Rust 1.81.0 ------------------------------- diff --git a/src/expressions.rst b/src/expressions.rst index 1a08b39b..a62bb813 100644 --- a/src/expressions.rst +++ b/src/expressions.rst @@ -194,8 +194,7 @@ involve :t:`[type]s` that require :t:`destruction`: :t:`[Constant parameter]s`, * :dp:`fls_to4e7imq2c0w` - :t:`[Dereference expression]s` when the :t:`operand` is not of a - :t:`raw pointer type`, + :t:`[Dereference expression]s`, * :dp:`fls_krtbrpwf3mh0` :t:`[Expression statement]s`, @@ -211,8 +210,7 @@ involve :t:`[type]s` that require :t:`destruction`: :t:`[If let expression]s`, * :dp:`fls_6g7c1kjrmfnr` - :t:`[Immutable borrow expression]s` where the borrowed :t:`type` is not - subject to :t:`interior mutability`. + :t:`[Immutable borrow expression]s`. * :dp:`fls_rpapnm3afan8` :t:`[Index expression]s`, @@ -251,8 +249,7 @@ involve :t:`[type]s` that require :t:`destruction`: :t:`[Range expression]s`, * :dp:`fls_hkbwa8xx2fwx` - :t:`[Shared borrow]s` that do not involve :t:`[type]s` with - :t:`interior mutability`, + :t:`[Borrow]s`, * :dp:`fls_fobs8ebt7dhc` :t:`[Struct expression]s`, @@ -280,11 +277,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 @@ -482,6 +474,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 +922,7 @@ Operator Expressions | ErrorPropagationExpression | LazyBooleanExpression | NegationExpression + | RawBorrowExpression | TypeCastExpression .. rubric:: Legality Rules @@ -934,6 +930,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 @@ -971,11 +972,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 +2058,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/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/glossary.rst b/src/glossary.rst index a2c0b140..08658414 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 @@ -7544,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 @@ -7663,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/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`, 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/macros.rst b/src/macros.rst index e9869644..f8d2d13e 100644 --- a/src/macros.rst +++ b/src/macros.rst @@ -119,6 +119,7 @@ Metavariables MacroFragmentSpecifier ::= $$block$$ | $$expr$$ + | $$expr_2021$$ | $$ident$$ | $$item$$ | $$lifetime$$ @@ -158,7 +159,7 @@ a :t:`metavariable`. :dt:`[fragment specifier restriction]s` on the :t:`[token]s` that follow them: * :dp:`fls_PxR9vNHsaFnI` - ``expr`` shall only be followed by ``=>``, ``,``, or ``;``. + ``expr`` and ``expr_2021`` shall only be followed by ``=>``, ``,``, or ``;``. * :dp:`fls_ePyoTeJJ11N0` ``pat`` shall only be followed by ``=>``, ``,``, ``=``, ``|``, ``if``, or @@ -840,7 +841,7 @@ A :t:`metavariable` in a :t:`macro matcher` is matched against a sequence of :t:`Fragment specifier` **block** requires a :t:`block expression`. * :dp:`fls_k00bck2k8tde` - :t:`Fragment specifier` **expr** requires an :t:`expression`. + :t:`Fragment specifier` **expr** and **expr_2021** requires an :t:`expression` that is not an :t:`underscore expression` or :t:`const block expression`. * :dp:`fls_pf0qrz5nadl2` :t:`Fragment specifier` **ident** requires a :t:`pure identifier`. diff --git a/src/patterns.rst b/src/patterns.rst index 4f46fb01..03d066f1 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 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:`[visible empty enum variant]s` and one non-:t:`visible empty enum variant` where the :t:`[type]s` of all :t:`[field]s` are not subject to :t:`visible emptiness` * :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:`[visible empty enum variant]s` and one non-:t:`visible 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 ffd3d083..9b4a1168 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 @@ -1108,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 @@ -1141,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 @@ -2177,6 +2204,46 @@ 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` where all :t:`[enum variant]s` are subject to :t:`visible emptiness`. + +* :dp:`fls_fSNrRsgzLd0E` + The :t:`type` is a :t:`struct type` 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` when the :t:`type` of at least one of the :t:`enum variant`'s :t:`visible ` :t:`[field]s` is subject to :t:`visible emptiness`. + .. _fls_lv7w7aalpwm5: Type Inference @@ -2304,7 +2371,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` @@ -2839,7 +2906,7 @@ Trait and Lifetime Bounds $$($$ TraitBound $$)$$ TraitBound ::= - $$?$$? ForGenericParameterList? TypePath + ($$?$$ | ForGenericParameterList)? TypePath ForGenericParameterList ::= $$for$$ GenericParameterList @@ -2923,7 +2990,7 @@ Lifetimes .. syntax:: Lifetime ::= - $$'$$ NonKeywordIdentifier + $$'$$ (NonKeywordIdentifier | RawIdentifierKeyword) AttributedLifetime ::= OuterAttributeOrDoc* Lifetime 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.