Skip to content

Commit 058e955

Browse files
committed
Add toc markers
1 parent ca00b13 commit 058e955

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+122
-29
lines changed

src/backend/backend-agnostic.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Backend Agnostic Codegen
22

3+
<!-- toc -->
4+
35
As of January 2021, `rustc_codegen_ssa` provides an abstract interface for all backends to
46
implement, to allow other codegen backends (e.g. [Cranelift]).
57

src/backend/implicit-caller-location.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Implicit Caller Location
22

3+
<!-- toc -->
4+
35
Approved in [RFC 2091], this feature enables the accurate reporting of caller location during panics
46
initiated from functions like `Option::unwrap`, `Result::expect`, and `Index::index`. This feature
57
adds the [`#[track_caller]`][attr-reference] attribute for functions, the

src/backend/monomorph.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Monomorphization
22

3+
<!-- toc -->
4+
35
As you probably know, rust has a very expressive type system that has extensive
46
support for generic types. But of course, assembly is not generic, so we need
57
to figure out the concrete types of all the generics before the code can

src/backend/updating-llvm.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Updating LLVM
22

3+
<!-- toc -->
4+
35
The Rust compiler uses LLVM as its primary codegen backend today, and naturally
46
we want to at least occasionally update this dependency! Currently we do not
57
have a strict policy about when to update LLVM or what it can be updated to, but

src/borrow_check/moves_and_initialization/move_paths.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Move paths
22

3+
<!-- toc -->
4+
35
In reality, it's not enough to track initialization at the granularity
46
of local variables. Rust also allows us to do moves and initialization
57
at the field granularity:

src/borrow_check/region_inference.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Region inference (NLL)
22

3+
<!-- toc -->
4+
35
The MIR-based region checking code is located in [the `rustc_mir::borrow_check`
46
module][nll].
57

src/borrow_check/region_inference/constraint_propagation.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Constraint propagation
22

3+
<!-- toc -->
4+
35
The main work of the region inference is **constraint propagation**,
46
which is done in the [`propagate_constraints`] function. There are
57
three sorts of constraints that are used in NLL, and we'll explain how

src/borrow_check/region_inference/lifetime_parameters.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Universal regions
22

3+
<!-- toc -->
4+
35
"Universal regions" is the name that the code uses to refer to "named
46
lifetimes" -- e.g., lifetime parameters and `'static`. The name
57
derives from the fact that such lifetimes are "universally quantified"

src/borrow_check/region_inference/member_constraints.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Member constraints
22

3+
<!-- toc -->
4+
35
A member constraint `'m member of ['c_1..'c_N]` expresses that the
46
region `'m` must be *equal* to some **choice regions** `'c_i` (for
57
some `i`). These constraints cannot be expressed by users, but they

src/borrow_check/region_inference/placeholders_and_universes.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Placeholders and universes
22

3+
<!-- toc -->
4+
35
From time to time we have to reason about regions that we can't
46
concretely know. For example, consider this program:
57

src/bug-fix-procedure.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Rustc Bug Fix Procedure
2+
3+
<!-- toc -->
4+
25
This page defines the best practices procedure for making bug fixes or soundness
36
corrections in the compiler that can cause existing code to stop compiling. This
47
text is based on

src/building/bootstrapping.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Bootstrapping the Compiler
22

3+
<!-- toc -->
4+
35
This subchapter is about the bootstrapping process.
46

57
## What is bootstrapping? How does it work?

src/compiler-debugging.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Debugging the compiler
22
[debugging]: #debugging
33

4+
<!-- toc -->
5+
46
This chapter contains a few tips to debug the compiler. These tips aim to be
57
useful no matter what you are working on. Some of the other chapters have
68
advice about specific parts of the compiler (e.g. the [Queries Debugging and

src/compiler-src.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# High-level overview of the compiler source
22

3+
<!-- toc -->
4+
35
> **NOTE**: The structure of the repository is going through a lot of
46
> transitions. In particular, we want to get to a point eventually where the
57
> top-level directory has separate directories for the compiler, build-system,

src/contributing.md

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
# Contributing to Rust
22

3+
<!-- toc -->
4+
35
Thank you for your interest in contributing to Rust! There are many ways to
46
contribute, and we appreciate all of them.
57

6-
* [Feature Requests](#feature-requests)
7-
* [Bug Reports](#bug-reports)
8-
* [The Build System](./building/how-to-build-and-run.md)
9-
* [Pull Requests](#pull-requests)
10-
* [Writing Documentation](#writing-documentation)
11-
* [Issue Triage](#issue-triage)
12-
* [Out-of-tree Contributions](#out-of-tree-contributions)
13-
* [Helpful Links and Information](#helpful-links-and-information)
14-
158
If you have questions, please make a post on [internals.rust-lang.org][internals] or
169
hop on the [Rust Discord server][rust-discord] or [Rust Zulip server][rust-zulip].
1710

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

427423
[rdg]: https://rustc-dev-guide.rust-lang.org/
428424
[rdgrepo]: https://github.com/rust-lang/rustc-dev-guide

src/debugging-support-in-rustc.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Debugging support in the Rust compiler
22

3+
<!-- toc -->
4+
35
This document explains the state of debugging tools support in the Rust compiler (rustc).
46
The document gives an overview of debugging tools like GDB, LLDB etc. and infrastructure
57
around Rust compiler to debug Rust code. If you want to learn how to debug the Rust compiler

src/diagnostics.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Errors and Lints
22

3+
<!-- toc -->
4+
35
A lot of effort has been put into making `rustc` have great error messages.
46
This chapter is about how to emit compile errors and lints from the compiler.
57

src/getting-started.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Getting Started
22

3+
<!-- toc -->
4+
35
This documentation is _not_ intended to be comprehensive; it is meant to be a
46
quick guide for the most useful things. For more information, [see this
57
chapter on how to build and run the compiler](./building/how-to-build-and-run.md).

src/git.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Using Git
22

3+
<!-- toc -->
4+
35
The Rust project uses [Git] to manage its source code. In order to
46
contribute, you'll need some familiarity with its features so that your changes
57
can be incorporated into the compiler.

src/hir.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# The HIR
22

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

21-
### Out-of-band storage and the `Crate` type
23+
## Out-of-band storage and the `Crate` type
2224

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

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

69-
### Identifiers in the HIR
71+
## Identifiers in the HIR
7072

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

84-
### The HIR Map
86+
## The HIR Map
8587

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

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

127-
### HIR Bodies
129+
## HIR Bodies
128130

129131
A [`rustc_hir::Body`] represents some kind of executable code, such as the body
130132
of a function/closure or the definition of a constant. Bodies are

src/llvm-coverage-instrumentation.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# LLVM Source-Based Code Coverage
22

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

35-
### Rust symbol mangling
37+
## Rust symbol mangling
3638

3739
`-Z instrument-coverage` automatically enables Rust symbol mangling `v0` (as
3840
if the user specified `-Z symbol-mangling-version=v0` option when invoking

src/macro-expansion.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Macro expansion
22

3+
<!-- toc -->
4+
35
> `rustc_ast`, `rustc_expand`, and `rustc_builtin_macros` are all undergoing
46
> refactoring, so some of the links in this chapter may be broken.
57

src/mir/construction.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# THIR and MIR construction
22

3+
<!-- toc -->
4+
35
The lowering of [HIR] to [MIR] occurs for the following (probably incomplete)
46
list of items:
57

src/mir/dataflow.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Dataflow Analysis
22

3+
<!-- toc -->
4+
35
If you work on the MIR, you will frequently come across various flavors of
46
[dataflow analysis][wiki]. `rustc` uses dataflow to find uninitialized
57
variables, determine what variables are live across a generator `yield`

src/mir/index.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# The MIR (Mid-level IR)
22

3+
<!-- toc -->
4+
35
MIR is Rust's _Mid-level Intermediate Representation_. It is
46
constructed from [HIR](../hir.html). MIR was introduced in
57
[RFC 1211]. It is a radically simplified form of Rust that is used for

src/miri.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Miri
22

3+
<!-- toc -->
4+
35
Miri (**MIR** **I**nterpreter) is a virtual machine for executing MIR without
46
compiling to machine code. It is usually invoked via `tcx.const_eval_*` functions.
57

src/name-resolution.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Name resolution
22

3+
<!-- toc -->
4+
35
In the previous chapters, we saw how the AST is built with all macros expanded.
46
We saw how doing that requires doing some name resolution to resolve imports
57
and macro names. In this chapter, we show how this is actually done and more.

src/overview.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Overview of the Compiler
22

3+
<!-- toc -->
4+
35
This chapter is about the overall process of compiling a program -- how
46
everything fits together.
57

src/panic-implementation.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
### Panicking in rust ###
1+
# Panicking in rust
22

3-
#### Step 1: Invocation of the `panic!` macro.
3+
<!-- toc -->
4+
5+
## Step 1: Invocation of the `panic!` macro.
46

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

10-
##### core definition of panic!
12+
### core definition of panic!
1113

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

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

60-
##### std implementation of panic!
62+
### std implementation of panic!
6163

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

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

86-
#### Step 2: The panic runtime
88+
## Step 2: The panic runtime
8789

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

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

94-
`panic_unwind` is the more interesting case.
96+
`panic_unwind` is the more interesting case.
9597

9698
In its implementation of `__rust_start_panic`, we take the `usize`, convert
9799
it back to a `*mut &mut dyn BoxMeUp`, dereference it, and call `box_me_up`

src/profile-guided-optimization.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Profile Guided Optimization
22

3+
<!-- toc -->
4+
35
`rustc` supports doing profile-guided optimization (PGO).
46
This chapter describes what PGO is and how the support for it is
57
implemented in `rustc`.

src/queries/incremental-compilation-in-detail.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Incremental Compilation In Detail
22

3+
<!-- toc -->
4+
35
The incremental compilation scheme is, in essence, a surprisingly
46
simple extension to the overall query system. It relies on the fact that:
57

src/queries/incremental-compilation.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Incremental compilation
22

3+
<!-- toc -->
4+
35
The incremental compilation scheme is, in essence, a surprisingly
46
simple extension to the overall query system. We'll start by describing
57
a slightly simplified variant of the real thing – the "basic algorithm" –

src/queries/profiling.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Profiling Queries
2+
3+
<!-- toc -->
4+
25
In an effort to support _incremental compilation_, the latest design of the Rust
36
compiler consists of a _query-based_ model.
47

src/queries/query-evaluation-model-in-detail.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
# The Query Evaluation Model in Detail
44

5+
<!-- toc -->
6+
57
This chapter provides a deeper dive into the abstract model queries are built on.
68
It does not go into implementation details but tries to explain
79
the underlying logic. The examples here, therefore, have been stripped down and

src/rustdoc-internals.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Rustdoc internals
22

3+
<!-- toc -->
4+
35
This page describes rustdoc's passes and modes. For an overview of rustdoc,
46
see [`rustdoc`](./rustdoc.md).
57

src/salsa.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# How Salsa works
22

3+
<!-- toc -->
4+
35
This chapter is based on the explanation given by Niko Matsakis in this
46
[video](https://www.youtube.com/watch?v=_muY4HjSqVw) about
57
[Salsa](https://github.com/salsa-rs/salsa). To find out more you may

0 commit comments

Comments
 (0)