Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
7e6f472
docs: Clarify Neovim workspace path setup
aland-omed Jul 22, 2026
fcd6175
Add documentation for some `rustc_type_ir` macros
Jamesbarford Jul 22, 2026
45eb8ca
ordering of sections, typos and removed incorrect statement
Jamesbarford Aug 11, 2026
23016c0
Give better examples of how to run `x`
jyn514 Aug 14, 2026
38d3100
Merge pull request #2964 from jyn514/x-fixups
jyn514 Aug 14, 2026
93ea5ae
fix some typos and update some links
jyn514 Aug 14, 2026
97869b0
Merge pull request #2965 from jyn514/typo-fixes
jyn514 Aug 14, 2026
7d2d9ca
Explicitly mark stub chapters in the table of contents
jyn514 Aug 14, 2026
1f9f694
Merge pull request #2939 from Jamesbarford/chore/rustc_type_ir-macro-…
lcnr Aug 14, 2026
c9aea25
Merge pull request #2967 from jyn514/stubs
jieyouxu Aug 14, 2026
429ccaa
Fix orphaned chapters
jyn514 Aug 14, 2026
86a906c
Merge pull request #2968 from jyn514/orphaned-chapters
jyn514 Aug 14, 2026
cf32f30
Cleanup bootstrap references
jyn514 Aug 14, 2026
8e4a9b8
Merge pull request #2966 from jyn514/bootstrap-docs
jyn514 Aug 14, 2026
e2332ad
Update offload docs for macro and third pass
Sa4dUs Aug 14, 2026
8a88516
Merge pull request #2969 from Sa4dUs/offload-generic-example
ZuseZ4 Aug 14, 2026
05a0dff
Prepare for merging from rust-lang/rust
invalid-email-address Aug 17, 2026
830bc90
Merge ref '2c39ff499469' from rust-lang/rust
invalid-email-address Aug 17, 2026
8fcce54
bump `mdbook-linkcheck2` in CI
Walnut356 Aug 17, 2026
0f19fec
Merge pull request #2971 from Walnut356/linkcheck_bump
tshepang Aug 17, 2026
7ba4564
Merge pull request #2970 from rust-lang/rustc-pull
tshepang Aug 17, 2026
bee090e
Use .md links consistently
jyn514 Aug 14, 2026
5d0b6b6
Document debuginfo `repr` directive
Walnut356 Jul 28, 2026
3d4e2be
Merge pull request #2972 from jyn514/md-links
tshepang Aug 17, 2026
ee19916
Merge pull request #2947 from Walnut356/di_test
jyn514 Aug 17, 2026
0d0d69a
Merge pull request #2938 from aland-omed/docs/neovim-workspace-folder…
jyn514 Aug 17, 2026
e649400
Update compiler-debugging.md
amandasystems Aug 17, 2026
f1605e7
Update dataflow.md to mention region graphs
amandasystems Apr 30, 2024
8c91e56
Add images of graphs
amandasystems May 2, 2024
4d4bbbc
Accept @lqd's nit about SCC edges
amandasystems Aug 1, 2024
dcdd9db
Update src/mir/dataflow.md
amandasystems Aug 1, 2024
8fc5ac4
Move Borrow checker debugging into its own chapter
amandasystems Aug 17, 2026
ee3b1c6
Merge pull request #1969 from amandasystems/master
tshepang Aug 18, 2026
f7c50ad
some room to breath
tshepang Aug 15, 2026
a4d9ca4
sembr src/generic-parameters-summary.md
tshepang Aug 15, 2026
d15d748
improve generic-parameters-summary.md
tshepang Aug 15, 2026
0e7fdd6
typo
tshepang Aug 15, 2026
5427bea
avoid inline external links
tshepang Aug 15, 2026
8996353
sembr src/bug-fix-procedure.md
tshepang Aug 15, 2026
aa53e20
improve bug-fix-procedure.md
tshepang Aug 15, 2026
db79d47
sembr src/part-4-intro.md
tshepang Aug 15, 2026
950dc49
sembr src/hir-typeck/coercions.md
tshepang Aug 18, 2026
115e0aa
improve hir-typeck/coercions.md
tshepang Aug 19, 2026
2b1bc75
sembr src/hir-typeck/method-lookup.md
tshepang Aug 19, 2026
bd7959a
improve hir-typeck/method-lookup.md
tshepang Aug 19, 2026
b74db9e
sembr src/backend/lowering-mir.md
tshepang Aug 19, 2026
7c939cb
reflow
tshepang Aug 19, 2026
a5660c0
sembr src/backend/implicit-caller-location.md
tshepang Aug 19, 2026
66e0c32
reflow
tshepang Aug 19, 2026
f3337e9
sembr src/backend/codegen.md
tshepang Aug 19, 2026
b5fe587
improve backend/codegen.md
tshepang Aug 19, 2026
a6c3c87
sembr src/backend/monomorph.md
tshepang Aug 19, 2026
e2fcd00
reflow
tshepang Aug 19, 2026
d58e4b4
fix redirect
tshepang Aug 19, 2026
6b570c7
sembr src/licenses.md
tshepang Aug 19, 2026
f3d129b
Merge pull request #2976 from rust-lang/tshepang/misc
tshepang Aug 19, 2026
042ab74
sembr src/borrow-check.md
tshepang Aug 19, 2026
1c0c2e9
reflow
tshepang Aug 19, 2026
f866e81
sembr src/borrow-check/debugging.md
tshepang Aug 19, 2026
102722d
reflow
tshepang Aug 19, 2026
4275a3c
sembr src/compiler-debugging.md
tshepang Aug 19, 2026
7496ac1
sembr src/debuginfo/testing.md
tshepang Aug 19, 2026
ca9ae07
improve debuginfo/testing.md
tshepang Aug 19, 2026
835c839
track freshness
tshepang Aug 19, 2026
e90d717
sembr src/debuginfo/lldb-visualizers.md
tshepang Aug 19, 2026
4665ec2
reflow
tshepang Aug 19, 2026
e8013ea
Merge pull request #2977 from rust-lang/tshepang/misc
tshepang Aug 19, 2026
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 src/doc/rustc-dev-guide/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main
pull_request:
schedule:
# Run multiple times a day as the successfull cached links are not checked every time.
# Run multiple times a day as the successful cached links are not checked every time.
- cron: "0 */8 * * *"

jobs:
Expand All @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
env:
MDBOOK_VERSION: 0.5.2
MDBOOK_LINKCHECK2_VERSION: 0.11.0
MDBOOK_LINKCHECK2_VERSION: 0.13.0
MDBOOK_MERMAID_VERSION: 0.17.0
MDBOOK_OUTPUT__LINKCHECK__FOLLOW_WEB_LINKS: ${{ github.event_name != 'pull_request' }}
DEPLOY_DIR: book/html
Expand Down
3 changes: 3 additions & 0 deletions src/doc/rustc-dev-guide/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ level = 0

[output.linkcheck]
command = "ci/linkcheck.sh"
require-md-extension = true
follow-web-links = true
exclude = [
"crates\\.io",
Expand Down Expand Up @@ -57,6 +58,7 @@ cache-timeout = 90000
warning-policy = "error"

[output.html.redirect]
"/backend/inline-asm.html" = "/asm.html"
"/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"
Expand All @@ -77,6 +79,7 @@ warning-policy = "error"
"/early_late_parameters.html" = "early-late-parameters.html"
"/generic_parameters_summary.html" = "generic-parameters-summary.html"
"/implementing_new_features.html" = "implementing-new-features.html"
"/llm-guidance/index.html" = "/llm-guidance.html"
"/miri.html" = "const-eval/interpret.html"
"/profiling/with_perf.html" = "with-perf.html"
"/profiling/with_rustc_perf.html" = "with-rustc-perf.html"
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustc-dev-guide/rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e64c8a664d9da54fc239cd4404cbf67f0d624326
2c39ff499469be916d4e45506d1afed69bbaddb7
14 changes: 8 additions & 6 deletions src/doc/rustc-dev-guide/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@
- [Fuchsia](./tests/ecosystem-test-jobs/fuchsia.md)
- [Rust for Linux](./tests/ecosystem-test-jobs/rust-for-linux.md)
- [Codegen backend testing](./tests/codegen-backend-tests/intro.md)
- [Cranelift codegen backend](./tests/codegen-backend-tests/cg_clif.md)
- [Cranelift codegen backend (stub)](./tests/codegen-backend-tests/cg_clif.md)
- [GCC codegen backend](./tests/codegen-backend-tests/cg_gcc.md)
- [Performance testing](./tests/perf.md)
- [Autodiff CI job](./tests/autodiff-ci-job.md)
- [Pre-stabilization CI job for the next solver and polonius alpha](./tests/x86_64-gnu-next-trait-solver-polonius-ci-job.md)
- [Parallel frontend CI job](./tests/optional-x86_64-gnu-parallel-frontend.md)
- [Standard library semver breakage test](./tests/stdlib-semver-check.md)
- [Misc info](./tests/misc.md)
- [Debugging the compiler](./compiler-debugging.md)
Expand Down Expand Up @@ -108,7 +109,7 @@
- [Rustdoc internals](./rustdoc-internals.md)
- [Search](./rustdoc-internals/search.md)
- [The `rustdoc-html` test suite](./rustdoc-internals/rustdoc-html-test-suite.md)
- [The `rustdoc-gui` test suite](./rustdoc-internals/rustdoc-gui-test-suite.md)
- [The `rustdoc-gui` test suite (stub)](./rustdoc-internals/rustdoc-gui-test-suite.md)
- [The `rustdoc-json` test suite](./rustdoc-internals/rustdoc-json-test-suite.md)
- [GPU offload internals](./offload/internals.md)
- [Installation](./offload/installation.md)
Expand Down Expand Up @@ -225,8 +226,9 @@
- [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)
- [Error reporting (stub)](./borrow-check/region-inference/error-reporting.md)
- [Two-phase-borrows](./borrow-check/two-phase-borrows.md)
- [Debugging the borrow checker](./borrow-check/debugging.md)
- [Closure capture inference](./closure.md)
- [Async closures/"coroutine-closures"](coroutine-closures.md)

Expand All @@ -249,12 +251,12 @@
- [LLVM codegen](./debuginfo/llvm-codegen.md)
- [Debugger internals](./debuginfo/debugger-internals.md)
- [LLDB internals](./debuginfo/lldb-internals.md)
- [GDB internals](./debuginfo/gdb-internals.md)
- [GDB internals (stub)](./debuginfo/gdb-internals.md)
- [Debugger visualizers](./debuginfo/debugger-visualizers.md)
- [LLDB - Python Providers](./debuginfo/lldb-visualizers.md)
- [GDB - Python Providers](./debuginfo/gdb-visualizers.md)
- [CDB - Natvis](./debuginfo/natvis-visualizers.md)
- [Testing](./debuginfo/testing.md)
- [CDB - Natvis (stub)](./debuginfo/natvis-visualizers.md)
- [Testing (stub)](./debuginfo/testing.md)
- [(Lecture notes) Debugging support in the Rust compiler](./debugging-support-in-rustc.md)
- [Libraries and metadata](./backend/libs-and-metadata.md)
- [Profile-guided optimization](./profile-guided-optimization.md)
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustc-dev-guide/src/about-this-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ There are several parts to this guide:
1. [Appendices][p9] at the end with useful reference information.
There are a few of these with different information, including a glossary.

[p1]: ./building/how-to-build-and-run.html
[p1]: ./building/how-to-build-and-run.md
[p2]: ./contributing.md
[p3]: ./building/bootstrapping/intro.md
[p4]: ./part-2-intro.md
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustc-dev-guide/src/appendix/background.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ don't actually do this in `rustc` though!):
Check out the subtyping chapter from the
[Rust Nomicon](https://doc.rust-lang.org/nomicon/subtyping.html).

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

<a id="free-vs-bound"></a>
Expand Down
24 changes: 12 additions & 12 deletions src/doc/rustc-dev-guide/src/appendix/code-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ Item | Kind | Short description | Chapter |
`Ty<'tcx>` | struct | This is the internal representation of a type used for type checking | [Type checking] | [compiler/rustc_middle/src/ty/mod.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.Ty.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] | [compiler/rustc_middle/src/ty/context.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html)

[The HIR]: ../hir.html
[Identifiers in the HIR]: ../hir.html#hir-id
[The parser]: ../the-parser.html
[The Rustc Driver and Interface]: ../rustc-driver/intro.html
[Type checking]: ../hir-typeck/summary.html
[The `ty` modules]: ../ty.html
[Rustdoc]: ../rustdoc.html
[Emitting Diagnostics]: ../diagnostics.html
[Macro expansion]: ../macro-expansion.html
[Name resolution]: ../name-resolution.html
[Parameter Environment]: ../typing-parameter-envs.html
[Trait Solving: Goals and Clauses]: ../traits/goals-and-clauses.html#domain-goals
[The HIR]: ../hir.md
[Identifiers in the HIR]: ../hir.md#hir-id
[The parser]: ../the-parser.md
[The Rustc Driver and Interface]: ../rustc-driver/intro.md
[Type checking]: ../hir-typeck/summary.md
[The `ty` modules]: ../ty.md
[Rustdoc]: ../rustdoc.md
[Emitting Diagnostics]: ../diagnostics.md
[Macro expansion]: ../macro-expansion.md
[Name resolution]: ../name-resolution.md
[Parameter Environment]: ../typing-parameter-envs.md
[Trait Solving: Goals and Clauses]: ../traits/goals-and-clauses.md#domain-goals
2 changes: 1 addition & 1 deletion src/doc/rustc-dev-guide/src/appendix/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Term | Meaning
<span id="span">span</span> | A location in the user's source code, used for error reporting primarily. These are like a file-name/line-number/column tuple on steroids: they carry a start/end point, and also track macro expansions and compiler desugaring. All while being packed into a few bytes (really, it's an index into a table). See the [`Span`] datatype for more.
<span id="subst">subst 👎</span> | The act of _substituting_ the generic parameters inside of a type, constant expression, etc. with concrete generic arguments by supplying [substs](#substs). Nowadays referred to as _instantiating_ in the compiler.
<span id="substs">substs 👎</span> | The _substitutions_ for a given generic item (e.g. the `i32`, `u32` in `HashMap<i32, u32>`). Nowadays referred to as the list of _generic arguments_ in the compiler (but note that strictly speaking these two concepts differ, see the literature).
<span id="sysroot">sysroot</span> | The directory for build artifacts that are loaded by the compiler at runtime. ([see more](../building/bootstrapping/what-bootstrapping-does.html#what-is-a-sysroot))
<span id="sysroot">sysroot</span> | The directory for build artifacts that are loaded by the compiler at runtime. ([see more](../building/bootstrapping/what-bootstrapping-does.md#what-is-a-sysroot))
<span id="tag">tag</span> | The "tag" of an enum/generator encodes the [discriminant](#discriminant) of the active variant/state. Tags can either be "direct" (simply storing the discriminant in a field) or use a ["niche"](#niche).
<span id="tait">TAIT</span> | Short for _type-alias `impl Trait`_. Introduced in [RFC 2515].
<span id="tcx">`tcx`</span> | Standard variable name for the "typing context" (`TyCtxt`), main data structure of the compiler. ([see more](../ty.md))
Expand Down
66 changes: 32 additions & 34 deletions src/doc/rustc-dev-guide/src/backend/codegen.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ Usually, rustc uses LLVM for code generation,
but there is also support for [Cranelift] and [GCC].
The key is that rustc doesn't implement codegen itself.
It's worth noting, though, that in the Rust source code,
many parts of the backend have `codegen` in their names
(there are no hard boundaries).
many parts of the backend have `codegen` in their names (there are no hard boundaries).

[Cranelift]: https://github.com/bytecodealliance/wasmtime/tree/main/cranelift
[GCC]: https://github.com/rust-lang/rustc_codegen_gcc
Expand All @@ -20,56 +19,55 @@ many parts of the backend have `codegen` in their names
## What is LLVM?

[LLVM](https://llvm.org) is "a collection of modular and reusable compiler and
toolchain technologies". In particular, the LLVM project contains a pluggable
toolchain technologies".
In particular, the LLVM project contains a pluggable
compiler backend (also called "LLVM"), which is used by many compiler projects,
including the `clang` C compiler and our beloved `rustc`.

LLVM takes input in the form of LLVM IR. It is basically assembly code with
additional low-level types and annotations added. These annotations are helpful
for doing optimizations on the LLVM IR and outputted machine code. The end
result of all this is (at long last) something executable (e.g. an ELF object,
LLVM takes input in the form of LLVM IR.
It is basically assembly code with additional low-level types and annotations added.
These annotations are helpful for doing optimizations on the LLVM IR and outputted machine code.
The end result of all this is (at long last) something executable (e.g. an ELF object,
an EXE, or wasm).

There are a few benefits to using LLVM:

- We don't have to write a whole compiler backend. This reduces implementation
and maintenance burden.
- We don't have to write a whole compiler backend.
This reduces implementation and maintenance burden.
- We benefit from the large suite of advanced optimizations that the LLVM
project has been collecting.
- We can automatically compile Rust to any of the platforms for which LLVM has
support. For example, as soon as LLVM added support for wasm, voila! rustc,
clang, and a bunch of other languages were able to compile to wasm! (Well,
there was some extra stuff to be done, but we were 90% there anyway).
- We and other compiler projects benefit from each other. For example, when the
[Spectre and Meltdown security vulnerabilities][spectre] were discovered,
- We can automatically compile Rust to any of the platforms for which LLVM has support.
For example, as soon as LLVM added support for wasm, voila!
rustc, clang, and a bunch of other languages were able to compile to wasm!
(Well, there was some extra stuff to be done, but we were 90% there anyway).
- We and other compiler projects benefit from each other.
For example, when the [Spectre and Meltdown security vulnerabilities][spectre] were discovered,
only LLVM needed to be patched.

[spectre]: https://meltdownattack.com/

## Running LLVM, linking, and metadata generation

Once LLVM IR for all of the functions and statics, etc is built, it is time to
start running LLVM and its optimization passes. LLVM IR is grouped into
"modules". Multiple "modules" can be codegened at the same time to aid in
multi-core utilization. These "modules" are what we refer to as _codegen
units_. These units were established way back during monomorphization
collection phase.
start running LLVM and its optimization passes.
LLVM IR is grouped into "modules".
Multiple "modules" can be codegened at the same time to aid in multi-core utilization.
These "modules" are what we refer to as _codegen units_.
These units were established way back during monomorphization collection phase.

Once LLVM produces objects from these modules, these objects are passed to the
linker along with, optionally, the metadata object and an archive or an
executable is produced.

It is not necessarily the codegen phase described above that runs the
optimizations. With certain kinds of LTO, the optimization might happen at the
linking time instead. It is also possible for some optimizations to happen
before objects are passed on to the linker and some to happen during the
linking.

This all happens towards the very end of compilation. The code for this can be
found in [`rustc_codegen_ssa::back`][ssaback] and
[`rustc_codegen_llvm::back`][llvmback]. Sadly, this piece of code is not
really well-separated into LLVM-dependent code; the [`rustc_codegen_ssa`][ssa]
contains a fair amount of code specific to the LLVM backend.
linker along with, optionally, the metadata object and an archive or an executable is produced.

It is not necessarily the codegen phase described above that runs the optimizations.
With certain kinds of LTO, the optimization might happen during linking time instead.
It is also possible for some optimizations to happen
before objects are passed on to the linker and some to happen during the linking.

This all happens towards the very end of compilation.
The code for this can be found in [`rustc_codegen_ssa::back`][ssaback] and
[`rustc_codegen_llvm::back`][llvmback].
Sadly, this piece of code is not really well-separated into LLVM-dependent code;
the [`rustc_codegen_ssa`][ssa] contains a fair amount of code specific to the LLVM backend.

Once these components are done with their work you end up with a number of
files in your filesystem corresponding to the outputs you have requested.
Expand Down
Loading
Loading