Skip to content

Commit 809c80b

Browse files
committed
Specify #127679
1 parent c94ea31 commit 809c80b

File tree

3 files changed

+80
-2
lines changed

3 files changed

+80
-2
lines changed

src/changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ Language changes in Rust 1.82.0
4848

4949
* `Stabilize \`&raw const\` and \`&raw mut\` operators (RFC 2582) <https://github.com/rust-lang/rust/pull/127679>`_
5050

51+
* New section: :ref:`fls_vXGuvRWOLbEE`
52+
53+
* New paragraphs: :p:`fls_K7SbApHPmwjM`
54+
5155
* `Stabilize unsafe extern blocks (RFC 3484) <https://github.com/rust-lang/rust/pull/127921>`_
5256

5357
* `Stabilize nested field access in \`offset_of!\` <https://github.com/rust-lang/rust/pull/128284>`_

src/expressions.rst

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,9 @@ The following :t:`[construct]s` are :t:`[place expression context]s`:
482482
* :dp:`fls_Ufz9W5vyZkv3`
483483
The :t:`operand` of a :t:`borrow expression`,
484484

485+
* :dp:`fls_K7SbApHPmwjM`
486+
The :t:`operand` of a :t:`raw borrow expression`,
487+
485488
* :dp:`fls_KxWIzoh9WwK7`
486489
The :t:`operand` of a :t:`dereference expression`,
487490

@@ -927,6 +930,7 @@ Operator Expressions
927930
| ErrorPropagationExpression
928931
| LazyBooleanExpression
929932
| NegationExpression
933+
| RawBorrowExpression
930934
| TypeCastExpression
931935
932936
.. rubric:: Legality Rules
@@ -971,11 +975,11 @@ state, or simply :t:`borrowed`.
971975
The :t:`type` of a :t:`borrow expression` is determined as follows:
972976

973977
* :dp:`fls_5b2x5ri2w54r`
974-
If the :t:`borrow expression` denotes a :t:`shared reference`, then the
978+
If the :t:`borrow expression` denotes an :t:`immutable borrow expression`, then the
975979
:t:`type` is ``&T``, where ``T`` is the :t:`type` of the :t:`operand`.
976980

977981
* :dp:`fls_agl09ia869rk`
978-
If the :t:`borrow expression` denotes a :t:`mutable reference`, then the
982+
If the :t:`borrow expression` denotes a :t:`mutable borrow expression`, then the
979983
:t:`type` is ``&mut T``, where ``T`` is the :t:`type` of the :t:`operand`.
980984

981985
:dp:`fls_8cvmee9bzs40`
@@ -2057,6 +2061,65 @@ The :t:`evaluation` of a :t:`lazy or expression` proceeds as follows:
20572061
false && panic!()
20582062
this || that
20592063
2064+
.. _fls_vXGuvRWOLbEE:
2065+
2066+
Raw Borrow Expression
2067+
~~~~~~~~~~~~~~~~~~~~~
2068+
2069+
.. rubric:: Syntax
2070+
2071+
.. syntax::
2072+
2073+
RawBorrowExpression ::=
2074+
$$&$$ $$raw$$ ($$const$$ | $$mut$$) Operand
2075+
2076+
.. rubric:: Legality Rules
2077+
2078+
:dp:`fls_TS6DvMon5h27`
2079+
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`.
2080+
2081+
:dp:`fls_UtjWrE2qeplQ`
2082+
An :dt:`immutable raw borrow expression` is a :t:`raw borrow expression` that has :t:`keyword` ``const``.
2083+
2084+
:dp:`fls_4e7EE4a8Yvmy`
2085+
A :dt:`mutable raw borrow expression` is a :t:`raw borrow expression` that has :t:`keyword` ``mut``.
2086+
2087+
:dp:`fls_gOXUWePymgGV`
2088+
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`.
2089+
2090+
:dp:`fls_YBC8GrIBzZbi`
2091+
It is a static error if the :t:`operand` of a :t:`raw borrow expression` is a :t:`temporary`.
2092+
2093+
:dp:`fls_Twkre8IzUa8S`
2094+
The :t:`type` of a :t:`raw borrow expression` is determined as follows:
2095+
2096+
* :dp:`fls_Ki4FOzJMqtvJ`
2097+
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`.
2098+
2099+
* :dp:`fls_DJxQDBsO9hc7`
2100+
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`.
2101+
2102+
:dp:`fls_WlXB0AHifCdd`
2103+
The :t:`value` of a :t:`raw borrow expression` is the address of its :t:`operand`.
2104+
2105+
.. rubric:: Dynamic Semantics
2106+
2107+
:dp:`fls_qQrV8QuGGcVO`
2108+
The :t:`evaluation` of a :t:`raw borrow expression` evaluates its :t:`operand`.
2109+
2110+
.. rubric:: Examples
2111+
2112+
.. code-block:: rust
2113+
2114+
let mut answer = 42;
2115+
2116+
:dp:`fls_dTABiwAPGhdZ`
2117+
Mutable raw borrow.
2118+
2119+
.. syntax::
2120+
2121+
let ref_answer = &raw mut answer;
2122+
20602123
.. _fls_1qhsun1vyarz:
20612124

20622125
Type Cast Expressions

src/glossary.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5357,6 +5357,17 @@ an included :t:`range expression high bound`.
53575357
:dp:`fls_krei7lc6lo8q`
53585358
See :s:`RangeToInclusiveExpression`.
53595359

5360+
.. _fls_YLhE2qpzYXRK:
5361+
5362+
raw borrow expression
5363+
^^^^^^^^^^^^^^^^^^^^^
5364+
5365+
:dp:`fls_Fe39wLb0vvEg`
5366+
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`.
5367+
5368+
:dp:`fls_I71jq8BGyLqi`
5369+
See :s:`RawBorrowExpression`.
5370+
53605371
.. _fls_ipeh92kh17ze:
53615372

53625373
raw byte string literal

0 commit comments

Comments
 (0)