Skip to content

Commit 821e5f3

Browse files
committed
Specify #127921 changes
1 parent 0e784c5 commit 821e5f3

File tree

6 files changed

+34
-11
lines changed

6 files changed

+34
-11
lines changed

src/changelog.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Language changes in Rust 1.82.0
4848

4949
* Changed syntax: :s:`ImplTraitTypeSpecification`, :s:`ImplTraitTypeSpecificationOneBound`
5050

51-
* New syntax: :s:`UseCaptures`, :s:`UseCapturesGenericArgs`, , :s:`UseCapturesGenericArg`
51+
* New syntax: :s:`UseCaptures`, :s:`UseCapturesGenericArgs`, :s:`UseCapturesGenericArg`
5252

5353
* New paragraphs: :p:`fls_69hqMjvNno9u`, :p:`fls_OnyR0Wsfk7KI`, :p:`fls_KgH6c5cC4S0G`, :p:`fls_iT9WCNfUZQnC`
5454

@@ -60,6 +60,16 @@ Language changes in Rust 1.82.0
6060

6161
* `Stabilize unsafe extern blocks (RFC 3484) <https://github.com/rust-lang/rust/pull/127921>`_
6262

63+
* New syntax: :s:`ItemSafety`
64+
65+
* Changed syntax: :s:`WeakKeyword`, :s:`FunctionQualifierList`, :s:`StaticDeclaration`
66+
67+
* New paragraphs: :p:`fls_8ltVLtAfvy0m`, :p:`fls_WRpcVF1fLEpr`, :p:`fls_8ltVLtAfvy0m`
68+
69+
* Changed paragraphs: :p:`fls_g0JEluWqBpNc`, :p:`fls_7ucwmzqtittv`, :p:`fls_4dje9t5y2dia`, :p:`fls_l88r9fj82650`, :p:`fls_fo9with6xumo`
70+
71+
* Removed paragraph :p:`fls_iaimuqcclstl`
72+
6373
* `Stabilize nested field access in \`offset_of!\` <https://github.com/rust-lang/rust/pull/128284>`_
6474

6575
* No change: `offset_of` is a library defined macro

src/ffi.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ External Blocks
160160

161161
:dp:`fls_4dje9t5y2dia`
162162
An :t:`external block` is a :t:`construct` that provides the declarations of
163-
foreign :t:`[function]s` as unchecked imports.
163+
:t:`[external function]s` and :t:`[external static]s` as unchecked imports.
164+
165+
:dp:`fls_8ltVLtAfvy0m`
166+
An :t:`unsafe external block` is an :t:`external block` subject to keyword ``unsafe``.
164167

165168
:dp:`fls_Nz0l16hMxqTd`
166169
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:
171174
* :dp:`fls_PBsepNHImJKH`
172175
Otherwise the :t:`ABI` is the :t:`extern C ABI`.
173176

174-
:dp:`fls_iaimuqcclstl`
175-
The ``unsafe`` :t:`keyword` of an :t:`external block` is rejected, but may
176-
still be consumed by :t:`[macro]s`.
177-
178177
.. rubric:: Examples
179178

180179
.. code-block:: rust
@@ -201,7 +200,7 @@ External Functions
201200
An :t:`external function` is an unchecked import of a foreign :t:`function`.
202201

203202
:dp:`fls_l88r9fj82650`
204-
An :t:`external function` shall be invoked from an :t:`unsafe context`.
203+
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``.
205204

206205
:dp:`fls_qwchgvvnp0qe`
207206
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
240239
:t:`external block`.
241240

242241
:dp:`fls_fo9with6xumo`
243-
An :t:`external static` shall be referenced from an :t:`unsafe context`.
242+
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``.
244243

245244
:dp:`fls_tr7purzcldn0`
246245
An :t:`external static` shall not specify a :t:`static initializer`.

src/functions.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Functions
1616
FunctionQualifierList $$fn$$ Name GenericParameterList? $$($$ FunctionParameterList? $$)$$ ReturnType? WhereClause? (FunctionBody | ;)
1717

1818
FunctionQualifierList ::=
19-
$$const$$? $$async$$? $$unsafe$$? AbiSpecification?
19+
$$const$$? $$async$$? ItemSafety? AbiSpecification?
2020

2121
FunctionParameterList ::=
2222
(FunctionParameter ($$,$$ FunctionParameter)* $$,$$?)
@@ -171,7 +171,10 @@ is equivalent to :t:`function`
171171
}
172172
173173
:dp:`fls_7ucwmzqtittv`
174-
An :t:`unsafe function` is a :t:`function` subject to :t:`keyword` ``unsafe``.
174+
An :t:`unsafe function` is a :t:`function` subject to an :s:`ItemSafety` with :t:`keyword` ``unsafe``.
175+
176+
:dp:`fls_8ltVLtAfvy0m`
177+
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`.
175178

176179
:dp:`fls_5hn8fkf7rcvz`
177180
The invocation of an :t:`unsafe function` shall require :t:`unsafe context`.

src/items.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ Items
3636
MacroRulesDeclaration
3737
| TerminatedMacroInvocation
3838
39+
ItemSafety ::=
40+
$$unsafe$$
41+
| $$safe$$
42+
3943
.. rubric:: Legality Rules
4044

4145
:dp:`fls_s3b1cba9lfj5`

src/lexical-elements.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,6 +1535,7 @@ Weak Keywords
15351535
$$macro_rules$$
15361536
| $$'static$$
15371537
| $$union$$
1538+
| $$safe$$
15381539
15391540
.. rubric:: Legality Rules
15401541

@@ -1554,3 +1555,6 @@ Word ``'static`` acts as a :t:`keyword` only when used in the context of a
15541555
Word ``union`` acts as a :t:`keyword` only when used in the context of a
15551556
:s:`UnionDeclaration`.
15561557

1558+
:dp:`fls_g0JEluWqBpNc`
1559+
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`.
1560+

src/values.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ Statics
140140
.. syntax::
141141

142142
StaticDeclaration ::=
143-
$$static$$ $$mut$$? Name TypeAscription StaticInitializer? $$;$$
143+
ItemSafety? $$static$$ $$mut$$? Name TypeAscription StaticInitializer? $$;$$
144144

145145
StaticInitializer ::=
146146
$$=$$ Expression
@@ -163,6 +163,9 @@ The :t:`type specification` of a :t:`static` shall have ``'static``
163163
The :t:`type` of a :t:`static` shall implement the :std:`core::marker::Sized`
164164
:t:`trait`.
165165

166+
:dp:`fls_WRpcVF1fLEpr`
167+
A :t:`static` shall only be subject to an :s:`ItemSafety` if it is an :t:`external static` in an :t:`unsafe external block`.
168+
166169
:dp:`fls_doi4z6u55bi7`
167170
A :t:`mutable static` is a :t:`static` with :t:`keyword` ``mut`` whose
168171
:t:`value` can be modified.

0 commit comments

Comments
 (0)