@@ -564,7 +564,7 @@ type_path_tail : '<' type_expr [ ',' type_expr ] + '>'
564564
565565A _ path_ is a sequence of one or more path components _ logically_ separated by
566566a namespace qualifier (` :: ` ). If a path consists of only one component, it may
567- refer to either an [ item] ( #items ) or a [ slot ] ( #memory-slots ) in a local control
567+ refer to either an [ item] ( #items ) or a [ variable ] ( #variables ) in a local control
568568scope. If a path has multiple components, it refers to an item.
569569
570570Every item has a _ canonical path_ within its crate, but the path naming an item
@@ -735,13 +735,11 @@ Rust syntax is restricted in two ways:
735735
736736# Crates and source files
737737
738- Rust is a * compiled* language. Its semantics obey a * phase distinction*
739- between compile-time and run-time. Those semantic rules that have a * static
740- interpretation* govern the success or failure of compilation. We refer to
741- these rules as "static semantics". Semantic rules called "dynamic semantics"
742- govern the behavior of programs at run-time. A program that fails to compile
743- due to violation of a compile-time rule has no defined dynamic semantics; the
744- compiler should halt with an error report, and produce no executable artifact.
738+ Rust is a * compiled* language. Its semantics obey a * phase distinction* between
739+ compile-time and run-time. Those semantic rules that have a * static
740+ interpretation* govern the success or failure of compilation. Those semantics
741+ that have a * dynamic interpretation* govern the behavior of the program at
742+ run-time.
745743
746744The compilation model centers on artifacts called _ crates_ . Each compilation
747745processes a single crate in source form, and if successful, produces a single
@@ -1064,9 +1062,9 @@ fn main() {}
10641062A _ function item_ defines a sequence of [ statements] ( #statements ) and an
10651063optional final [ expression] ( #expressions ) , along with a name and a set of
10661064parameters. Functions are declared with the keyword ` fn ` . Functions declare a
1067- set of * input* [ * slots * ] ( #memory-slots ) as parameters, through which the caller
1068- passes arguments into the function, and an * output* [ * slot * ] ( #memory-slots )
1069- through which the function passes results back to the caller.
1065+ set of * input* [ * variables * ] ( #variables ) as parameters, through which the caller
1066+ passes arguments into the function, and the * output* [ * type * ] ( #types )
1067+ of the value the function will return to its caller on completion .
10701068
10711069A function may also be copied into a first-class * value* , in which case the
10721070value has the corresponding [ * function type* ] ( #function-types ) , and can be used
@@ -1229,7 +1227,7 @@ be undesired.
12291227#### Diverging functions
12301228
12311229A special kind of function can be declared with a ` ! ` character where the
1232- output slot type would normally be. For example:
1230+ output type would normally be. For example:
12331231
12341232```
12351233fn my_err(s: &str) -> ! {
@@ -1302,18 +1300,11 @@ contiguous stack segments like C.
13021300
13031301A _ type alias_ defines a new name for an existing [ type] ( #types ) . Type
13041302aliases are declared with the keyword ` type ` . Every value has a single,
1305- specific type; the type-specified aspects of a value include:
1303+ specific type, but may implement several different traits, or be compatible with
1304+ several different type constraints.
13061305
1307- * Whether the value is composed of sub-values or is indivisible.
1308- * Whether the value represents textual or numerical information.
1309- * Whether the value represents integral or floating-point information.
1310- * The sequence of memory operations required to access the value.
1311- * The [ kind] ( #type-kinds ) of the type.
1312-
1313- For example, the type ` (u8, u8) ` defines the set of immutable values that are
1314- composite pairs, each containing two unsigned 8-bit integers accessed by
1315- pattern-matching and laid out in memory with the ` x ` component preceding the
1316- ` y ` component:
1306+ For example, the following defines the type ` Point ` as a synonym for the type
1307+ ` (u8, u8) ` , the type of pairs of unsigned 8 bit integers.:
13171308
13181309```
13191310type Point = (u8, u8);
@@ -2551,7 +2542,7 @@ statements](#expression-statements).
25512542### Declaration statements
25522543
25532544A _ declaration statement_ is one that introduces one or more * names* into the
2554- enclosing statement block. The declared names may denote new slots or new
2545+ enclosing statement block. The declared names may denote new variables or new
25552546items.
25562547
25572548#### Item declarations
@@ -2566,18 +2557,18 @@ in meaning to declaring the item outside the statement block.
25662557> ** Note** : there is no implicit capture of the function's dynamic environment when
25672558> declaring a function-local item.
25682559
2569- #### Slot declarations
2560+ #### Variable declarations
25702561
25712562``` {.ebnf .gram}
25722563let_decl : "let" pat [':' type ] ? [ init ] ? ';' ;
25732564init : [ '=' ] expr ;
25742565```
25752566
2576- A _ slot declaration_ introduces a new set of slots , given by a pattern. The
2567+ A _ variable declaration_ introduces a new set of variable , given by a pattern. The
25772568pattern may be followed by a type annotation, and/or an initializer expression.
25782569When no type annotation is given, the compiler will infer the type, or signal
25792570an error if insufficient type information is available for definite inference.
2580- Any slots introduced by a slot declaration are visible from the point of
2571+ Any variables introduced by a variable declaration are visible from the point of
25812572declaration until the end of the enclosing block scope.
25822573
25832574### Expression statements
@@ -2632,7 +2623,7 @@ of any reference that points to it.
26322623
26332624#### Moved and copied types
26342625
2635- When a [ local variable] ( #memory-slots ) is used as an
2626+ When a [ local variable] ( #variables ) is used as an
26362627[ rvalue] ( #lvalues,-rvalues-and-temporaries ) the variable will either be moved
26372628or copied, depending on its type. All values whose type implements ` Copy ` are
26382629copied, all others are moved.
@@ -3042,10 +3033,9 @@ paren_expr_list : '(' expr_list ')' ;
30423033call_expr : expr paren_expr_list ;
30433034```
30443035
3045- A _ call expression_ invokes a function, providing zero or more input slots and
3046- an optional reference slot to serve as the function's output, bound to the
3047- ` lval ` on the right hand side of the call. If the function eventually returns,
3048- then the expression completes.
3036+ A _ call expression_ invokes a function, providing zero or more input variables
3037+ and an optional location to move the function's output into. If the function
3038+ eventually returns, then the expression completes.
30493039
30503040Some examples of call expressions:
30513041
@@ -3456,9 +3446,9 @@ return_expr : "return" expr ? ;
34563446```
34573447
34583448Return expressions are denoted with the keyword ` return ` . Evaluating a ` return `
3459- expression moves its argument into the output slot of the current function,
3460- destroys the current function activation frame, and transfers control to the
3461- caller frame.
3449+ expression moves its argument into the designated output location for the
3450+ current function call, destroys the current function activation frame, and
3451+ transfers control to the caller frame.
34623452
34633453An example of a ` return ` expression:
34643454
@@ -3475,7 +3465,7 @@ fn max(a: i32, b: i32) -> i32 {
34753465
34763466## Types
34773467
3478- Every slot , item and value in a Rust program has a type. The _ type_ of a
3468+ Every variable , item and value in a Rust program has a type. The _ type_ of a
34793469* value* defines the interpretation of the memory holding it.
34803470
34813471Built-in types and type-constructors are tightly integrated into the language,
@@ -3493,7 +3483,7 @@ The primitive types are the following:
34933483* The machine-dependent integer and floating-point types.
34943484
34953485[ ^ unittype ] : The "unit" value ` () ` is * not* a sentinel "null pointer" value for
3496- reference slots ; the "unit" type is the implicit return type from functions
3486+ reference variables ; the "unit" type is the implicit return type from functions
34973487 otherwise lacking a return type, and can be used in other contexts (such as
34983488 message-sending or type-parametric code) as a zero-size type.]
34993489
@@ -3831,29 +3821,33 @@ impl Printable for String {
38313821` self ` refers to the value of type ` String ` that is the receiver for a call to
38323822the method ` make_string ` .
38333823
3834- # The ` Copy ` trait
3824+ # Special traits
3825+
3826+ Several traits define special evaluation behavior.
38353827
3836- Rust has a special trait, ` Copy ` , which when implemented changes the semantics
3837- of a value. Values whose type implements ` Copy ` are copied rather than moved
3838- upon assignment.
3828+ ## The ` Copy ` trait
38393829
3840- # The ` Sized ` trait
3830+ The ` Copy ` trait changes the semantics of a type implementing it. Values whose
3831+ type implements ` Copy ` are copied rather than moved upon assignment.
38413832
3842- ` Sized ` is a special trait which indicates that the size of this type is known
3843- at compile-time.
3833+ ## The ` Sized ` trait
38443834
3845- # The ` Drop ` trait
3835+ The ` Sized ` trait indicates that the size of this type is known at compile-time.
3836+
3837+ ## The ` Drop ` trait
38463838
38473839The ` Drop ` trait provides a destructor, to be run whenever a value of this type
38483840is to be destroyed.
38493841
38503842# Memory model
38513843
38523844A Rust program's memory consists of a static set of * items* and a * heap* .
3853- Immutable portions of the heap may be shared between threads, mutable portions
3854- may not.
3845+ Immutable portions of the heap may be safely shared between threads, mutable
3846+ portions may not be safely shared, but several mechanisms for effectively-safe
3847+ sharing of mutable values, built on unsafe code but enforcing a safe locking
3848+ discipline, exist in the standard library.
38553849
3856- Allocations in the stack consist of * slots * , and allocations in the heap
3850+ Allocations in the stack consist of * variables * , and allocations in the heap
38573851consist of * boxes* .
38583852
38593853### Memory allocation and lifetime
@@ -3872,10 +3866,11 @@ in the heap, heap allocations may outlive the frame they are allocated within.
38723866When a stack frame is exited, its local allocations are all released, and its
38733867references to boxes are dropped.
38743868
3875- ### Memory slots
3869+ ### Variables
38763870
3877- A _ slot_ is a component of a stack frame, either a function parameter, a
3878- [ temporary] ( #lvalues,-rvalues-and-temporaries ) , or a local variable.
3871+ A _ variable_ is a component of a stack frame, either a named function parameter,
3872+ an anonymous [ temporary] ( #lvalues,-rvalues-and-temporaries ) , or a named local
3873+ variable.
38793874
38803875A _ local variable_ (or * stack-local* allocation) holds a value directly,
38813876allocated within the stack's memory. The value is a part of the stack frame.
@@ -3888,7 +3883,7 @@ Box<i32>, y: Box<i32>)` declare one mutable variable `x` and one immutable
38883883variable ` y ` ).
38893884
38903885Methods that take either ` self ` or ` Box<Self> ` can optionally place them in a
3891- mutable slot by prefixing them with ` mut ` (similar to regular arguments):
3886+ mutable variable by prefixing them with ` mut ` (similar to regular arguments):
38923887
38933888```
38943889trait Changer {
@@ -3903,44 +3898,7 @@ state. Subsequent statements within a function may or may not initialize the
39033898local variables. Local variables can be used only after they have been
39043899initialized; this is enforced by the compiler.
39053900
3906- # Runtime services, linkage and debugging
3907-
3908- The Rust _ runtime_ is a relatively compact collection of Rust code that
3909- provides fundamental services and datatypes to all Rust threads at run-time. It
3910- is smaller and simpler than many modern language runtimes. It is tightly
3911- integrated into the language's execution model of memory, threads, communication
3912- and logging.
3913-
3914- ### Memory allocation
3915-
3916- The runtime memory-management system is based on a _ service-provider
3917- interface_ , through which the runtime requests blocks of memory from its
3918- environment and releases them back to its environment when they are no longer
3919- needed. The default implementation of the service-provider interface consists
3920- of the C runtime functions ` malloc ` and ` free ` .
3921-
3922- The runtime memory-management system, in turn, supplies Rust threads with
3923- facilities for allocating releasing stacks, as well as allocating and freeing
3924- heap data.
3925-
3926- ### Built in types
3927-
3928- The runtime provides C and Rust code to assist with various built-in types,
3929- such as arrays, strings, and the low level communication system (ports,
3930- channels, threads).
3931-
3932- Support for other built-in types such as simple types, tuples and enums is
3933- open-coded by the Rust compiler.
3934-
3935- ### Thread scheduling and communication
3936-
3937- The runtime provides code to manage inter-thread communication. This includes
3938- the system of thread-lifecycle state transitions depending on the contents of
3939- queues, as well as code to copy values between queues and their recipients and
3940- to serialize values for transmission over operating-system inter-process
3941- communication facilities.
3942-
3943- ### Linkage
3901+ # Linkage
39443902
39453903The Rust compiler supports various methods to link crates together both
39463904statically and dynamically. This section will explore the various methods to
0 commit comments