Skip to content

Commit e7bd83a

Browse files
committed
---
yaml --- r: 209623 b: refs/heads/try c: f14d289 h: refs/heads/master i: 209621: 982c3d0 209619: bb4fa0d 209615: 2b31daf v: v3
1 parent 08a884d commit e7bd83a

File tree

18 files changed

+792
-1216
lines changed

18 files changed

+792
-1216
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3e561f05c00cd180ec02db4ccab2840a4aba93d2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
5-
refs/heads/try: 49a94f29bbe49bd26d14cbf87b0955bd4befb8c1
5+
refs/heads/try: f14d289d71fd8e4956e7214bda3af15cd50898fe
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/mk/main.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ CFG_RELEASE_NUM=1.0.0
1818
# An optional number to put after the label, e.g. '.2' -> '-beta.2'
1919
# NB Make sure it starts with a dot to conform to semver pre-release
2020
# versions (section 9)
21-
CFG_PRERELEASE_VERSION=.3
21+
CFG_PRERELEASE_VERSION=.2
2222

2323
CFG_FILENAME_EXTRA=4e7c5e5c
2424

branches/try/src/doc/complement-lang-faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Yes. Calling C code from Rust is simple and exactly as efficient as calling C co
124124

125125
Yes. The Rust code has to be exposed via an `extern` declaration, which makes it C-ABI compatible. Such a function can be passed to C code as a function pointer or, if given the `#[no_mangle]` attribute to disable symbol mangling, can be called directly from C code.
126126

127-
## Why aren't function signatures inferred? Why only local variables?
127+
## Why aren't function signatures inferred? Why only local slots?
128128

129129
* Mechanically, it simplifies the inference algorithm; inference only requires looking at one function at a time.
130130
* The same simplification goes double for human readers. A reader does not need an IDE running an inference algorithm across an entire crate to be able to guess at a function's argument types; it's always explicit and nearby.

branches/try/src/doc/grammar.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
This document is the primary reference for the Rust programming language grammar. It
66
provides only one kind of material:
77

8-
- Chapters that formally define the language grammar.
8+
- Chapters that formally define the language grammar and, for each
9+
construct.
910

1011
This document does not serve as an introduction to the language. Background
1112
familiarity with the language is assumed. A separate [guide] is available to
@@ -426,7 +427,7 @@ meta_seq : meta_item [ ',' meta_seq ] ? ;
426427
**FIXME:** grammar?
427428

428429
A _declaration statement_ is one that introduces one or more *names* into the
429-
enclosing statement block. The declared names may denote new variables or new
430+
enclosing statement block. The declared names may denote new slots or new
430431
items.
431432

432433
#### Item declarations
@@ -440,7 +441,7 @@ function, enumeration, structure, type, static, trait, implementation or module
440441
scope to a narrow region containing all of its uses; it is otherwise identical
441442
in meaning to declaring the item outside the statement block.
442443

443-
#### Variable declarations
444+
#### Slot declarations
444445

445446
```antlr
446447
let_decl : "let" pat [':' type ] ? [ init ] ? ';' ;
@@ -762,7 +763,7 @@ bound := path | lifetime
762763

763764
### Memory ownership
764765

765-
### Variables
766+
### Memory slots
766767

767768
### Boxes
768769

branches/try/src/doc/reference.md

Lines changed: 90 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ type_path_tail : '<' type_expr [ ',' type_expr ] + '>'
564564

565565
A _path_ is a sequence of one or more path components _logically_ separated by
566566
a namespace qualifier (`::`). If a path consists of only one component, it may
567-
refer to either an [item](#items) or a [variable](#variables) in a local control
567+
refer to either an [item](#items) or a [slot](#memory-slots) in a local control
568568
scope. If a path has multiple components, it refers to an item.
569569

570570
Every item has a _canonical path_ within its crate, but the path naming an item
@@ -735,11 +735,13 @@ 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* 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.
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.
743745

744746
The compilation model centers on artifacts called _crates_. Each compilation
745747
processes a single crate in source form, and if successful, produces a single
@@ -1062,9 +1064,9 @@ fn main() {}
10621064
A _function item_ defines a sequence of [statements](#statements) and an
10631065
optional final [expression](#expressions), along with a name and a set of
10641066
parameters. Functions are declared with the keyword `fn`. Functions declare a
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.
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.
10681070

10691071
A function may also be copied into a first-class *value*, in which case the
10701072
value has the corresponding [*function type*](#function-types), and can be used
@@ -1227,7 +1229,7 @@ be undesired.
12271229
#### Diverging functions
12281230

12291231
A special kind of function can be declared with a `!` character where the
1230-
output type would normally be. For example:
1232+
output slot type would normally be. For example:
12311233

12321234
```
12331235
fn my_err(s: &str) -> ! {
@@ -1300,11 +1302,18 @@ contiguous stack segments like C.
13001302

13011303
A _type alias_ defines a new name for an existing [type](#types). Type
13021304
aliases are declared with the keyword `type`. Every value has a single,
1303-
specific type, but may implement several different traits, or be compatible with
1304-
several different type constraints.
1305+
specific type; the type-specified aspects of a value include:
13051306

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.:
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:
13081317

13091318
```
13101319
type Point = (u8, u8);
@@ -2542,7 +2551,7 @@ statements](#expression-statements).
25422551
### Declaration statements
25432552

25442553
A _declaration statement_ is one that introduces one or more *names* into the
2545-
enclosing statement block. The declared names may denote new variables or new
2554+
enclosing statement block. The declared names may denote new slots or new
25462555
items.
25472556

25482557
#### Item declarations
@@ -2557,18 +2566,18 @@ in meaning to declaring the item outside the statement block.
25572566
> **Note**: there is no implicit capture of the function's dynamic environment when
25582567
> declaring a function-local item.
25592568
2560-
#### Variable declarations
2569+
#### Slot declarations
25612570

25622571
```{.ebnf .gram}
25632572
let_decl : "let" pat [':' type ] ? [ init ] ? ';' ;
25642573
init : [ '=' ] expr ;
25652574
```
25662575

2567-
A _variable declaration_ introduces a new set of variable, given by a pattern. The
2576+
A _slot declaration_ introduces a new set of slots, given by a pattern. The
25682577
pattern may be followed by a type annotation, and/or an initializer expression.
25692578
When no type annotation is given, the compiler will infer the type, or signal
25702579
an error if insufficient type information is available for definite inference.
2571-
Any variables introduced by a variable declaration are visible from the point of
2580+
Any slots introduced by a slot declaration are visible from the point of
25722581
declaration until the end of the enclosing block scope.
25732582

25742583
### Expression statements
@@ -2623,7 +2632,7 @@ of any reference that points to it.
26232632

26242633
#### Moved and copied types
26252634

2626-
When a [local variable](#variables) is used as an
2635+
When a [local variable](#memory-slots) is used as an
26272636
[rvalue](#lvalues,-rvalues-and-temporaries) the variable will either be moved
26282637
or copied, depending on its type. All values whose type implements `Copy` are
26292638
copied, all others are moved.
@@ -3033,9 +3042,10 @@ paren_expr_list : '(' expr_list ')' ;
30333042
call_expr : expr paren_expr_list ;
30343043
```
30353044

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.
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.
30393049

30403050
Some examples of call expressions:
30413051

@@ -3446,9 +3456,9 @@ return_expr : "return" expr ? ;
34463456
```
34473457

34483458
Return expressions are denoted with the keyword `return`. Evaluating a `return`
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.
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.
34523462

34533463
An example of a `return` expression:
34543464

@@ -3465,7 +3475,7 @@ fn max(a: i32, b: i32) -> i32 {
34653475

34663476
## Types
34673477

3468-
Every variable, item and value in a Rust program has a type. The _type_ of a
3478+
Every slot, item and value in a Rust program has a type. The _type_ of a
34693479
*value* defines the interpretation of the memory holding it.
34703480

34713481
Built-in types and type-constructors are tightly integrated into the language,
@@ -3483,7 +3493,7 @@ The primitive types are the following:
34833493
* The machine-dependent integer and floating-point types.
34843494

34853495
[^unittype]: The "unit" value `()` is *not* a sentinel "null pointer" value for
3486-
reference variables; the "unit" type is the implicit return type from functions
3496+
reference slots; the "unit" type is the implicit return type from functions
34873497
otherwise lacking a return type, and can be used in other contexts (such as
34883498
message-sending or type-parametric code) as a zero-size type.]
34893499

@@ -3821,33 +3831,29 @@ impl Printable for String {
38213831
`self` refers to the value of type `String` that is the receiver for a call to
38223832
the method `make_string`.
38233833

3824-
# Special traits
3825-
3826-
Several traits define special evaluation behavior.
3834+
# The `Copy` trait
38273835

3828-
## The `Copy` trait
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.
38293839

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.
3840+
# The `Sized` trait
38323841

3833-
## The `Sized` trait
3842+
`Sized` is a special trait which indicates that the size of this type is known
3843+
at compile-time.
38343844

3835-
The `Sized` trait indicates that the size of this type is known at compile-time.
3836-
3837-
## The `Drop` trait
3845+
# The `Drop` trait
38383846

38393847
The `Drop` trait provides a destructor, to be run whenever a value of this type
38403848
is to be destroyed.
38413849

38423850
# Memory model
38433851

38443852
A Rust program's memory consists of a static set of *items* and a *heap*.
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.
3853+
Immutable portions of the heap may be shared between threads, mutable portions
3854+
may not.
38493855

3850-
Allocations in the stack consist of *variables*, and allocations in the heap
3856+
Allocations in the stack consist of *slots*, and allocations in the heap
38513857
consist of *boxes*.
38523858

38533859
### Memory allocation and lifetime
@@ -3866,11 +3872,10 @@ in the heap, heap allocations may outlive the frame they are allocated within.
38663872
When a stack frame is exited, its local allocations are all released, and its
38673873
references to boxes are dropped.
38683874

3869-
### Variables
3875+
### Memory slots
38703876

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.
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.
38743879

38753880
A _local variable_ (or *stack-local* allocation) holds a value directly,
38763881
allocated within the stack's memory. The value is a part of the stack frame.
@@ -3883,7 +3888,7 @@ Box<i32>, y: Box<i32>)` declare one mutable variable `x` and one immutable
38833888
variable `y`).
38843889

38853890
Methods that take either `self` or `Box<Self>` can optionally place them in a
3886-
mutable variable by prefixing them with `mut` (similar to regular arguments):
3891+
mutable slot by prefixing them with `mut` (similar to regular arguments):
38873892

38883893
```
38893894
trait Changer {
@@ -3898,7 +3903,44 @@ state. Subsequent statements within a function may or may not initialize the
38983903
local variables. Local variables can be used only after they have been
38993904
initialized; this is enforced by the compiler.
39003905

3901-
# Linkage
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
39023944

39033945
The Rust compiler supports various methods to link crates together both
39043946
statically and dynamically. This section will explore the various methods to
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
% Lifetimes
22

3-
Coming Soon! Until then, check out the [ownership](ownership.html) chapter.
3+
Coming soon!

0 commit comments

Comments
 (0)