Skip to content

Commit d917770

Browse files
committed
auto merge of #16381 : pnkfelix/rust/fsk-rust.md-fixes, r=alexcrichton
rust.md: Explicitly point out how special `'static` is. Drive-by: fix description of `&content` to point out that `&'f type` is (as of today) only for type expressions.
2 parents 9d55421 + 97e82cc commit d917770

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/doc/rust.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,9 @@ A *static item* is a named _constant value_ stored in the global data section of
13561356
Immutable static items are stored in the read-only data section.
13571357
The constant value bound to a static item is, like all constant values, evaluated at compile time.
13581358
Static items have the `static` lifetime, which outlives all other lifetimes in a Rust program.
1359+
Only values stored in the global data section (such as string constants
1360+
and static items) can have the `static` lifetime;
1361+
dynamically constructed values cannot safely be assigned the `static` lifetime.
13591362
Static items are declared with the `static` keyword.
13601363
A static item must have a _constant expression_ giving its definition.
13611364

@@ -3621,7 +3624,10 @@ There are four varieties of pointer in Rust:
36213624
References arise by (automatic) conversion from owning pointers, managed pointers,
36223625
or by applying the borrowing operator `&` to some other value,
36233626
including [lvalues, rvalues or temporaries](#lvalues,-rvalues-and-temporaries).
3624-
References are written `&content`, or in some cases `&'f content` for some lifetime-variable `f`,
3627+
A borrow expression is written `&content`.
3628+
3629+
A reference type is written `&'f type` for some lifetime-variable `f`,
3630+
or just `&type` when the lifetime can be elided;
36253631
for example `&int` means a reference to an integer.
36263632
Copying a reference is a "shallow" operation:
36273633
it involves only copying the pointer itself.

0 commit comments

Comments
 (0)