Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
30 changes: 29 additions & 1 deletion book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,39 @@ cache-timeout = 90000
warning-policy = "error"

[output.html.redirect]
"/borrow_check.html" = "borrow-check.html"
"/borrow_check/drop_check.html" = "borrow-check/drop-check.html"
"/borrow_check/moves_and_initialization.html" = "borrow-check/moves-and-initialization.html"
"/borrow_check/moves_and_initialization/move_paths.html" = "borrow-check/moves-and-initialization/move-paths.html"
"/borrow_check/opaque-types-region-inference-restrictions.html" = "borrow-check/opaque-types-region-inference-restrictions.html"
"/borrow_check/region_inference.html" = "borrow-check/region-inference.html"
"/borrow_check/region_inference/closure_constraints.html" = "borrow-check/region-inference/closure-constraints.html"
"/borrow_check/region_inference/constraint_propagation.html" = "borrow-check/region-inference/constraint-propagation.html"
"/borrow_check/region_inference/error_reporting.html" = "borrow-check/region-inference/error-reporting.html"
"/borrow_check/region_inference/lifetime_parameters.html" = "borrow-check/region-inference/lifetime-parameters.html"
"/borrow_check/region_inference/member_constraints.html" = "borrow-check/region-inference/member-constraints.html"
"/borrow_check/region_inference/placeholders_and_universes.html" = "borrow-check/region-inference/placeholders-and-universes.html"
"/borrow_check/two_phase_borrows.html" = "borrow-check/two-phase-borrows.html"
"/borrow_check/type_check.html" = "borrow-check/type-check.html"
"/compiletest.html" = "tests/compiletest.html"
"/diagnostics/sessiondiagnostic.html" = "diagnostic-structs.html"
"/diagnostics/diagnostic-codes.html" = "error-codes.html"
"/diagnostics/sessiondiagnostic.html" = "diagnostic-structs.html"
"/early_late_parameters.html" = "early-late-parameters.html"
"/generic_parameters_summary.html" = "generic-parameters-summary.html"
"/implementing_new_features.html" = "implementing-new-features.html"
"/miri.html" = "const-eval/interpret.html"
"/profiling/with_perf.html" = "profiling/with-perf.html"
"/profiling/with_rustc_perf.html" = "profiling/with-rustc-perf.html"
"/profiling/wpa_profiling.html" = "profiling/wpa-profiling.html"
"/stabilization_guide.html" = "stabilization-guide.html"
"/stabilization_report_template.html" = "stabilization-report-template.html"
"/tests/fuchsia.html" = "ecosystem-test-jobs/fuchsia.html"
"/tests/headers.html" = "directives.html"
"/tests/integration.html" = "ecosystem.html"
"/tests/rust-for-linux.html" = "ecosystem-test-jobs/rust-for-linux.html"
"/ty_module/binders.html" = "ty-module/binders.html"
"/ty_module/early_binder.html" = "ty-module/early-binder.html"
"/ty_module/generic_arguments.html" = "ty-module/generic-arguments.html"
"/ty_module/instantiating_binders.html" = "ty-module/instantiating-binders.html"
"/ty_module/param_ty_const_regions.html" = "ty-module/param-ty-const-regions.html"
"/typing_parameter_envs.html" = "typing-parameter-envs.html"
61 changes: 28 additions & 33 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
- [Debugging the compiler](./compiler-debugging.md)
- [Using the tracing/logging instrumentation](./tracing.md)
- [Profiling the compiler](./profiling.md)
- [with the linux perf tool](./profiling/with_perf.md)
- [with Windows Performance Analyzer](./profiling/wpa_profiling.md)
- [with the Rust benchmark suite](./profiling/with_rustc_perf.md)
- [with the linux perf tool](./profiling/with-perf.md)
- [with Windows Performance Analyzer](./profiling/wpa-profiling.md)
- [with the Rust benchmark suite](./profiling/with-rustc-perf.md)
- [crates.io dependencies](./crates-io.md)

# Contributing to Rust
Expand All @@ -51,11 +51,11 @@
- [Using Git](./git.md)
- [Mastering @rustbot](./rustbot.md)
- [Walkthrough: a typical contribution](./walkthrough.md)
- [Implementing new language features](./implementing_new_features.md)
- [Implementing new language features](./implementing-new-features.md)
- [Stability guarantees](./stability-guarantees.md)
- [Stability attributes](./stability.md)
- [Stabilizing language features](./stabilization_guide.md)
- [Stabilization report template](./stabilization_report_template.md)
- [Stabilizing language features](./stabilization-guide.md)
- [Stabilization report template](./stabilization-report-template.md)
- [Feature Gates](./feature-gates.md)
- [Coding conventions](./conventions.md)
- [Procedures for breaking changes](./bug-fix-procedure.md)
Expand Down Expand Up @@ -154,17 +154,17 @@
# Analysis

- [Prologue](./part-4-intro.md)
- [Generic parameter definitions](./generic_parameters_summary.md)
- [`EarlyBinder` and instantiating parameters](./ty_module/early_binder.md)
- [Binders and Higher ranked regions](./ty_module/binders.md)
- [Instantiating binders](./ty_module/instantiating_binders.md)
- [Early vs Late bound parameters](./early_late_parameters.md)
- [Generic parameter definitions](./generic-parameters-summary.md)
- [`EarlyBinder` and instantiating parameters](./ty-module/early-binder.md)
- [Binders and Higher ranked regions](./ty-module/binders.md)
- [Instantiating binders](./ty-module/instantiating-binders.md)
- [Early vs Late bound parameters](./early-late-parameters.md)
- [The `ty` module: representing types](./ty.md)
- [ADTs and Generic Arguments](./ty_module/generic_arguments.md)
- [Parameter types/consts/regions](./ty_module/param_ty_const_regions.md)
- [ADTs and Generic Arguments](./ty-module/generic-arguments.md)
- [Parameter types/consts/regions](./ty-module/param-ty-const-regions.md)
- [`TypeFolder` and `TypeFoldable`](./ty-fold.md)
- [Aliases and Normalization](./normalization.md)
- [Typing/Param Envs](./typing_parameter_envs.md)
- [Typing/Param Envs](./typing-parameter-envs.md)
- [Type inference](./type-inference.md)
- [Trait solving](./traits/resolution.md)
- [Higher-ranked trait bounds](./traits/hrtb.md)
Expand Down Expand Up @@ -197,25 +197,25 @@
- [Opaque types](./opaque-types-type-alias-impl-trait.md)
- [Inference details](./opaque-types-impl-trait-inference.md)
- [Return Position Impl Trait In Trait](./return-position-impl-trait-in-trait.md)
- [Region inference restrictions][opaque-infer]
- [Region inference restrictions](./borrow-check/opaque-types-region-inference-restrictions.md)
- [Const condition checking](./effects.md)
- [Pattern and exhaustiveness checking](./pat-exhaustive-checking.md)
- [Unsafety checking](./unsafety-checking.md)
- [MIR dataflow](./mir/dataflow.md)
- [Drop elaboration](./mir/drop-elaboration.md)
- [The borrow checker](./borrow_check.md)
- [Tracking moves and initialization](./borrow_check/moves_and_initialization.md)
- [Move paths](./borrow_check/moves_and_initialization/move_paths.md)
- [MIR type checker](./borrow_check/type_check.md)
- [Drop check](./borrow_check/drop_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)
- [Error reporting](./borrow_check/region_inference/error_reporting.md)
- [Two-phase-borrows](./borrow_check/two_phase_borrows.md)
- [The borrow checker](./borrow-check.md)
- [Tracking moves and initialization](./borrow-check/moves-and-initialization.md)
- [Move paths](./borrow-check/moves-and-initialization/move-paths.md)
- [MIR type checker](./borrow-check/type-check.md)
- [Drop check](./borrow-check/drop-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](./borrow-check/region-inference/placeholders-and-universes.md)
- [Closure constraints](./borrow-check/region-inference/closure-constraints.md)
- [Error reporting](./borrow-check/region-inference/error-reporting.md)
- [Two-phase-borrows](./borrow-check/two-phase-borrows.md)
- [Closure capture inference](./closure.md)
- [Async closures/"coroutine-closures"](coroutine-closures.md)

Expand Down Expand Up @@ -263,8 +263,3 @@
[Appendix E: Bibliography](./appendix/bibliography.md)

[Appendix Z: HumorRust](./appendix/humorust.md)

---

[pau]: ./borrow_check/region_inference/placeholders_and_universes.md
[opaque-infer]: ./borrow_check/opaque-types-region-inference-restrictions.md
3 changes: 1 addition & 2 deletions src/appendix/background.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,7 @@ use in lambda calculus evaluation (see [this Wikipedia article][wikideb] for
more). In `rustc`, we use de Bruijn indices to [represent generic types][sub].

[wikideb]: https://en.wikipedia.org/wiki/De_Bruijn_index
[sub]: ../ty_module/generic_arguments.md

[sub]: ../ty-module/generic-arguments.md

Here is a basic example of how de Bruijn indices might be used for closures (we
don't actually do this in `rustc` though!):
Expand Down
2 changes: 1 addition & 1 deletion src/appendix/code-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ Item | Kind | Short description | Chapter |
[Emitting Diagnostics]: ../diagnostics.html
[Macro expansion]: ../macro-expansion.html
[Name resolution]: ../name-resolution.html
[Parameter Environment]: ../typing_parameter_envs.html
[Parameter Environment]: ../typing-parameter-envs.html
[Trait Solving: Goals and Clauses]: ../traits/goals-and-clauses.html#domain-goals
4 changes: 2 additions & 2 deletions src/appendix/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ Term | Meaning
<span id="normalize">normalize</span> | A general term for converting to a more canonical form, but in the case of rustc typically refers to [associated type normalization](../traits/goals-and-clauses.md#normalizeprojection---type).
<span id="newtype">newtype</span> | A wrapper around some other type (e.g., `struct Foo(T)` is a "newtype" for `T`). This is commonly used in Rust to give a stronger type for indices.
<span id="niche">niche</span> | Invalid bit patterns for a type _that can be used_ for layout optimizations. Some types cannot have certain bit patterns. For example, the `NonZero*` integers or the reference `&T` cannot be represented by a 0 bitstring. This means the compiler can perform layout optimizations by taking advantage of the invalid "niche value". An example application for this is the [*Discriminant elision on `Option`-like enums*](https://rust-lang.github.io/unsafe-code-guidelines/layout/enums.html#discriminant-elision-on-option-like-enums), which allows using a type's niche as the ["tag"](#tag) for an `enum` without requiring a separate field.
<span id="nll">NLL</span> | Short for [non-lexical lifetimes](../borrow_check/region_inference.md), this is an extension to Rust's borrowing system to make it be based on the control-flow graph.
<span id="nll">NLL</span> | Short for [non-lexical lifetimes](../borrow-check/region-inference.md), this is an extension to Rust's borrowing system to make it be based on the control-flow graph.
<span id="node-id">node-id or `NodeId`</span> | An index identifying a particular node in the AST or HIR; gradually being phased out and replaced with `HirId`. See [the HIR chapter for more](../hir.md#identifiers-in-the-hir).
<span id="obligation">obligation</span> | Something that must be proven by the trait system. ([see more](../traits/resolution.md))
<span id="placeholder">placeholder</span> | **NOTE: skolemization is deprecated by placeholder** a way of handling subtyping around "for-all" types (e.g., `for<'a> fn(&'a u32)`) as well as solving higher-ranked trait bounds (e.g., `for<'a> T: Trait<'a>`). See [the chapter on placeholder and universes](../borrow_check/region_inference/placeholders_and_universes.md) for more details.
<span id="placeholder">placeholder</span> | **NOTE: skolemization is deprecated by placeholder** a way of handling subtyping around "for-all" types (e.g., `for<'a> fn(&'a u32)`) as well as solving higher-ranked trait bounds (e.g., `for<'a> T: Trait<'a>`). See [the chapter on placeholder and universes](../borrow-check/region-inference/placeholders-and-universes.md) for more details.
<span id="point">point</span> | Used in the NLL analysis to refer to some particular location in the MIR; typically used to refer to a node in the control-flow graph.
<span id="projection">projection</span> | A general term for a "relative path", e.g. `x.f` is a "field projection", and `T::Item` is an ["associated type projection"](../traits/goals-and-clauses.md#trait-ref).
<span id="pc">promoted constants</span> | Constants extracted from a function and lifted to static scope; see [this section](../mir/index.md#promoted) for more details.
Expand Down
4 changes: 2 additions & 2 deletions src/borrow_check.md → src/borrow-check.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ the [`mir_borrowck`] query.
- Next, we perform a number of
[dataflow analyses](./appendix/background.md#dataflow) that
compute what data is moved and when.
- We then do a [second type check](borrow_check/type_check.md) across the MIR:
- We then do a [second type check](borrow-check/type-check.md) across the MIR:
the purpose of this type check is to determine all of the constraints between
different regions.
- Next, we do [region inference](borrow_check/region_inference.md), which computes
- Next, we do [region inference](borrow-check/region-inference.md), which computes
the values of each region — basically, the points in the control-flow graph where
each lifetime must be valid according to the constraints we collected.
- At this point, we can compute the "borrows in scope" at each point.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ Consider this example:
```rust,ignore
fn foo() {
let a: Vec<u32>;

// a is not initialized yet

a = vec![22];

// a is initialized here

std::mem::drop(a); // a is moved here

// a is no longer initialized here

let l = a.len(); //~ ERROR
Expand All @@ -44,7 +44,7 @@ moves `a` into the call, and hence it becomes uninitialized again.
To make it easier to peruse, this section is broken into a number of
subsections:

- [Move paths](./moves_and_initialization/move_paths.html) the
- [Move paths](./moves-and-initialization/move-paths.md) the
*move path* concept that we use to track which local variables (or parts of
local variables, in some cases) are initialized.
- TODO *Rest not yet written* =)
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ See [#113971] for how we used to conflate the difference.

[#113971]: https://github.com/rust-lang/rust/issues/113971
[SCC]: https://en.wikipedia.org/wiki/Strongly_connected_component
[member constraints]: ./region_inference/member_constraints.md
[member constraints]: region-inference/member-constraints.md

**interaction with "once modulo regions" restriction**
In the example above, note the opaque type in the signature is `Opaque<'a>` and the one in the
Expand Down Expand Up @@ -195,7 +195,7 @@ fn test<'a>() -> Opaque<'a> {
}
```

**Motivation:**
**Motivation:**
In closure bodies, external lifetimes, although being categorized as "universal" lifetimes,
behave more like existential lifetimes in that the relations between them are not known ahead of
time, instead their values are inferred just like existential lifetimes and the requirements are
Expand All @@ -208,7 +208,7 @@ Here is an example that details how :
```rust
type Opaque<'x, 'y> = impl Sized;

//
//
fn test<'a, 'b>(s: &'a str) -> impl FnOnce() -> Opaque<'a, 'b> {
move || { s }
//~^ ERROR hidden type for `Opaque<'_, '_>` captures lifetime that does not appear in bounds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ The MIR-based region analysis consists of two major functions:
- The [NLL RFC] also includes fairly thorough (and hopefully readable)
coverage.

[cp]: ./region_inference/constraint_propagation.md
[cp]: ./region-inference/constraint-propagation.md
[fvb]: ../appendix/background.md#free-vs-bound
[`replace_regions_in_mir`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_borrowck/nll/fn.replace_regions_in_mir.html
[`compute_regions`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_borrowck/nll/fn.compute_regions.html
[`RegionInferenceContext`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_borrowck/region_infer/struct.RegionInferenceContext.html
[`solve`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_borrowck/region_infer/struct.RegionInferenceContext.html#method.solve
[NLL RFC]: https://rust-lang.github.io/rfcs/2094-nll.html
[MIR type checker]: ./type_check.md
[MIR type checker]: ./type-check.md

## Universal regions

Expand Down Expand Up @@ -97,7 +97,7 @@ The kinds of region elements are as follows:
- There is an element `!1` for each placeholder region `!1`. This
corresponds (intuitively) to some unknown set of other elements –
for details on placeholders, see the section
[placeholders and universes](region_inference/placeholders_and_universes.md).
[placeholders and universes](region-inference/placeholders-and-universes.md).

## Constraints

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on one at a time (each of them is fairly independent from the others):
- [member constraints][m_c] (`member R_m of [R_c...]`), which arise from impl Trait.

[`propagate_constraints`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_borrowck/region_infer/struct.RegionInferenceContext.html#method.propagate_constraints
[m_c]: ./member_constraints.md
[m_c]: ./member-constraints.md

In this chapter, we'll explain the "heart" of constraint propagation,
covering both liveness and outlives constraints.
Expand All @@ -29,7 +29,7 @@ given some set of constraints `{C}` and it computes a set of values
- For each constraint C:
- Update `Values` as needed to satisfy the constraint

[riv]: ../region_inference.md#region-variables
[riv]: ../region-inference.md#region-variables

As a simple example, if we have a liveness constraint `R live at E`,
then we can apply `Values(R) = Values(R) union {E}` to make the
Expand Down Expand Up @@ -211,7 +211,7 @@ have already processed a given SCC or not. For each successor `S2`, once
we have computed `S2`'s value, we can union those elements into the
value for `S1`. (Although we have to be careful in this process to
properly handle [higher-ranked
placeholders](./placeholders_and_universes.html). Note that the value
placeholders](./placeholders-and-universes.md). Note that the value
for `S1` already contains the liveness constraints, since they were
added in [`RegionInferenceContext::new`].

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ In fact, the universal regions can be further subdivided based on
where they were brought into scope (see the [`RegionClassification`]
type). These subdivisions are not important for the topics discussed
here, but become important when we consider [closure constraint
propagation](./closure_constraints.html), so we discuss them there.
propagation](./closure-constraints.md), so we discuss them there.

[`RegionClassification`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_borrowck/universal_regions/enum.RegionClassification.html#variant.Local

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/const-eval.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ They're the wrappers of the `const_eval` query.
Statics are special; all other functions do not represent statics correctly
and have thus assertions preventing their use on statics.

The `const_eval_*` functions use a [`ParamEnv`](./typing_parameter_envs.html) of environment
The `const_eval_*` functions use a [`ParamEnv`](./typing-parameter-envs.md) of environment
in which the constant is evaluated (e.g. the function within which the constant is used)
and a [`GlobalId`]. The `GlobalId` is made up of an `Instance` referring to a constant
or static or of an `Instance` of a function and an index into the function's `Promoted` table.
Expand Down
Loading
Loading