Skip to content

Commit 0322912

Browse files
FuGangqiangManishearth
authored andcommitted
---
yaml --- r: 194036 b: refs/heads/beta c: 5836efd h: refs/heads/master v: v3
1 parent bac606e commit 0322912

File tree

20 files changed

+204
-346
lines changed

20 files changed

+204
-346
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3131
refs/heads/issue-18208-method-dispatch-3-quick-reject: 2009f85b9f99dedcec4404418eda9ddba90258a2
3232
refs/heads/batch: b7fd822592a4fb577552d93010c4a4e14f314346
3333
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
34-
refs/heads/beta: 5b9e87b5711361cb01bf3e066bc53c765f6dc5b9
34+
refs/heads/beta: 5836efdfe7077e10fe7ba69f0cb01d1ca93fa47b
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
3737
refs/heads/tmp: de8a23bbc3a7b9cbd7574b5b91a34af59bf030e6

branches/beta/man/rustc.1

Lines changed: 1 addition & 1 deletion
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
245+
.SH ENVIRONMENT VARIABLES
246246

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

branches/beta/src/doc/reference.md

Lines changed: 1 addition & 1 deletion
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 ] ? ;

branches/beta/src/doc/trpl/SUMMARY.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Summary
22

3-
* [The Basics](basic.md)
3+
* [I: 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-
* [Intermediate Rust](intermediate.md)
17+
* [II: 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-
* [Advanced Topics](advanced.md)
34+
* [III: Advanced Topics](advanced.md)
3535
* [FFI](ffi.md)
3636
* [Unsafe Code](unsafe.md)
3737
* [Advanced Macros](advanced-macros.md)

branches/beta/src/libcollections/btree/map.rs

Lines changed: 10 additions & 1 deletion
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};
27+
use core::ops::{Index, IndexMut};
2828
use core::{iter, fmt, mem, usize};
2929
use Bound::{self, Included, Excluded, Unbounded};
3030

@@ -925,6 +925,15 @@ 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+
928937
/// Genericises over how to get the correct type of iterator from the correct type
929938
/// of Node ownership.
930939
trait Traverse<N> {

branches/beta/src/librustc/README.md

Lines changed: 0 additions & 128 deletions
This file was deleted.

branches/beta/src/librustc/README.txt

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
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 four crates altogether: `libsyntax`, `librustc`,
20+
`librustc_back`, and `librustc_trans` (the names and divisions are not
21+
set in stone and may change; in general, a finer-grained division of
22+
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 current
28+
directory (that is, the parent directory of front/, middle/, back/,
29+
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+
Roughly speaking the "order" of the three crates is as follows:
45+
46+
libsyntax -> librustc -> librustc_trans
47+
| |
48+
+-----------------+-------------------+
49+
|
50+
librustc_trans/driver
51+
52+
Here the role of `librustc_trans/driver` is to invoke the compiler
53+
from libsyntax, then the analysis phases from librustc, and finally
54+
the lowering and codegen passes from librustc_trans.
55+
56+
Modules in the rustc crate
57+
==========================
58+
59+
The rustc crate itself consists of the following subdirectories
60+
(mostly, but not entirely, in their own directories):
61+
62+
session - options and data that pertain to the compilation session as a whole
63+
middle - middle-end: name resolution, typechecking, LLVM code
64+
generation
65+
metadata - encoder and decoder for data required by
66+
separate compilation
67+
util - ubiquitous types and helper functions
68+
lib - bindings to LLVM
69+
70+
The entry-point for the compiler is main() in the librustc_trans
71+
crate.
72+
73+
The 3 central data structures:
74+
------------------------------
75+
76+
#1: ./../libsyntax/ast.rs defines the AST. The AST is treated as immutable
77+
after parsing, but it depends on mutable context data structures
78+
(mainly hash maps) to give it meaning.
79+
80+
- Many -- though not all -- nodes within this data structure are
81+
wrapped in the type `spanned<T>`, meaning that the front-end has
82+
marked the input coordinates of that node. The member .node is
83+
the data itself, the member .span is the input location (file,
84+
line, column; both low and high).
85+
86+
- Many other nodes within this data structure carry a
87+
def_id. These nodes represent the 'target' of some name
88+
reference elsewhere in the tree. When the AST is resolved, by
89+
middle/resolve.rs, all names wind up acquiring a def that they
90+
point to. So anything that can be pointed-to by a name winds
91+
up with a def_id.
92+
93+
#2: middle/ty.rs defines the datatype sty. This is the type that
94+
represents types after they have been resolved and normalized by
95+
the middle-end. The typeck phase converts every ast type to a
96+
ty::sty, and the latter is used to drive later phases of
97+
compilation. Most variants in the ast::ty tag have a
98+
corresponding variant in the ty::sty tag.
99+
100+
#3: lib/llvm.rs (in librustc_trans) defines the exported types
101+
ValueRef, TypeRef, BasicBlockRef, and several others. Each of
102+
these is an opaque pointer to an LLVM type, manipulated through
103+
the lib::llvm interface.
104+
105+
106+
Control and information flow within the compiler:
107+
-------------------------------------------------
108+
109+
- main() in lib.rs assumes control on startup. Options are
110+
parsed, platform is detected, etc.
111+
112+
- ./../libsyntax/parse/parser.rs parses the input files and produces an AST
113+
that represents the input crate.
114+
115+
- Multiple middle-end passes (middle/resolve.rs, middle/typeck.rs)
116+
analyze the semantics of the resulting AST. Each pass generates new
117+
information about the AST and stores it in various environment data
118+
structures. The driver passes environments to each compiler pass
119+
that needs to refer to them.
120+
121+
- Finally, the `trans` module in `librustc_trans` translates the Rust
122+
AST to LLVM bitcode in a type-directed way. When it's finished
123+
synthesizing LLVM values, rustc asks LLVM to write them out in some
124+
form (.bc, .o) and possibly run the system linker.

branches/beta/src/librustc_resolve/lib.rs

Lines changed: 1 addition & 1 deletion
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.get_mut(&import_id).unwrap().insert(name);
903+
self.glob_map[import_id].insert(name);
904904
return;
905905
}
906906

branches/beta/src/librustc_resolve/resolve_imports.rs

Lines changed: 1 addition & 1 deletion
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 = import_resolutions.get_mut(&target).unwrap();
606+
let import_resolution = &mut (*import_resolutions)[target];
607607

608608
{
609609
let mut check_and_write_import = |namespace, result: &_, used_public: &mut bool| {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
See the README.md in ../librustc.
1+
See the README.txt in ../librustc.

0 commit comments

Comments
 (0)