Skip to content
This repository was archived by the owner on Jan 24, 2021. It is now read-only.

Background #15

Merged
merged 53 commits into from
Jul 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
d97d111
Fix a few typos in type inference chapter
jonas-schievink Jun 12, 2019
885ab7e
Changes to config.toml require a clean
fintelia Jun 8, 2019
8dfb8c1
add note about rebuilding llvm
mark-i-m Jun 15, 2019
ea6f6b5
Notes about closure de-sugaring
blitzerr Nov 2, 2018
9a4ff92
Some edits to address review comments
mark-i-m Mar 23, 2019
c15c609
fix ci failures, typos, broken links
mark-i-m Jun 15, 2019
f675e36
Update for TyCtxt<'a, 'gcx, 'tcx> -> TyCtxt<'tcx>.
eddyb Jun 14, 2019
f55e97c
fix typos
mark-i-m Jun 15, 2019
76a7f10
Added Rustc Debugger Support Chapter
amanjeev May 5, 2019
43ac567
fix compiler-team
b41sh Jun 24, 2019
6f50f15
Change stage0 cfg_attr to bootstrap
flip1995 Jun 24, 2019
9f3678d
Update mdbook
mark-i-m Jun 19, 2019
d16c326
Update to mdbook-linkcheck 0.3.0
mark-i-m Jun 21, 2019
bb872a6
add bibligraphy appendix
mark-i-m Jun 25, 2019
979387d
fix broken links
mark-i-m Jun 26, 2019
85c0616
avoid ftp links
mark-i-m Jun 26, 2019
40e8461
fix typo
nikomatsakis Jun 18, 2019
83ab6e4
break out parts of the region inference chapter into sub-chapters
nikomatsakis Jun 18, 2019
4615a9a
start filling out the constraint propagation chapter in more detail
nikomatsakis Jun 18, 2019
472f4e8
describe region inference and member constraints in some detail
nikomatsakis Jun 20, 2019
bd347df
adjust overview slightly
nikomatsakis Jun 20, 2019
5c92fc2
Update src/borrow_check/region_inference/constraint_propagation.md
nikomatsakis Jun 24, 2019
989c943
Update src/borrow_check/region_inference/lifetime_parameters.md
nikomatsakis Jun 24, 2019
13691d6
Update src/borrow_check/region_inference/lifetime_parameters.md
nikomatsakis Jun 24, 2019
3435363
Update src/borrow_check/region_inference/lifetime_parameters.md
nikomatsakis Jun 24, 2019
53f83a9
Update src/borrow_check/region_inference/constraint_propagation.md
nikomatsakis Jun 24, 2019
6e64bab
Update src/borrow_check/region_inference/constraint_propagation.md
nikomatsakis Jun 24, 2019
8858bdf
Update src/borrow_check/region_inference/constraint_propagation.md
nikomatsakis Jun 24, 2019
d4f8036
Update src/borrow_check/region_inference/constraint_propagation.md
nikomatsakis Jun 24, 2019
a90e341
Update src/borrow_check/region_inference/constraint_propagation.md
nikomatsakis Jun 24, 2019
f540a0b
Update src/borrow_check/region_inference/constraint_propagation.md
nikomatsakis Jun 24, 2019
ae217e5
Update src/borrow_check/region_inference/constraint_propagation.md
nikomatsakis Jun 24, 2019
b71caff
Update src/borrow_check/region_inference/member_constraints.md
nikomatsakis Jun 24, 2019
32b5763
Update src/borrow_check/region_inference/lifetime_parameters.md
nikomatsakis Jun 24, 2019
8c78b7d
Update src/borrow_check/region_inference/member_constraints.md
nikomatsakis Jun 24, 2019
16e4900
Update src/borrow_check/region_inference/member_constraints.md
nikomatsakis Jun 24, 2019
1a66e0c
Update src/borrow_check/region_inference/constraint_propagation.md
nikomatsakis Jun 24, 2019
47dc406
Update src/borrow_check/region_inference/member_constraints.md
nikomatsakis Jun 24, 2019
986780b
Update src/borrow_check/region_inference/constraint_propagation.md
nikomatsakis Jun 24, 2019
0c6f789
Update src/borrow_check/region_inference/member_constraints.md
nikomatsakis Jun 24, 2019
edeb237
Update src/borrow_check/region_inference/placeholders_and_universes.md
nikomatsakis Jun 24, 2019
5bfca5a
Update src/borrow_check/region_inference/placeholders_and_universes.md
nikomatsakis Jun 24, 2019
364f0e4
Update src/borrow_check/region_inference/placeholders_and_universes.md
nikomatsakis Jun 24, 2019
a8de9a1
fix indentation
nikomatsakis Jun 24, 2019
ed95356
add `point` to the glossary and link a use of it
nikomatsakis Jun 24, 2019
abf512f
fix long line
mark-i-m Jun 26, 2019
87e3552
fix links
mark-i-m Jun 26, 2019
c6d9943
fix mdbook test
mark-i-m Jun 26, 2019
7f47c49
Fix typo
JohnTitor Jun 26, 2019
92f3f8e
Update pass modes for ui tests (#380)
JohnTitor Jul 4, 2019
b5a2b93
Fix broken links (#382)
JohnTitor Jul 4, 2019
fbe8f83
Merge remote-tracking branch 'rust-lang/master'
OlingCat Jul 7, 2019
29515fa
Background translated.
OlingCat Jul 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ci/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ function cargo_install() {
fi
}

cargo_install mdbook 0.2.3
cargo_install mdbook-linkcheck 0.2.3
cargo_install mdbook 0.3.0
cargo_install mdbook-linkcheck 0.3.0
95 changes: 95 additions & 0 deletions src-zh/appendix/background.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,51 @@
<!--
# Appendix B: Background topics
-->

# 附录 B:背景话题

<!--
This section covers a numbers of common compiler terms that arise in
this guide. We try to give the general definition while providing some
Rust-specific context.
-->

本节涵盖了本指南中出现的常见编译器术语。我们会在某些特定于 Rust
的上下文中给出这些术语的一般定义。

<a name="cfg"></a>

<!--
## What is a control-flow graph?
-->

## 什么是控制流图?

<!--
A control-flow graph is a common term from compilers. If you've ever
used a flow-chart, then the concept of a control-flow graph will be
pretty familiar to you. It's a representation of your program that
exposes the underlying control flow in a very clear way.
-->

控制流图(control-flow graph)是编译器中常见的术语。如果你曾使用过流程图,
那么控制流图的概念对你来说会很熟悉。它是程序的一种表示方式,
能够以非常清晰的方式展现底层控制流。

<!--
A control-flow graph is structured as a set of **basic blocks**
connected by edges. The key idea of a basic block is that it is a set
of statements that execute "together" – that is, whenever you branch
to a basic block, you start at the first statement and then execute
all the remainder. Only at the end of the block is there the
possibility of branching to more than one place (in MIR, we call that
final statement the **terminator**):
-->

控制流图由以边相连的一组**基本块(basic block)**构成。基本块的主要概念是
一组「一起」执行的语句,也就是说,只要你的分支跳到了基本块,
它就会从头到尾依次执行所有的语句。只有到基本块的最后才有可能分支到更多地方
(在 MIR 中,我们将最后一条语句称作**终止句(terminator)**):

```mir
bb0: {
Expand All @@ -31,8 +57,12 @@ bb0: {
}
```

<!--
Many expressions that you are used to in Rust compile down to multiple
basic blocks. For example, consider an if statement:
-->

你在 Rust 中使用的很多表达式都会编译成多个基本块。例如,考虑以下 if 语句:

```rust,ignore
a = 1;
Expand All @@ -44,7 +74,11 @@ if some_variable {
d = 1;
```

<!--
This would compile into four basic blocks:
-->

它会被编译成四个基本块

```mir
BB0: {
Expand All @@ -68,39 +102,76 @@ BB3: {
}
```

<!--
When using a control-flow graph, a loop simply appears as a cycle in
the graph, and the `break` keyword translates into a path out of that
cycle.
-->

在使用控制流图时,循环会简单地作为一个图中的环路出现,而 `break`
关键字则会被翻译成跳出此环路的一条路径。

<a name="dataflow"></a>

<!--
## What is a dataflow analysis?
-->

## 什么是数据流分析?

<!--
[*Static Program Analysis*](https://cs.au.dk/~amoeller/spa/) by Anders Møller
and Michael I. Schwartzbach is an incredible resource!
-->

[**静态程序分析(Static Program Analysis)**](https://cs.au.dk/~amoeller/spa/),
作者 Anders Møller 和 Michael I. Schwartzbach,它是一个绝佳的资源。

*to be written*

<a name="quantified"></a>

<!--
## What is "universally quantified"? What about "existentially quantified"?
-->

## 什么是「全称量化」?「存在量化」呢?

*to be written*

<a name="variance"></a>

<!--
## What is co- and contra-variance?
-->

## 什么是协变和逆变?

<!--
Check out the subtyping chapter from the
[Rust Nomicon](https://doc.rust-lang.org/nomicon/subtyping.html).
-->

详见 [Rust 秘典](https://doc.rust-lang.org/nomicon/subtyping.html)
中的子定型(Subtyping)一章。

<!--
See the [variance](../variance.html) chapter of this guide for more info on how
the type checker handles variance.
-->

关于类型检查器如何处理型变的更多信息见本指南的
[型变(variance)](../variance.html)一章。

<a name="free-vs-bound"></a>

<!--
## What is a "free region" or a "free variable"? What about "bound region"?
-->

## 什么是「自由生存域」和「自由变量」?「约束生存域」呢?

<!--
Let's describe the concepts of free vs bound in terms of program
variables, since that's the thing we're most familiar with.

Expand All @@ -115,14 +186,38 @@ variables, since that's the thing we're most familiar with.
refer to local variables that are defined *outside* of the
expression. We say that those variables **appear free** in the
expression (i.e., they are **free**, not **bound** (tied up)).
-->

我们来描述一下程序变量的自由和约束的概念,因为它们是我们最熟悉的概念。

- 考虑此表达式,它创建了一个闭包:`|a, b| a + b`。在这里,`a + b` 中的 `a`
和 `b` 指代该闭包被调用会时传入的参数。我们称 `a` 和 `b` 在该闭包中是
**被约束(bound)**的,而闭包签名 `|a, b|` 是名字 `a` 和 `b` 的**约束位(binder)**
(因为对 `a` 或 `b` 的任何引用都是指代它引入的变量)。

- 考虑此表达式 `a + b`。在该表达式中,`a` 和 `b` 均指代定义在该表达式**之外**
的局部变量。我们称这些变量在该表达式中**自由出现(appear free)**
(即它们是**自由(free)**的,而非**被约束(bound)**的(被束缚的))。

<!--
So there you have it: a variable "appears free" in some
expression/statement/whatever if it refers to something defined
outside of that expressions/statement/whatever. Equivalently, we can
then refer to the "free variables" of an expression – which is just
the set of variables that "appear free".
-->

所以现在你理解了:在某些「表达式、语句、还是别的什么」中的变量,
如果指代的是定义在该「表达式、语句、还是别的什么」之外的东西,那么它们就是
「自由出现」的。我们可以等价地称之为表达式中的「自由变量」,
毕竟它们就是一组「自由出现」的变量而已。

<!--
So what does this have to do with regions? Well, we can apply the
analogous concept to type and regions. For example, in the type `&'a
u32`, `'a` appears free. But in the type `for<'a> fn(&'a u32)`, it
does not.
-->

那么,它们与生存域(region)有什么关系呢?我们可以将类似的概念应用到类型和生存域上来。
例如,在类型 `&'a u32` 中,`'a` 是自由出现的。但在类型 `for<'a> fn(&'a u32)` 中则不是。
11 changes: 11 additions & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
- [The HIR (High-level IR)](./hir.md)
- [Lowering AST to HIR](./lowering.md)
- [Debugging](./hir-debugging.md)
- [Closure expansion](./closure.md)
- [The `ty` module: representing types](./ty.md)
- [Kinds](./kinds.md)
- [Type inference](./type-inference.md)
Expand Down Expand Up @@ -75,6 +76,12 @@
- [Move paths](./borrow_check/moves_and_initialization/move_paths.md)
- [MIR type checker](./borrow_check/type_check.md)
- [Region inference](./borrow_check/region_inference.md)
- [Constraint propagation](./borrow_check/region_inference/constraint_propagation.md)
- [Lifetime parameters](./borrow_check/region_inference/lifetime_parameters.md)
- [Member constraints](./borrow_check/region_inference/member_constraints.md)
- [Placeholders and universes][pau]
- [Closure constraints](./borrow_check/region_inference/closure_constraints.md)
- [Errror reporting](./borrow_check/region_inference/error_reporting.md)
- [Two-phase-borrows](./borrow_check/two_phase_borrows.md)
- [Constant evaluation](./const-eval.md)
- [miri const evaluator](./miri.md)
Expand All @@ -83,11 +90,15 @@
- [Updating LLVM](./codegen/updating-llvm.md)
- [Debugging LLVM](./codegen/debugging.md)
- [Profile-guided Optimization](./profile-guided-optimization.md)
- [Debugging Support in Rust Compiler](./debugging-support-in-rustc.md)

---

[Appendix A: Stupid Stats](./appendix/stupid-stats.md)
[Appendix B: Background material](./appendix/background.md)
[Appendix C: Glossary](./appendix/glossary.md)
[Appendix D: Code Index](./appendix/code-index.md)
[Appendix E: Bibliography](./appendix/bibliography.md)
[](./important-links.md)

[pau]: ./borrow_check/region_inference/placeholders_and_universes.md
90 changes: 90 additions & 0 deletions src/appendix/bibliography.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Rust Bibliography

This is a reading list of material relevant to Rust. It includes prior
research that has - at one time or another - influenced the design of
Rust, as well as publications about Rust.

## Type system

* [Region based memory management in Cyclone](https://www.cs.umd.edu/projects/cyclone/papers/cyclone-regions.pdf)
* [Safe manual memory management in Cyclone](http://www.cs.umd.edu/projects/PL/cyclone/scp.pdf)
* [Typeclasses: making ad-hoc polymorphism less ad hoc](http://www.ps.uni-sb.de/courses/typen-ws99/class.ps.gz)
* [Macros that work together](https://www.cs.utah.edu/plt/publications/jfp12-draft-fcdf.pdf)
* [Traits: composable units of behavior](http://scg.unibe.ch/archive/papers/Scha03aTraits.pdf)
* [Alias burying](http://www.cs.uwm.edu/faculty/boyland/papers/unique-preprint.ps) - We tried something similar and abandoned it.
* [External uniqueness is unique enough](http://www.cs.uu.nl/research/techreps/UU-CS-2002-048.html)
* [Uniqueness and Reference Immutability for Safe Parallelism](https://research.microsoft.com/pubs/170528/msr-tr-2012-79.pdf)
* [Region Based Memory Management](http://www.cs.ucla.edu/~palsberg/tba/papers/tofte-talpin-iandc97.pdf)

## Concurrency

* [Singularity: rethinking the software stack](https://research.microsoft.com/pubs/69431/osr2007_rethinkingsoftwarestack.pdf)
* [Language support for fast and reliable message passing in singularity OS](https://research.microsoft.com/pubs/67482/singsharp.pdf)
* [Scheduling multithreaded computations by work stealing](http://supertech.csail.mit.edu/papers/steal.pdf)
* [Thread scheduling for multiprogramming multiprocessors](http://www.eecis.udel.edu/%7Ecavazos/cisc879-spring2008/papers/arora98thread.pdf)
* [The data locality of work stealing](http://www.aladdin.cs.cmu.edu/papers/pdfs/y2000/locality_spaa00.pdf)
* [Dynamic circular work stealing deque](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.170.1097&rep=rep1&type=pdf) - The Chase/Lev deque
* [Work-first and help-first scheduling policies for async-finish task parallelism](http://www.cs.rice.edu/%7Eyguo/pubs/PID824943.pdf) - More general than fully-strict work stealing
* [A Java fork/join calamity](http://www.coopsoft.com/ar/CalamityArticle.html) - critique of Java's fork/join library, particularly its application of work stealing to non-strict computation
* [Scheduling techniques for concurrent systems](http://www.stanford.edu/~ouster/cgi-bin/papers/coscheduling.pdf)
* [Contention aware scheduling](http://www.blagodurov.net/files/a8-blagodurov.pdf)
* [Balanced work stealing for time-sharing multicores](http://www.cse.ohio-state.edu/hpcs/WWW/HTML/publications/papers/TR-12-1.pdf)
* [Three layer cake for shared-memory programming](http://dl.acm.org/citation.cfm?id=1953616&dl=ACM&coll=DL&CFID=524387192&CFTOKEN=44362705)
* [Non-blocking steal-half work queues](http://www.cs.bgu.ac.il/%7Ehendlerd/papers/p280-hendler.pdf)
* [Reagents: expressing and composing fine-grained concurrency](http://aturon.github.io/academic/reagents.pdf)
* [Algorithms for scalable synchronization of shared-memory multiprocessors](https://www.cs.rochester.edu/u/scott/papers/1991_TOCS_synch.pdf)
* [Epoch-based reclamation](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-579.pdf).

## Others

* [Crash-only software](https://www.usenix.org/legacy/events/hotos03/tech/full_papers/candea/candea.pdf)
* [Composing High-Performance Memory Allocators](http://people.cs.umass.edu/~emery/pubs/berger-pldi2001.pdf)
* [Reconsidering Custom Memory Allocation](http://people.cs.umass.edu/~emery/pubs/berger-oopsla2002.pdf)

## Papers *about* Rust

* [GPU Programming in Rust: Implementing High Level Abstractions in a Systems
Level
Language](https://www.cs.indiana.edu/~achauhan/Publications/Pubs/2013-hips-holk-rust.pdf).
Early GPU work by Eric Holk.
* [Parallel closures: a new twist on an old
idea](https://www.usenix.org/conference/hotpar12/parallel-closures-new-twist-old-idea)
- not exactly about Rust, but by nmatsakis
* [Patina: A Formalization of the Rust Programming
Language](http://dada.cs.washington.edu/research/tr/2015/03/UW-CSE-15-03-02.pdf).
Early formalization of a subset of the type system, by Eric Reed.
* [Experience Report: Developing the Servo Web Browser Engine using
Rust](http://arxiv.org/abs/1505.07383). By Lars Bergstrom.
* [Implementing a Generic Radix Trie in
Rust](https://michaelsproul.github.io/rust_radix_paper/rust-radix-sproul.pdf). Undergrad
paper by Michael Sproul.
* [Reenix: Implementing a Unix-Like Operating System in
Rust](http://scialex.github.io/reenix.pdf). Undergrad paper by Alex
Light.
* [Evaluation of performance and productivity metrics of potential programming languages in the HPC environment](http://octarineparrot.com/assets/mrfloya-thesis-ba.pdf).
Bachelor's thesis by Florian Wilkens. Compares C, Go and Rust.
* [Nom, a byte oriented, streaming, zero copy, parser combinators library
in Rust](http://spw15.langsec.org/papers/couprie-nom.pdf). By
Geoffroy Couprie, research for VLC.
* [Graph-Based Higher-Order Intermediate
Representation](http://compilers.cs.uni-saarland.de/papers/lkh15_cgo.pdf). An
experimental IR implemented in Impala, a Rust-like language.
* [Code Refinement of Stencil
Codes](http://compilers.cs.uni-saarland.de/papers/ppl14_web.pdf). Another
paper using Impala.
* [Parallelization in Rust with fork-join and
friends](http://publications.lib.chalmers.se/records/fulltext/219016/219016.pdf). Linus
Farnstrand's master's thesis.
* [Session Types for
Rust](http://munksgaard.me/papers/laumann-munksgaard-larsen.pdf). Philip
Munksgaard's master's thesis. Research for Servo.
* [Ownership is Theft: Experiences Building an Embedded OS in Rust - Amit Levy, et. al.](http://amitlevy.com/papers/tock-plos2015.pdf)
* [You can't spell trust without Rust](https://raw.githubusercontent.com/Gankro/thesis/master/thesis.pdf). Alexis Beingessner's master's thesis.
* [Rust-Bio: a fast and safe bioinformatics library](http://bioinformatics.oxfordjournals.org/content/early/2015/10/06/bioinformatics.btv573). Johannes Köster
* [Safe, Correct, and Fast Low-Level Networking](https://octarineparrot.com/assets/msci_paper.pdf). Robert Clipsham's master's thesis.
* [Formalizing Rust traits](http://hdl.handle.net/2429/55609). Jonatan Milewski's master's thesis.
* [Rust as a Language for High Performance GC Implementation](http://users.cecs.anu.edu.au/~steveb/downloads/pdf/rust-ismm-2016.pdf)
* [Simple Verification of Rust Programs via Functional Purification](https://github.com/Kha/electrolysis). Sebastian Ullrich's master's thesis.
* [Writing parsers like it is 2017](http://spw17.langsec.org/papers/chifflier-parsing-in-2017.pdf) Pierre Chifflier and Geoffroy Couprie for the Langsec Workshop
* [The Case for Writing a Kernel in Rust](https://www.tockos.org/assets/papers/rust-kernel-apsys2017.pdf)
* [RustBelt: Securing the Foundations of the Rust Programming Language](https://plv.mpi-sws.org/rustbelt/popl18/)
2 changes: 1 addition & 1 deletion src/appendix/code-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Item | Kind | Short description | Chapter |
`TraitDef` | struct | This struct contains a trait's definition with type information | [The `ty` modules] | [src/librustc/ty/trait_def.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/trait_def/struct.TraitDef.html)
`TraitRef` | struct | The combination of a trait and its input types (e.g. `P0: Trait<P1...Pn>`) | [Trait Solving: Goals and Clauses], [Trait Solving: Lowering impls] | [src/librustc/ty/sty.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.TraitRef.html)
`Ty<'tcx>` | struct | This is the internal representation of a type used for type checking | [Type checking] | [src/librustc/ty/mod.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/type.Ty.html)
`TyCtxt<'cx, 'tcx, 'tcx>` | struct | The "typing context". This is the central data structure in the compiler. It is the context that you use to perform all manner of queries | [The `ty` modules] | [src/librustc/ty/context.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.TyCtxt.html)
`TyCtxt<'tcx>` | struct | The "typing context". This is the central data structure in the compiler. It is the context that you use to perform all manner of queries | [The `ty` modules] | [src/librustc/ty/context.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.TyCtxt.html)

[The HIR]: ../hir.html
[Identifiers in the HIR]: ../hir.html#hir-id
Expand Down
Loading