Skip to content

Commit 4dfd3d4

Browse files
committed
---
yaml --- r: 7527 b: refs/heads/master c: 8743908 h: refs/heads/master i: 7525: e29e1ce 7523: 3732d60 7519: 686bcea v: v3
1 parent 25addcc commit 4dfd3d4

File tree

3 files changed

+82
-59
lines changed

3 files changed

+82
-59
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 6d4884d983fbf931740be064dfe5b9b01e6118c3
2+
refs/heads/master: 874390831a61d0708f227bfc5a78fd167ea6d9c1

trunk/doc/rust.md

Lines changed: 55 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ The following productions in the Rust grammar are defined in terms of
132132
Unicode properties: `ident`, `non_null`, `non_star`, `non_eol`, `non_slash`,
133133
`non_single_quote` and `non_double_quote`.
134134

135-
### Identifier
135+
### Identifiers
136136

137137
The `ident` production is any nonempty Unicode string of the following form:
138138

@@ -254,8 +254,8 @@ are excluded from the `ident` rule.
254254
A literal is an expression consisting of a single token, rather than a
255255
sequence of tokens, that immediately and directly denotes the value it
256256
evaluates to, rather than referring to it by name or some other evaluation
257-
rule. A literal is a form of [constant expression](#constant-expression), so
258-
is evaluated (primarily) at compile time.
257+
rule. A literal is a form of constant expression, so is evaluated (primarily)
258+
at compile time.
259259

260260
~~~~~~~~ {.ebnf .gram}
261261
literal : string_lit | char_lit | num_lit ;
@@ -439,14 +439,13 @@ type_path_tail : '<' type_expr [ ',' type_expr ] + '>'
439439
~~~~~~~~
440440

441441
A _path_ is a sequence of one or more path components _logically_ separated by
442-
a namespace qualifier (`::`). If a path consists of only one component, it
443-
may refer to either an [item](#items) or a [variable](#variables) in a local
442+
a namespace qualifier (`::`). If a path consists of only one component, it may
443+
refer to either an [item](#items) or a [slot](#slot-declarations) in a local
444444
control scope. If a path has multiple components, it refers to an item.
445445

446-
Every item has a _canonical path_ within its [crate](#crates), but the path
447-
naming an item is only meaningful within a given crate. There is no global
448-
namespace across crates; an item's canonical path merely identifies it within
449-
the crate.
446+
Every item has a _canonical path_ within its crate, but the path naming an
447+
item is only meaningful within a given crate. There is no global namespace
448+
across crates; an item's canonical path merely identifies it within the crate.
450449

451450
Two examples of simple paths consisting of only identifier components:
452451

@@ -457,11 +456,10 @@ x::y::z;
457456

458457
Path components are usually [identifiers](#identifiers), but the trailing
459458
component of a path may be an angle-bracket-enclosed list of type
460-
arguments. In [expression](#expressions) context, the type
461-
argument list is given after a final (`::`) namespace qualifier in order to
462-
disambiguate it from a relational expression involving the less-than symbol
463-
(`<`). In [type expression](#type-expressions) context, the final namespace
464-
qualifier is omitted.
459+
arguments. In [expression](#expressions) context, the type argument list is
460+
given after a final (`::`) namespace qualifier in order to disambiguate it
461+
from a relational expression involving the less-than symbol (`<`). In type
462+
expression context, the final namespace qualifier is omitted.
465463

466464
Two examples of paths with type arguments:
467465

@@ -569,7 +567,7 @@ implicitly by combining the module name with the file extension `.rs`. The
569567
module contained in that source file is bound to the module path formed by
570568
the `dir_directive` modules containing the `source_directive`.
571569

572-
## Source file
570+
## Source files
573571

574572
A source file contains a `module`: that is, a sequence of zero or more
575573
`item` definitions. Each source file is an implicit module, the name and
@@ -590,12 +588,11 @@ item : mod_item | fn_item | type_item | enum_item
590588
| res_item | iface_item | impl_item ;
591589
~~~~~~~~
592590

593-
An _item_ is a component of a crate; some module items can be defined in
594-
[crate files](#crate-files), but most are defined in [source
595-
files](#source-files). Items are organized within a crate by a nested set of
596-
[modules](#modules). Every crate has a single "outermost" anonymous module;
597-
all further items within the crate have [paths](#paths) within the module tree
598-
of the crate.
591+
An _item_ is a component of a crate; some module items can be defined in crate
592+
files, but most are defined in source files. Items are organized within a
593+
crate by a nested set of [modules](#modules). Every crate has a single
594+
"outermost" anonymous module; all further items within the crate have
595+
[paths](#paths) within the module tree of the crate.
599596

600597
Items are entirely determined at compile-time, remain constant during
601598
execution, and may reside in read-only memory.
@@ -821,9 +818,10 @@ mod foo {
821818
A _function item_ defines a sequence of [statements](#statements) and an
822819
optional final [expression](#expressions) associated with a name and a set of
823820
parameters. Functions are declared with the keyword `fn`. Functions declare a
824-
set of *input [slots](#slots)* as parameters, through which the caller passes
825-
arguments into the function, and an *output [slot](#slots)* through which the
826-
function passes results back to the caller.
821+
set of *input [slots](#slot-declarations)* as parameters, through which the
822+
caller passes arguments into the function, and an *output
823+
[slot](#slot-declarations)* through which the function passes results back to
824+
the caller.
827825

828826
A function may also be copied into a first class *value*, in which case the
829827
value has the corresponding [*function type*](#function-types), and can be
@@ -1020,9 +1018,10 @@ accessed through the components `x` and `y`, and laid out in memory with the
10201018

10211019
### Enumerations
10221020

1023-
An _enumeration item_ simultaneously declares a new nominal [enumerated
1024-
type](#enumerated-type) as well as a set of *constructors* that can be used to
1025-
create or pattern-match values of the corresponding enumerated type.
1021+
An _enumeration item_ simultaneously declares a new nominal
1022+
[enumerated type](#enumerated-types) as well as a set of *constructors* that
1023+
can be used to create or pattern-match values of the corresponding enumerated
1024+
type.
10261025

10271026
The constructors of an `enum` type may be recursive: that is, each constructor
10281027
may take an argument that refers, directly or indirectly, to the enumerated
@@ -1282,13 +1281,14 @@ sequence expression evaluation.
12821281
## Statements
12831282

12841283
A _statement_ is a component of a block, which is in turn a component of an
1285-
outer [block-expression](#block-expressions) or [function](#functions). When a
1286-
function is spawned into a [task](#tasks), the task *executes* statements in
1287-
an order determined by the body of the enclosing function. Each statement
1288-
causes the task to perform certain actions.
1284+
outer [expression](#expressions) or [function](#functions). When a function is
1285+
spawned into a [task](#tasks), the task *executes* statements in an order
1286+
determined by the body of the enclosing function. Each statement causes the
1287+
task to perform certain actions.
12891288

1290-
Rust has two kinds of statement: [declarations](#declarations) and
1291-
[expressions](#expressions).
1289+
Rust has two kinds of statement:
1290+
[declaration statements](#declaration-statements) and
1291+
[expression statements](#expression-statements).
12921292

12931293
A declaration serves to introduce a *name* that can be used in the block
12941294
*scope* enclosing the statement: all statements before and after the
@@ -1310,9 +1310,8 @@ arbitrary depth.
13101310

13111311
### Declaration statements
13121312

1313-
A _declaration statement_ is one that introduces a *name* into the
1314-
enclosing statement block. The declared name may denote a new slot or a new
1315-
item.
1313+
A _declaration statement_ is one that introduces a *name* into the enclosing
1314+
statement block. The declared name may denote a new slot or a new item.
13161315

13171316
#### Item declarations
13181317

@@ -1352,7 +1351,7 @@ scope.
13521351
The former form, with no type annotation, causes the compiler to infer the
13531352
static type of the slot through unification with the types of values assigned
13541353
to the slot in the remaining code in the block scope. Inference only occurs on
1355-
frame-local slots, not argument slots. Function signatures must
1354+
frame-local variable, not argument slots. Function signatures must
13561355
always declare types for all argument slots.
13571356

13581357

@@ -1722,11 +1721,11 @@ Evaluating a copy expression first evaluates the argument expression, then
17221721
copies the resulting value, allocating any memory necessary to hold the new
17231722
copy.
17241723

1725-
[Shared boxes](#shared-box-types) (type `@`) are, as usual, shallow-copied, as
1726-
they may be cyclic. [Unique boxes](#unique-box-types),
1727-
[vectors](#vector-types) and similar unique types are deep-copied.
1724+
[Shared boxes](#box-types) (type `@`) are, as usual, shallow-copied, as they
1725+
may be cyclic. [Unique boxes](#box-types), [vectors](#vector-types) and
1726+
similar unique types are deep-copied.
17281727

1729-
Since the binary [assignment operator](#assignment-operator) `=` performs a
1728+
Since the binary [assignment operator](#assignment-expressions) `=` performs a
17301729
copy implicitly, the unary copy operator is typically only used to cause an
17311730
argument to a function to be copied and passed by value.
17321731

@@ -1826,7 +1825,7 @@ bound slot in the bound function's signature, space is allocated in the hidden
18261825
tuple and populated with a copy of the bound value.
18271826

18281827
A `bind` expression is an alternative way of constructing a shared function
1829-
closure; the [`fn@` expression](#shared-function-expression) form is another
1828+
closure; the [`fn@` expression](#shared-function-expressions) form is another
18301829
way.
18311830

18321831
### Shared function expressions
@@ -1966,8 +1965,8 @@ patterns must equal the type of the head expression.
19661965
To execute an `alt` expression, first the head expression is evaluated, then
19671966
its value is sequentially compared to the patterns in the arms until a match
19681967
is found. The first arm with a matching pattern is chosen as the branch target
1969-
of the `alt`, any variables bound by the pattern are assigned to local slots
1970-
in the arm's block, and control enters the block.
1968+
of the `alt`, any variables bound by the pattern are assigned to local
1969+
variables in the arm's block, and control enters the block.
19711970

19721971
An example of an `alt` expression:
19731972

@@ -2378,11 +2377,11 @@ Future versions of Rust will address these issues.
23782377

23792378
# Types and typestates
23802379

2381-
## Type system
2380+
## Types
23822381

23832382
Every slot and value in a Rust program has a type. The _type_ of a *value*
23842383
defines the interpretation of the memory holding it. The type of a *slot* may
2385-
also include [constraints](#constrained-types).
2384+
also include [constraints](#constraints).
23862385

23872386
Built-in types and type-constructors are tightly integrated into the language,
23882387
in nontrivial ways that are not possible to emulate in user-defined
@@ -2457,7 +2456,6 @@ A value of type `str` is a Unicode string, represented as a vector of 8-bit
24572456
unsigned bytes holding a sequence of UTF-8 codepoints.
24582457

24592458

2460-
24612459
### Record types
24622460

24632461
The record type-constructor forms a new heterogeneous product of values.^[The
@@ -2568,8 +2566,8 @@ Unsafe pointers (`*`)
25682566
### Function types
25692567

25702568
The function type-constructor `fn` forms new function types. A function type
2571-
consists of a sequence of input slots, an optional set of [input
2572-
constraints](#input-constraints) and an output slot.
2569+
consists of a sequence of input slots, an optional set of
2570+
[input constraints](#constraints) and an output slot.
25732571

25742572
An example of a `fn` type:
25752573

@@ -2916,23 +2914,23 @@ references to any boxes; the remainder of its heap is immediately freed.
29162914

29172915
A task's stack contains slots.
29182916

2919-
A _slot_ is a component of a stack frame. A slot is either *local* or
2920-
a *reference*.
2917+
A _slot_ is a component of a stack frame. A slot is either a *local variable*
2918+
or a *reference*.
29212919

2922-
A _local_ slot (or *stack-local* allocation) holds a value directly,
2920+
A _local variable_ (or *stack-local* allocation) holds a value directly,
29232921
allocated within the stack's memory. The value is a part of the stack frame.
29242922

29252923
A _reference_ references a value outside the frame. It may refer to a
29262924
value allocated in another frame *or* a boxed value in the heap. The
29272925
reference-formation rules ensure that the referent will outlive the reference.
29282926

2929-
Local slots are always implicitly mutable.
2927+
Local variables are always implicitly mutable.
29302928

2931-
Local slots are not initialized when allocated; the entire frame worth of
2932-
local slots are allocated at once, on frame-entry, in an uninitialized
2929+
Local variables are not initialized when allocated; the entire frame worth of
2930+
local variables are allocated at once, on frame-entry, in an uninitialized
29332931
state. Subsequent statements within a function may or may not initialize the
2934-
local slots. Local slots can be used only after they have been initialized;
2935-
this condition is guaranteed by the typestate system.
2932+
local variables. Local variables can be used only after they have been
2933+
initialized; this condition is guaranteed by the typestate system.
29362934

29372935
References are created for function arguments. If the compiler can not prove
29382936
that the referred-to value will outlive the reference, it will try to set
@@ -3198,7 +3196,6 @@ Receiving a value is done by a call to the `recv` method on a value of type
31983196
`core::comm::port`. This call causes the receiving task to enter the *blocked
31993197
reading* state until a value arrives in the port's receive queue, at which
32003198
time the port deques a value to return, and un-blocks the receiving task.
3201-
See [communication system](#communication-system).
32023199

32033200
An example of a *receive*:
32043201

trunk/src/etc/check-links.pl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/perl -w
2+
3+
my $file = $ARGV[0];
4+
5+
my @lines = <>;
6+
7+
my $anchors = {};
8+
9+
my $i = 0;
10+
foreach $line (@lines) {
11+
$i++;
12+
if ($line =~ m/id="([^"]+)"/) {
13+
$anchors->{$1} = $i;
14+
}
15+
}
16+
17+
$i = 0;
18+
foreach $line (@lines) {
19+
$i++;
20+
while ($line =~ m/href="#([^"]+)"/g) {
21+
if (! exists($anchors->{$1})) {
22+
print "$file:$i: $1 referenced\n";
23+
}
24+
}
25+
}
26+

0 commit comments

Comments
 (0)