Skip to content

Commit a4f0021

Browse files
committed
Update and copyedit README for rustc
Lindsey pointed out that the location of librustsyntax was out-of-date, so I fixed that; noticed a lot of other out-of-date info; and updated it. I also obliterated all passive voice. Yay! Closes #2382
1 parent 0343b05 commit a4f0021

File tree

1 file changed

+35
-20
lines changed

1 file changed

+35
-20
lines changed

src/rustc/README.txt

+35-20
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,38 @@
11
An informal guide to reading and working on the rustc compiler.
22
==================================================================
33

4-
If you wish to expand on this document, or have one of the
5-
slightly-more-familiar authors add anything else to it, please get in
6-
touch or file a bug. Your concerns are probably the same as someone
7-
else's.
4+
If you wish to expand on this document, or have a more experienced
5+
Rust contributor add anything else to it, please get in touch:
6+
7+
https://github.com/mozilla/rust/wiki/Note-development-policy
8+
("Communication" subheading)
9+
10+
or file a bug:
11+
12+
https://github.com/mozilla/rust/issues
13+
14+
Your concerns are probably the same as someone else's.
815

916

1017
High-level concepts
1118
===================
1219

1320
Rustc consists of the following subdirectories:
1421

15-
syntax/ - pure syntax concerns: lexer, parser, AST.
1622
front/ - front-end: attributes, conditional compilation
17-
middle/ - middle-end: resolving, typechecking, translating
23+
middle/ - middle-end: resolving, typechecking, generating LLVM code
1824
back/ - back-end: linking and ABI
25+
metadata/ - serializer and deserializer for data required by
26+
separate compilation
1927
driver/ - command-line processing, main() entrypoint
2028
util/ - ubiquitous types and helper functions
2129
lib/ - bindings to LLVM
22-
pretty/ - pretty-printing
30+
31+
The files concerned purely with syntax -- that is, the AST, parser,
32+
pretty-printer, lexer, macro expander, and utilities for traversing
33+
ASTs -- are in a separate crate called "rustsyntax", whose files are
34+
in ./../librustsyntax if the parent directory of front/, middle/,
35+
back/, and so on is . .
2336

2437
The entry-point for the compiler is main() in driver/rustc.rs, and
2538
this file sequences the various parts together.
@@ -28,10 +41,9 @@ this file sequences the various parts together.
2841
The 3 central data structures:
2942
------------------------------
3043

31-
#1: syntax/ast.rs defines the AST. The AST is treated as immutable
32-
after parsing despite containing some mutable types (hashtables
33-
and such). There are three interesting details to know about this
34-
structure:
44+
#1: ../librustsyntax/ast.rs defines the AST. The AST is treated as immutable
45+
after parsing, but it depends on mutable context data structures
46+
(mainly hash maps) to give it meaning.
3547

3648
- Many -- though not all -- nodes within this data structure are
3749
wrapped in the type spanned<T>, meaning that the front-end has
@@ -55,7 +67,7 @@ The 3 central data structures:
5567

5668
#3: lib/llvm.rs defines the exported types ValueRef, TypeRef,
5769
BasicBlockRef, and several others. Each of these is an opaque
58-
pointer to an LLVM type, manipulated through the lib.llvm
70+
pointer to an LLVM type, manipulated through the lib::llvm
5971
interface.
6072

6173

@@ -65,13 +77,16 @@ Control and information flow within the compiler:
6577
- main() in driver/rustc.rs assumes control on startup. Options are
6678
parsed, platform is detected, etc.
6779

68-
- front/parser.rs is driven over the input files.
80+
- librustsyntax/parse/parser.rs parses the input files and produces an
81+
AST that represents the input crate.
6982

70-
- Multiple middle-end passes (middle/resolve.rs, middle/typeck.rs) are
71-
run over the resulting AST. Each pass generates new information
72-
about the AST which is stored in various side data structures.
83+
- Multiple middle-end passes (middle/resolve.rs, middle/typeck.rs)
84+
analyze the semantics of the resulting AST. Each pass generates new
85+
information about the AST and stores it in various environment data
86+
structures. The driver is in charge of passing the correct
87+
environments to each compiler pass that needs to refer to them.
7388

74-
- Finally middle/trans.rs is applied to the AST, which performs a
75-
type-directed translation to LLVM-ese. When it's finished
76-
synthesizing LLVM values, rustc asks LLVM to write them out in some
77-
form (.bc, .o) and possibly run the system linker.
89+
- Finally middle/trans.rs translates the Rust AST to LLVM bitcode in a
90+
type-directed way. When it's finished synthesizing LLVM values,
91+
rustc asks LLVM to write them out in some form (.bc, .o) and
92+
possibly run the system linker.

0 commit comments

Comments
 (0)