@@ -31,23 +31,27 @@ You may also be interested in the [grammar].
31
31
32
32
## Unicode productions
33
33
34
- A few productions in Rust's grammar permit Unicode code points outside the ASCII
35
- range. We define these productions in terms of character properties specified
36
- in the Unicode standard, rather than in terms of ASCII-range code points. The
37
- section [ Special Unicode Productions] ( #special-unicode-productions ) lists these
38
- productions.
34
+ A few productions in Rust's grammar permit Unicode code points outside the
35
+ ASCII range. We define these productions in terms of character properties
36
+ specified in the Unicode standard, rather than in terms of ASCII-range code
37
+ points. The grammar has a [ Special Unicode Productions] [ unicodeproductions ]
38
+ section that lists these productions.
39
+
40
+ [ unicodeproductions ] : grammar.html#special-unicode-productions
39
41
40
42
## String table productions
41
43
42
44
Some rules in the grammar &mdash ; notably [ unary
43
45
operators] ( #unary-operator-expressions ) , [ binary
44
- operators] ( #binary-operator-expressions ) , and [ keywords] ( # keywords) &mdash ; are
46
+ operators] ( #binary-operator-expressions ) , and [ keywords] [ keywords ] &mdash ; are
45
47
given in a simplified form: as a listing of a table of unquoted, printable
46
48
whitespace-separated strings. These cases form a subset of the rules regarding
47
49
the [ token] ( #tokens ) rule, and are assumed to be the result of a
48
50
lexical-analysis phase feeding the parser, driven by a DFA, operating over the
49
51
disjunction of all such string table entries.
50
52
53
+ [ keywords ] : grammar.html#keywords
54
+
51
55
When such a string enclosed in double-quotes (` " ` ) occurs inside the grammar,
52
56
it is an implicit reference to a single member of such a string table
53
57
production. See [ tokens] ( #tokens ) for more information.
@@ -75,7 +79,7 @@ An identifier is any nonempty Unicode[^non_ascii_idents] string of the following
75
79
- The first character has property ` XID_start `
76
80
- The remaining characters have property ` XID_continue `
77
81
78
- that does _ not_ occur in the set of [ keywords] ( # keywords) .
82
+ that does _ not_ occur in the set of [ keywords] [ keywords ] .
79
83
80
84
> ** Note** : ` XID_start ` and ` XID_continue ` as character properties cover the
81
85
> character ranges used to form the more familiar C and Java language-family
@@ -401,7 +405,7 @@ Symbols are a general class of printable [token](#tokens) that play structural
401
405
roles in a variety of grammar productions. They are catalogued here for
402
406
completeness as the set of remaining miscellaneous printable tokens that do not
403
407
otherwise appear as [ unary operators] ( #unary-operator-expressions ) , [ binary
404
- operators] ( #binary-operator-expressions ) , or [ keywords] ( # keywords) .
408
+ operators] ( #binary-operator-expressions ) , or [ keywords] [ keywords ] .
405
409
406
410
407
411
## Paths
@@ -611,7 +615,7 @@ module needs its own source file: [module definitions](#modules) can be nested
611
615
within one file.
612
616
613
617
Each source file contains a sequence of zero or more ` item ` definitions, and
614
- may optionally begin with any number of [ attributes] (#Items and attributes)
618
+ may optionally begin with any number of [ attributes] ( #items- and- attributes )
615
619
that apply to the containing module, most of which influence the behavior of
616
620
the compiler. The anonymous crate module can have additional attributes that
617
621
apply to the crate as a whole.
@@ -653,7 +657,7 @@ There are several kinds of item:
653
657
* [ ` use ` declarations] ( #use-declarations )
654
658
* [ modules] ( #modules )
655
659
* [ functions] ( #functions )
656
- * [ type definitions] ( #type-definitions )
660
+ * [ type definitions] ( grammar.html #type-definitions)
657
661
* [ structures] ( #structures )
658
662
* [ enumerations] ( #enumerations )
659
663
* [ static items] ( #static-items )
@@ -772,7 +776,7 @@ extern crate std as ruststd; // linking to 'std' under another name
772
776
A _ use declaration_ creates one or more local name bindings synonymous with
773
777
some other [ path] ( #paths ) . Usually a ` use ` declaration is used to shorten the
774
778
path required to refer to a module item. These declarations may appear at the
775
- top of [ modules] ( #modules ) and [ blocks] ( #blocks ) .
779
+ top of [ modules] ( #modules ) and [ blocks] ( grammar.html#block-expressions ) .
776
780
777
781
> ** Note** : Unlike in many languages,
778
782
> ` use ` declarations in Rust do * not* declare linkage dependency with external crates.
@@ -1143,9 +1147,7 @@ let px: i32 = match p { Point(x, _) => x };
1143
1147
```
1144
1148
1145
1149
A _ unit-like struct_ is a structure without any fields, defined by leaving off
1146
- the list of fields entirely. Such types will have a single value, just like
1147
- the [ unit value ` () ` ] ( #unit-and-boolean-literals ) of the unit type. For
1148
- example:
1150
+ the list of fields entirely. Such types will have a single value. For example:
1149
1151
1150
1152
```
1151
1153
struct Cookie;
@@ -2435,11 +2437,6 @@ comma:
2435
2437
(0); // zero in parentheses
2436
2438
```
2437
2439
2438
- ### Unit expressions
2439
-
2440
- The expression ` () ` denotes the _ unit value_ , the only value of the type with
2441
- the same name.
2442
-
2443
2440
### Structure expressions
2444
2441
2445
2442
There are several forms of structure expressions. A _ structure expression_
@@ -3259,7 +3256,7 @@ constructor or `struct` field may refer, directly or indirectly, to the
3259
3256
enclosing ` enum ` or ` struct ` type itself. Such recursion has restrictions:
3260
3257
3261
3258
* Recursive types must include a nominal type in the recursion
3262
- (not mere [ type definitions] ( #type-definitions ) ,
3259
+ (not mere [ type definitions] ( grammar.html #type-definitions) ,
3263
3260
or other structural types such as [ arrays] ( #array,-and-slice-types ) or [ tuples] ( #tuple-types ) ).
3264
3261
* A recursive ` enum ` item must have at least one non-recursive constructor
3265
3262
(in order to give the recursion a basis case).
0 commit comments