Skip to content

Commit f772079

Browse files
committed
Rollup merge of #24727 - rkruppe:reference-audit, r=steveklabnik
It was in pretty good shape, but since that is my pet peeve, I clarified the compiler/interpreter distinction and why it is irrelevant for this section. Otherwise only a couple of minor clarifications, and weasel words where reality is more complicated than the text accounted for (e.g., there is more than one kind of library). r? @steveklabnik
2 parents 316091a + e9f2980 commit f772079

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

src/doc/reference.md

+25-10
Original file line numberDiff line numberDiff line change
@@ -735,15 +735,26 @@ 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
738+
Although Rust, like any other language, can be implemented by an interpreter as
739+
well as a compiler, the only existing implementation is a compiler —
740+
from now on referred to as *the* Rust compiler — and the language has
741+
always been designed to be compiled. For these reasons, this section assumes a
742+
compiler.
743+
744+
Rust's semantics obey a *phase distinction* between compile-time and
745+
run-time.[^phase-distinction] Those semantic rules that have a *static
740746
interpretation* govern the success or failure of compilation. Those semantics
741747
that have a *dynamic interpretation* govern the behavior of the program at
742748
run-time.
743749

750+
[^phase-distinction]: This distinction would also exist in an interpreter.
751+
Static checks like syntactic analysis, type checking, and lints should
752+
happen before the program is executed regardless of when it is executed.
753+
744754
The compilation model centers on artifacts called _crates_. Each compilation
745755
processes a single crate in source form, and if successful, produces a single
746-
crate in binary form: either an executable or a library.[^cratesourcefile]
756+
crate in binary form: either an executable or some sort of
757+
library.[^cratesourcefile]
747758

748759
[^cratesourcefile]: A crate is somewhat analogous to an *assembly* in the
749760
ECMA-335 CLI model, a *library* in the SML/NJ Compilation Manager, a *unit*
@@ -764,21 +775,25 @@ extension `.rs`.
764775
A Rust source file describes a module, the name and location of which —
765776
in the module tree of the current crate — are defined from outside the
766777
source file: either by an explicit `mod_item` in a referencing source file, or
767-
by the name of the crate itself.
778+
by the name of the crate itself. Every source file is a module, but not every
779+
module needs its own source file: [module definitions](#modules) can be nested
780+
within one file.
768781

769782
Each source file contains a sequence of zero or more `item` definitions, and
770-
may optionally begin with any number of `attributes` that apply to the
771-
containing module. Attributes on the anonymous crate module define important
772-
metadata that influences the behavior of the compiler.
783+
may optionally begin with any number of [attributes](#Items and attributes)
784+
that apply to the containing module, most of which influence the behavior of
785+
the compiler. The anonymous crate module can have additional attributes that
786+
apply to the crate as a whole.
773787

774788
```no_run
775-
// Crate name
789+
// Specify the crate name.
776790
#![crate_name = "projx"]
777791
778-
// Specify the output type
792+
// Specify the type of output artifact.
779793
#![crate_type = "lib"]
780794
781-
// Turn on a warning
795+
// Turn on a warning.
796+
// This can be done in any module, not just the anonymous crate module.
782797
#![warn(non_camel_case_types)]
783798
```
784799

0 commit comments

Comments
 (0)