Skip to content

Commit 70da9b2

Browse files
committed
Specify const block expressions
1 parent 6086955 commit 70da9b2

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

src/entities-and-resolution.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,10 @@ related :t:`let statement` appears.
496496
The :t:`binding` of a :t:`match arm` is :t:`in scope` within its related
497497
:t:`[expression]s` and related :t:`match arm guard`.
498498

499+
:dp:`fls_eBacCVlDaKYK`
500+
A :t:`binding` declared outside of a :t:`const block expression` is not :t:`in
501+
scope` within such a :t:`const block expression`.
502+
499503
.. _fls_ftphlagzd2te:
500504

501505
Generic Parameter Scope

src/expressions.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Expressions
2020
OuterAttributeOrDoc* (
2121
AsyncBlockExpression
2222
| BlockExpression
23+
| ConstBlockExpression
2324
| IfExpression
2425
| IfLetExpression
2526
| LoopExpression
@@ -316,6 +317,9 @@ A :t:`constant context` is a :t:`construct` that requires a
316317
* :dp:`fls_ib8p7dfwddx2`
317318
The :t:`static initializer` of a :t:`static`.
318319

320+
* :dp:`fls_ucFupTeCyylb`
321+
The :t:`block expression` of a :t:`const block expression`.
322+
319323
:dp:`fls_ox6sgl9n43g2`
320324
It is a static error to create a :t:`mutable reference` in a
321325
:t:`constant context`.
@@ -784,6 +788,48 @@ the :t:`[capture target]s` of the :t:`async block expression`.
784788
42
785789
}
786790
791+
.. _fls_G59PiNQkVUnQ:
792+
793+
Const Blocks
794+
~~~~~~~~~~~~
795+
796+
.. rubric:: Syntax
797+
798+
.. syntax::
799+
800+
ConstBlockExpression ::=
801+
$$const$$ BlockExpression
802+
803+
.. rubric:: Legality Rules
804+
805+
:dp:`fls_0lcunL4bo8ka`
806+
A :t:`const block expression` is a :t:`block expression` that is specified
807+
with :t:`keyword` ``const`` and encapsulates behavior which is evaluated
808+
statically.
809+
810+
:dp:`fls_veEGzEbpT4ny`
811+
An :t:`const block expression` denotes a new :t:`control flow boundary`.
812+
813+
:dp:`fls_PiUS1hF3dv9U`
814+
The :t:`block expression` of a :t:`const block expression` shall be a
815+
:t:`constant expression`.
816+
817+
:dp:`fls_wuwb0SnpP6Zu`
818+
The :t:`type` of a :t:`const block expression` is the :t:`type` of the
819+
containing :t:`block expression`.
820+
821+
:dp:`fls_2i7TD7VoQk4B`
822+
The :t:`value` of a :t:`const block expression` is the :t:`value` of the
823+
contained :t:`block expression`.
824+
825+
.. rubric:: Examples
826+
827+
.. code-block:: rust
828+
829+
const {
830+
42
831+
}
832+
787833
.. _fls_0ybsR1hEo7wV:
788834

789835
Named Blocks

0 commit comments

Comments
 (0)