Skip to content

Add mdbook-toc, markers, and documentation #1028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions src/backend/backend-agnostic.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Backend Agnostic Codegen

<!-- toc -->

As of January 2021, `rustc_codegen_ssa` provides an abstract interface for all backends to
implement, to allow other codegen backends (e.g. [Cranelift]).

Expand Down
2 changes: 2 additions & 0 deletions src/backend/implicit-caller-location.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Implicit Caller Location

<!-- toc -->

Approved in [RFC 2091], this feature enables the accurate reporting of caller location during panics
initiated from functions like `Option::unwrap`, `Result::expect`, and `Index::index`. This feature
adds the [`#[track_caller]`][attr-reference] attribute for functions, the
Expand Down
2 changes: 2 additions & 0 deletions src/backend/monomorph.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Monomorphization

<!-- toc -->

As you probably know, rust has a very expressive type system that has extensive
support for generic types. But of course, assembly is not generic, so we need
to figure out the concrete types of all the generics before the code can
Expand Down
2 changes: 2 additions & 0 deletions src/backend/updating-llvm.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Updating LLVM

<!-- toc -->

The Rust compiler uses LLVM as its primary codegen backend today, and naturally
we want to at least occasionally update this dependency! Currently we do not
have a strict policy about when to update LLVM or what it can be updated to, but
Expand Down
2 changes: 2 additions & 0 deletions src/borrow_check/moves_and_initialization/move_paths.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Move paths

<!-- toc -->

In reality, it's not enough to track initialization at the granularity
of local variables. Rust also allows us to do moves and initialization
at the field granularity:
Expand Down
2 changes: 2 additions & 0 deletions src/borrow_check/region_inference.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Region inference (NLL)

<!-- toc -->

The MIR-based region checking code is located in [the `rustc_mir::borrow_check`
module][nll].

Expand Down
2 changes: 2 additions & 0 deletions src/borrow_check/region_inference/constraint_propagation.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Constraint propagation

<!-- toc -->

The main work of the region inference is **constraint propagation**,
which is done in the [`propagate_constraints`] function. There are
three sorts of constraints that are used in NLL, and we'll explain how
Expand Down
2 changes: 2 additions & 0 deletions src/borrow_check/region_inference/lifetime_parameters.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Universal regions

<!-- toc -->

"Universal regions" is the name that the code uses to refer to "named
lifetimes" -- e.g., lifetime parameters and `'static`. The name
derives from the fact that such lifetimes are "universally quantified"
Expand Down
2 changes: 2 additions & 0 deletions src/borrow_check/region_inference/member_constraints.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Member constraints

<!-- toc -->

A member constraint `'m member of ['c_1..'c_N]` expresses that the
region `'m` must be *equal* to some **choice regions** `'c_i` (for
some `i`). These constraints cannot be expressed by users, but they
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Placeholders and universes

<!-- toc -->

From time to time we have to reason about regions that we can't
concretely know. For example, consider this program:

Expand Down
3 changes: 3 additions & 0 deletions src/bug-fix-procedure.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Rustc Bug Fix Procedure

<!-- toc -->

This page defines the best practices procedure for making bug fixes or soundness
corrections in the compiler that can cause existing code to stop compiling. This
text is based on
Expand Down
2 changes: 2 additions & 0 deletions src/building/bootstrapping.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Bootstrapping the Compiler

<!-- toc -->

This subchapter is about the bootstrapping process.

## What is bootstrapping? How does it work?
Expand Down
2 changes: 2 additions & 0 deletions src/compiler-debugging.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Debugging the compiler
[debugging]: #debugging

<!-- toc -->

This chapter contains a few tips to debug the compiler. These tips aim to be
useful no matter what you are working on. Some of the other chapters have
advice about specific parts of the compiler (e.g. the [Queries Debugging and
Expand Down
2 changes: 2 additions & 0 deletions src/compiler-src.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# High-level overview of the compiler source

<!-- toc -->

> **NOTE**: The structure of the repository is going through a lot of
> transitions. In particular, we want to get to a point eventually where the
> top-level directory has separate directories for the compiler, build-system,
Expand Down
14 changes: 5 additions & 9 deletions src/contributing.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
# Contributing to Rust

<!-- toc -->

Thank you for your interest in contributing to Rust! There are many ways to
contribute, and we appreciate all of them.

* [Feature Requests](#feature-requests)
* [Bug Reports](#bug-reports)
* [The Build System](./building/how-to-build-and-run.md)
* [Pull Requests](#pull-requests)
* [Writing Documentation](#writing-documentation)
* [Issue Triage](#issue-triage)
* [Out-of-tree Contributions](#out-of-tree-contributions)
* [Helpful Links and Information](#helpful-links-and-information)

If you have questions, please make a post on [internals.rust-lang.org][internals] or
hop on the [Rust Discord server][rust-discord] or [Rust Zulip server][rust-zulip].

Expand Down Expand Up @@ -423,6 +416,9 @@ Just a few things to keep in mind:
- A link to a relevant WG, tracking issue, `rustc` rustdoc page, or similar, that may provide
further explanation for the change process or a way to verify that the information is not
outdated.
- If a text grows rather long (more than a few page scrolls) or complicated (more than four
subsections) it might benefit from having a Table of Contents at the beginning, which you can
auto-generate by including the `<!-- toc -->` marker.

[rdg]: https://rustc-dev-guide.rust-lang.org/
[rdgrepo]: https://github.com/rust-lang/rustc-dev-guide
Expand Down
2 changes: 2 additions & 0 deletions src/debugging-support-in-rustc.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Debugging support in the Rust compiler

<!-- toc -->

This document explains the state of debugging tools support in the Rust compiler (rustc).
The document gives an overview of debugging tools like GDB, LLDB etc. and infrastructure
around Rust compiler to debug Rust code. If you want to learn how to debug the Rust compiler
Expand Down
2 changes: 2 additions & 0 deletions src/diagnostics.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Errors and Lints

<!-- toc -->

A lot of effort has been put into making `rustc` have great error messages.
This chapter is about how to emit compile errors and lints from the compiler.

Expand Down
2 changes: 2 additions & 0 deletions src/getting-started.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Getting Started

<!-- toc -->

This documentation is _not_ intended to be comprehensive; it is meant to be a
quick guide for the most useful things. For more information, [see this
chapter on how to build and run the compiler](./building/how-to-build-and-run.md).
Expand Down
2 changes: 2 additions & 0 deletions src/git.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Using Git

<!-- toc -->

The Rust project uses [Git] to manage its source code. In order to
contribute, you'll need some familiarity with its features so that your changes
can be incorporated into the compiler.
Expand Down
10 changes: 6 additions & 4 deletions src/hir.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# The HIR

<!-- toc -->

The HIR – "High-Level Intermediate Representation" – is the primary IR used
in most of rustc. It is a compiler-friendly representation of the abstract
syntax tree (AST) that is generated after parsing, macro expansion, and name
Expand All @@ -18,7 +20,7 @@ You can view the HIR representation of your code by passing the
cargo rustc -- -Z unpretty=hir-tree
```

### Out-of-band storage and the `Crate` type
## Out-of-band storage and the `Crate` type

The top-level data-structure in the HIR is the [`Crate`], which stores
the contents of the crate currently being compiled (we only ever
Expand Down Expand Up @@ -66,7 +68,7 @@ the compiler a chance to observe that you accessed the data for

<a name="hir-id"></a>

### Identifiers in the HIR
## Identifiers in the HIR

There are a bunch of different identifiers to refer to other nodes or definitions
in the HIR. In short:
Expand All @@ -81,7 +83,7 @@ For more detailed information, check out the [chapter on identifiers][ids].
[`HirId`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir_id/struct.HirId.html
[ids]: ./identifiers.md#in-the-hir

### The HIR Map
## The HIR Map

Most of the time when you are working with the HIR, you will do so via
the **HIR Map**, accessible in the tcx via [`tcx.hir()`] (and defined in
Expand Down Expand Up @@ -124,7 +126,7 @@ calls like [`tcx.hir().get_parent_node(n)`][get_parent_node].

[get_parent_node]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/map/struct.Map.html#method.get_parent_node

### HIR Bodies
## HIR Bodies

A [`rustc_hir::Body`] represents some kind of executable code, such as the body
of a function/closure or the definition of a constant. Bodies are
Expand Down
4 changes: 3 additions & 1 deletion src/llvm-coverage-instrumentation.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# LLVM Source-Based Code Coverage

<!-- toc -->

`rustc` supports detailed source-based code and test coverage analysis
with a command line option (`-Z instrument-coverage`) that instruments Rust
libraries and binaries with additional instructions and data, at compile time.
Expand Down Expand Up @@ -32,7 +34,7 @@ Detailed instructions and examples are documented in the
[Coverage Map]: https://llvm.org/docs/CoverageMappingFormat.html
[unstable-book-sbcc]: https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/source-based-code-coverage.html

### Rust symbol mangling
## Rust symbol mangling

`-Z instrument-coverage` automatically enables Rust symbol mangling `v0` (as
if the user specified `-Z symbol-mangling-version=v0` option when invoking
Expand Down
2 changes: 2 additions & 0 deletions src/macro-expansion.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Macro expansion

<!-- toc -->

> `rustc_ast`, `rustc_expand`, and `rustc_builtin_macros` are all undergoing
> refactoring, so some of the links in this chapter may be broken.

Expand Down
2 changes: 2 additions & 0 deletions src/mir/construction.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# THIR and MIR construction

<!-- toc -->

The lowering of [HIR] to [MIR] occurs for the following (probably incomplete)
list of items:

Expand Down
2 changes: 2 additions & 0 deletions src/mir/dataflow.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Dataflow Analysis

<!-- toc -->

If you work on the MIR, you will frequently come across various flavors of
[dataflow analysis][wiki]. `rustc` uses dataflow to find uninitialized
variables, determine what variables are live across a generator `yield`
Expand Down
2 changes: 2 additions & 0 deletions src/mir/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# The MIR (Mid-level IR)

<!-- toc -->

MIR is Rust's _Mid-level Intermediate Representation_. It is
constructed from [HIR](../hir.html). MIR was introduced in
[RFC 1211]. It is a radically simplified form of Rust that is used for
Expand Down
2 changes: 2 additions & 0 deletions src/miri.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Miri

<!-- toc -->

Miri (**MIR** **I**nterpreter) is a virtual machine for executing MIR without
compiling to machine code. It is usually invoked via `tcx.const_eval_*` functions.

Expand Down
2 changes: 2 additions & 0 deletions src/name-resolution.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Name resolution

<!-- toc -->

In the previous chapters, we saw how the AST is built with all macros expanded.
We saw how doing that requires doing some name resolution to resolve imports
and macro names. In this chapter, we show how this is actually done and more.
Expand Down
2 changes: 2 additions & 0 deletions src/overview.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Overview of the Compiler

<!-- toc -->

This chapter is about the overall process of compiling a program -- how
everything fits together.

Expand Down
14 changes: 8 additions & 6 deletions src/panic-implementation.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
### Panicking in rust ###
# Panicking in rust

#### Step 1: Invocation of the `panic!` macro.
<!-- toc -->

## Step 1: Invocation of the `panic!` macro.

There are actually two panic macros - one defined in `core`, and one defined in `std`.
This is due to the fact that code in `core` can panic. `core` is built before `std`,
but we want panics to use the same machinery at runtime, whether they originate in `core`
or `std`.

##### core definition of panic!
### core definition of panic!

The `core` `panic!` macro eventually makes the following call (in `library/core/src/panicking.rs`):

Expand Down Expand Up @@ -57,7 +59,7 @@ Rust source).
Thus, control flow will pass from core to std at runtime. This allows panics from `core`
to go through the same infrastructure that other panics use (panic hooks, unwinding, etc)

##### std implementation of panic!
### std implementation of panic!

This is where the actual panic-related logic begins. In `library/std/src/panicking.rs`,
control passes to `rust_panic_with_hook`. This method is responsible
Expand All @@ -83,15 +85,15 @@ is suitable for passing across an FFI boundary.

Finally, we call `__rust_start_panic` with this `usize`. We have now entered the panic runtime.

#### Step 2: The panic runtime
## Step 2: The panic runtime

Rust provides two panic runtimes: `panic_abort` and `panic_unwind`. The user chooses
between them at build time via their `Cargo.toml`

`panic_abort` is extremely simple: its implementation of `__rust_start_panic` just aborts,
as you would expect.

`panic_unwind` is the more interesting case.
`panic_unwind` is the more interesting case.

In its implementation of `__rust_start_panic`, we take the `usize`, convert
it back to a `*mut &mut dyn BoxMeUp`, dereference it, and call `box_me_up`
Expand Down
2 changes: 2 additions & 0 deletions src/profile-guided-optimization.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Profile Guided Optimization

<!-- toc -->

`rustc` supports doing profile-guided optimization (PGO).
This chapter describes what PGO is and how the support for it is
implemented in `rustc`.
Expand Down
2 changes: 2 additions & 0 deletions src/queries/incremental-compilation-in-detail.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Incremental Compilation In Detail

<!-- toc -->

The incremental compilation scheme is, in essence, a surprisingly
simple extension to the overall query system. It relies on the fact that:

Expand Down
2 changes: 2 additions & 0 deletions src/queries/incremental-compilation.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Incremental compilation

<!-- toc -->

The incremental compilation scheme is, in essence, a surprisingly
simple extension to the overall query system. We'll start by describing
a slightly simplified variant of the real thing – the "basic algorithm" –
Expand Down
3 changes: 3 additions & 0 deletions src/queries/profiling.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Profiling Queries

<!-- toc -->

In an effort to support _incremental compilation_, the latest design of the Rust
compiler consists of a _query-based_ model.

Expand Down
2 changes: 2 additions & 0 deletions src/queries/query-evaluation-model-in-detail.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# The Query Evaluation Model in Detail

<!-- toc -->

This chapter provides a deeper dive into the abstract model queries are built on.
It does not go into implementation details but tries to explain
the underlying logic. The examples here, therefore, have been stripped down and
Expand Down
2 changes: 2 additions & 0 deletions src/rustdoc-internals.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Rustdoc internals

<!-- toc -->

This page describes rustdoc's passes and modes. For an overview of rustdoc,
see [`rustdoc`](./rustdoc.md).

Expand Down
2 changes: 2 additions & 0 deletions src/salsa.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# How Salsa works

<!-- toc -->

This chapter is based on the explanation given by Niko Matsakis in this
[video](https://www.youtube.com/watch?v=_muY4HjSqVw) about
[Salsa](https://github.com/salsa-rs/salsa). To find out more you may
Expand Down
Loading