@@ -2870,16 +2870,12 @@ references to any boxes; the remainder of its heap is immediately freed.
2870
2870
2871
2871
A task's stack contains slots.
2872
2872
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 .
2875
2875
2876
2876
A _ local variable_ (or * stack-local* allocation) holds a value directly,
2877
2877
allocated within the stack's memory. The value is a part of the stack frame.
2878
2878
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
-
2883
2879
Local variables are immutable unless declared with ` let mut ` . The
2884
2880
` mut ` keyword applies to all local variables declared within that
2885
2881
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
2891
2887
local variables. Local variables can be used only after they have been
2892
2888
initialized; this is enforced by the compiler.
2893
2889
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
- ~~~~~~~~
2908
2890
2909
2891
### Memory boxes
2910
2892
0 commit comments