@@ -13,24 +13,16 @@ semantic rules
13
13
that have a * dynamic interpretation* govern the behavior of the program at
14
14
run-time.
15
15
16
- [ ^ phase-distinction ] : This distinction would also exist in an interpreter.
17
- Static checks like syntactic analysis, type checking, and lints should
18
- happen before the program is executed regardless of when it is executed.
19
-
20
16
The compilation model centers on artifacts called _ crates_ . Each compilation
21
17
processes a single crate in source form, and if successful, produces a single
22
18
crate in binary form: either an executable or some sort of
23
19
library.[ ^ cratesourcefile ]
24
20
25
- [ ^ cratesourcefile ] : A crate is somewhat analogous to an * assembly* in the
26
- ECMA-335 CLI model, a * library* in the SML/NJ Compilation Manager, a * unit*
27
- in the Owens and Flatt module system, or a * configuration* in Mesa.
28
-
29
21
A _ crate_ is a unit of compilation and linking, as well as versioning,
30
22
distribution and runtime loading. A crate contains a _ tree_ of nested
31
- [ module] ( #modules ) scopes. The top level of this tree is a module that is
23
+ [ module] scopes. The top level of this tree is a module that is
32
24
anonymous (from the point of view of paths within the module) and any item
33
- within a crate has a canonical [ module path] ( #paths ) denoting its location
25
+ within a crate has a canonical [ module path] denoting its location
34
26
within the crate's module tree.
35
27
36
28
The Rust compiler is always invoked with a single source file as input, and
@@ -42,16 +34,16 @@ A Rust source file describes a module, the name and location of which —
42
34
in the module tree of the current crate &mdash ; are defined from outside the
43
35
source file: either by an explicit ` mod_item ` in a referencing source file, or
44
36
by the name of the crate itself. Every source file is a module, but not every
45
- module needs its own source file: [ module definitions] ( #modules ) can be nested
37
+ module needs its own source file: [ module definitions] [ module ] can be nested
46
38
within one file.
47
39
48
40
Each source file contains a sequence of zero or more ` item ` definitions, and
49
- may optionally begin with any number of [ attributes] ( #items-and-attributes )
41
+ may optionally begin with any number of [ attributes]
50
42
that apply to the containing module, most of which influence the behavior of
51
43
the compiler. The anonymous crate module can have additional attributes that
52
44
apply to the crate as a whole.
53
45
54
- ``` no_run
46
+ ``` rust, no_run
55
47
// Specify the crate name.
56
48
#![crate_name = "projx"]
57
49
@@ -65,4 +57,17 @@ apply to the crate as a whole.
65
57
66
58
A crate that contains a ` main ` function can be compiled to an executable. If a
67
59
` main ` function is present, its return type must be ` () `
68
- ("[ unit] ( #tuple-types ) ") and it must take no arguments.
60
+ ("[ unit] ") and it must take no arguments.
61
+
62
+ [ ^ phase-distinction ] : This distinction would also exist in an interpreter.
63
+ Static checks like syntactic analysis, type checking, and lints should
64
+ happen before the program is executed regardless of when it is executed.
65
+
66
+ [ ^ cratesourcefile ] : A crate is somewhat analogous to an * assembly* in the
67
+ ECMA-335 CLI model, a * library* in the SML/NJ Compilation Manager, a * unit*
68
+ in the Owens and Flatt module system, or a * configuration* in Mesa.
69
+
70
+ [ module ] : items.html#modules
71
+ [ module path ] : paths.html
72
+ [ attributes ] : items-and-attributes.html
73
+ [ unit ] : types.html#tuple-types
0 commit comments