Skip to content

Commit 809a554

Browse files
committed
Auto merge of #23593 - Manishearth:rollup, r=Manishearth
(yay, no Saturday)
2 parents b0aad7d + b4e9106 commit 809a554

File tree

19 files changed

+347
-205
lines changed

19 files changed

+347
-205
lines changed

man/rustc.1

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ full debug info with variable and type information.
242242
\fBopt\-level\fR=\fIVAL\fR
243243
Optimize with possible levels 0\[en]3
244244

245-
.SH ENVIRONMENT VARIABLES
245+
.SH ENVIRONMENT
246246

247247
Some of these affect the output of the compiler, while others affect programs
248248
which link to the standard library.

src/doc/reference.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1982,7 +1982,7 @@ the namespace hierarchy as it normally would.
19821982
## Attributes
19831983

19841984
```{.ebnf .gram}
1985-
attribute : "#!" ? '[' meta_item ']' ;
1985+
attribute : '#' '!' ? '[' meta_item ']' ;
19861986
meta_item : ident [ '=' literal
19871987
| '(' meta_seq ')' ] ? ;
19881988
meta_seq : meta_item [ ',' meta_seq ] ? ;
@@ -3158,7 +3158,7 @@ ten_times(|j| println!("hello, {}", j));
31583158
### While loops
31593159

31603160
```{.ebnf .gram}
3161-
while_expr : "while" no_struct_literal_expr '{' block '}' ;
3161+
while_expr : [ lifetime ':' ] "while" no_struct_literal_expr '{' block '}' ;
31623162
```
31633163

31643164
A `while` loop begins by evaluating the boolean loop conditional expression.
@@ -3223,7 +3223,7 @@ A `continue` expression is only permitted in the body of a loop.
32233223
### For expressions
32243224

32253225
```{.ebnf .gram}
3226-
for_expr : "for" pat "in" no_struct_literal_expr '{' block '}' ;
3226+
for_expr : [ lifetime ':' ] "for" pat "in" no_struct_literal_expr '{' block '}' ;
32273227
```
32283228

32293229
A `for` expression is a syntactic construct for looping over elements provided

src/doc/trpl/SUMMARY.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Summary
22

3-
* [I: The Basics](basic.md)
3+
* [The Basics](basic.md)
44
* [Installing Rust](installing-rust.md)
55
* [Hello, world!](hello-world.md)
66
* [Hello, Cargo!](hello-cargo.md)
@@ -14,7 +14,7 @@
1414
* [Strings](strings.md)
1515
* [Arrays, Vectors, and Slices](arrays-vectors-and-slices.md)
1616
* [Standard Input](standard-input.md)
17-
* [II: Intermediate Rust](intermediate.md)
17+
* [Intermediate Rust](intermediate.md)
1818
* [Crates and Modules](crates-and-modules.md)
1919
* [Testing](testing.md)
2020
* [Pointers](pointers.md)
@@ -31,7 +31,7 @@
3131
* [Concurrency](concurrency.md)
3232
* [Error Handling](error-handling.md)
3333
* [Documentation](documentation.md)
34-
* [III: Advanced Topics](advanced.md)
34+
* [Advanced Topics](advanced.md)
3535
* [FFI](ffi.md)
3636
* [Unsafe Code](unsafe.md)
3737
* [Advanced Macros](advanced-macros.md)

src/libcollections/btree/map.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use core::default::Default;
2424
use core::fmt::Debug;
2525
use core::hash::{Hash, Hasher};
2626
use core::iter::{Map, FromIterator, IntoIterator};
27-
use core::ops::{Index, IndexMut};
27+
use core::ops::{Index};
2828
use core::{iter, fmt, mem, usize};
2929
use Bound::{self, Included, Excluded, Unbounded};
3030

@@ -925,15 +925,6 @@ impl<K: Ord, Q: ?Sized, V> Index<Q> for BTreeMap<K, V>
925925
}
926926
}
927927

928-
#[stable(feature = "rust1", since = "1.0.0")]
929-
impl<K: Ord, Q: ?Sized, V> IndexMut<Q> for BTreeMap<K, V>
930-
where K: Borrow<Q>, Q: Ord
931-
{
932-
fn index_mut(&mut self, key: &Q) -> &mut V {
933-
self.get_mut(key).expect("no entry found for key")
934-
}
935-
}
936-
937928
/// Genericises over how to get the correct type of iterator from the correct type
938929
/// of Node ownership.
939930
trait Traverse<N> {

src/librustc/README.md

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
An informal guide to reading and working on the rustc compiler.
2+
==================================================================
3+
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+
* http://internals.rust-lang.org/
8+
* https://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust
9+
10+
or file a bug:
11+
12+
https://github.com/rust-lang/rust/issues
13+
14+
Your concerns are probably the same as someone else's.
15+
16+
The crates of rustc
17+
===================
18+
19+
Rustc consists of a number of crates, including `libsyntax`,
20+
`librustc`, `librustc_back`, `librustc_trans`, and `librustc_driver`
21+
(the names and divisions are not set in stone and may change;
22+
in general, a finer-grained division of crates is preferable):
23+
24+
- `libsyntax` contains those things concerned purely with syntax –
25+
that is, the AST, parser, pretty-printer, lexer, macro expander, and
26+
utilities for traversing ASTs – are in a separate crate called
27+
"syntax", whose files are in `./../libsyntax`, where `.` is the
28+
current directory (that is, the parent directory of front/, middle/,
29+
back/, and so on).
30+
31+
- `librustc` (the current directory) contains the high-level analysis
32+
passes, such as the type checker, borrow checker, and so forth.
33+
It is the heart of the compiler.
34+
35+
- `librustc_back` contains some very low-level details that are
36+
specific to different LLVM targets and so forth.
37+
38+
- `librustc_trans` contains the code to convert from Rust IR into LLVM
39+
IR, and then from LLVM IR into machine code, as well as the main
40+
driver that orchestrates all the other passes and various other bits
41+
of miscellany. In general it contains code that runs towards the
42+
end of the compilation process.
43+
44+
- `librustc_driver` invokes the compiler from `libsyntax`, then the
45+
analysis phases from `librustc`, and finally the lowering and
46+
codegen passes from `librustc_trans`.
47+
48+
Roughly speaking the "order" of the three crates is as follows:
49+
50+
libsyntax -> librustc -> librustc_trans
51+
| |
52+
+-----------------+-------------------+
53+
|
54+
librustc_driver
55+
56+
57+
Modules in the rustc crate
58+
==========================
59+
60+
The rustc crate itself consists of the following submodules
61+
(mostly, but not entirely, in their own directories):
62+
63+
- session: options and data that pertain to the compilation session as
64+
a whole
65+
- middle: middle-end: name resolution, typechecking, LLVM code
66+
generation
67+
- metadata: encoder and decoder for data required by separate
68+
compilation
69+
- plugin: infrastructure for compiler plugins
70+
- lint: infrastructure for compiler warnings
71+
- util: ubiquitous types and helper functions
72+
- lib: bindings to LLVM
73+
74+
The entry-point for the compiler is main() in the librustc_trans
75+
crate.
76+
77+
The 3 central data structures:
78+
------------------------------
79+
80+
1. `./../libsyntax/ast.rs` defines the AST. The AST is treated as
81+
immutable after parsing, but it depends on mutable context data
82+
structures (mainly hash maps) to give it meaning.
83+
84+
- Many – though not all – nodes within this data structure are
85+
wrapped in the type `spanned<T>`, meaning that the front-end has
86+
marked the input coordinates of that node. The member `node` is
87+
the data itself, the member `span` is the input location (file,
88+
line, column; both low and high).
89+
90+
- Many other nodes within this data structure carry a
91+
`def_id`. These nodes represent the 'target' of some name
92+
reference elsewhere in the tree. When the AST is resolved, by
93+
`middle/resolve.rs`, all names wind up acquiring a def that they
94+
point to. So anything that can be pointed-to by a name winds
95+
up with a `def_id`.
96+
97+
2. `middle/ty.rs` defines the datatype `sty`. This is the type that
98+
represents types after they have been resolved and normalized by
99+
the middle-end. The typeck phase converts every ast type to a
100+
`ty::sty`, and the latter is used to drive later phases of
101+
compilation. Most variants in the `ast::ty` tag have a
102+
corresponding variant in the `ty::sty` tag.
103+
104+
3. `./../librustc_llvm/lib.rs` defines the exported types
105+
`ValueRef`, `TypeRef`, `BasicBlockRef`, and several others.
106+
Each of these is an opaque pointer to an LLVM type,
107+
manipulated through the `lib::llvm` interface.
108+
109+
110+
Control and information flow within the compiler:
111+
-------------------------------------------------
112+
113+
- main() in lib.rs assumes control on startup. Options are
114+
parsed, platform is detected, etc.
115+
116+
- `./../libsyntax/parse/parser.rs` parses the input files and produces
117+
an AST that represents the input crate.
118+
119+
- Multiple middle-end passes (`middle/resolve.rs`, `middle/typeck.rs`)
120+
analyze the semantics of the resulting AST. Each pass generates new
121+
information about the AST and stores it in various environment data
122+
structures. The driver passes environments to each compiler pass
123+
that needs to refer to them.
124+
125+
- Finally, the `trans` module in `librustc_trans` translates the Rust
126+
AST to LLVM bitcode in a type-directed way. When it's finished
127+
synthesizing LLVM values, rustc asks LLVM to write them out in some
128+
form (`.bc`, `.o`) and possibly run the system linker.

src/librustc/README.txt

-124
This file was deleted.

src/librustc_resolve/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
900900
return;
901901
}
902902
if self.glob_map.contains_key(&import_id) {
903-
self.glob_map[import_id].insert(name);
903+
self.glob_map.get_mut(&import_id).unwrap().insert(name);
904904
return;
905905
}
906906

src/librustc_resolve/resolve_imports.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
603603

604604
// We've successfully resolved the import. Write the results in.
605605
let mut import_resolutions = module_.import_resolutions.borrow_mut();
606-
let import_resolution = &mut (*import_resolutions)[target];
606+
let import_resolution = import_resolutions.get_mut(&target).unwrap();
607607

608608
{
609609
let mut check_and_write_import = |namespace, result: &_, used_public: &mut bool| {

src/librustc_trans/README.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
See the README.txt in ../librustc.
1+
See the README.md in ../librustc.

0 commit comments

Comments
 (0)