Skip to content

Commit d471e24

Browse files
committed
manual: remove description of references (modes) from memory-slots section.
1 parent 7090953 commit d471e24

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

doc/rust.md

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2870,16 +2870,12 @@ references to any boxes; the remainder of its heap is immediately freed.
28702870

28712871
A task's stack contains slots.
28722872

2873-
A _slot_ is a component of a stack frame. A slot is either a *local variable*
2874-
or a *reference*.
2873+
A _slot_ is a component of a stack frame, either a function parameter,
2874+
a [temporary](#lvalues-rvalues-and-temporaries), or a local variable.
28752875

28762876
A _local variable_ (or *stack-local* allocation) holds a value directly,
28772877
allocated within the stack's memory. The value is a part of the stack frame.
28782878

2879-
A _reference_ references a value outside the frame. It may refer to a
2880-
value allocated in another frame *or* a boxed value in the heap. The
2881-
reference-formation rules ensure that the referent will outlive the reference.
2882-
28832879
Local variables are immutable unless declared with `let mut`. The
28842880
`mut` keyword applies to all local variables declared within that
28852881
declaration (so `let mut x, y` declares two mutable variables, `x` and
@@ -2891,20 +2887,6 @@ state. Subsequent statements within a function may or may not initialize the
28912887
local variables. Local variables can be used only after they have been
28922888
initialized; this is enforced by the compiler.
28932889

2894-
References are created for function arguments. If the compiler can not prove
2895-
that the referred-to value will outlive the reference, it will try to set
2896-
aside a copy of that value to refer to. If this is not semantically safe (for
2897-
example, if the referred-to value contains mutable fields), it will reject the
2898-
program. If the compiler deems copying the value expensive, it will warn.
2899-
2900-
A function with an argument of type `&mut T`, for some type `T`, can write to
2901-
the slot that its argument refers to. An example of such a function is:
2902-
2903-
~~~~~~~~
2904-
fn incr(i: &mut int) {
2905-
*i = *i + 1;
2906-
}
2907-
~~~~~~~~
29082890

29092891
### Memory boxes
29102892

0 commit comments

Comments
 (0)