Skip to content

Commit

Permalink
Merge branch 'patch-1' of github.com:hbina/rustc-guide into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
hbina committed Nov 21, 2019
2 parents b3aa636 + cdf5301 commit e4c4156
Show file tree
Hide file tree
Showing 8 changed files with 637 additions and 42 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ invoke this link checker, otherwise it will emit a warning saying it couldn't
be found.

```bash
> cargo install mdbook-linkcheck
cargo install mdbook-linkcheck
```

You will need `mdbook` version `>= 0.2`. `linkcheck` will be run automatically
Expand Down
4 changes: 2 additions & 2 deletions src/closure.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Let's say the above is the content of a file called `immut.rs`. If we compile
`immut.rs` using the following command. The [`-Zdump-mir=all`][dump-mir] flag will cause
`rustc` to generate and dump the [MIR][mir] to a directory called `mir_dump`.
```console
> rustc +stage1 immut.rs -Zdump-mir=all
rustc +stage1 immut.rs -Zdump-mir=all
```

[mir]: ./mir/index.md
Expand Down Expand Up @@ -145,7 +145,7 @@ codebase. For closures specifically, set the `RUST_LOG` env variable as below an
output in a file:

```console
> RUST_LOG=rustc_typeck::check::upvar rustc +stage1 -Zdump-mir=all \
RUST_LOG=rustc_typeck::check::upvar rustc +stage1 -Zdump-mir=all \
<.rs file to compile> 2> <file where the output will be dumped>
```

Expand Down
62 changes: 62 additions & 0 deletions src/compiler-documenting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Documenting rustc

You might want to build documentation of the various components
available like the standard library. There’s two ways to go about this.
You can run rustdoc directly on the file to make sure the HTML is
correct, which is fast. Alternatively, you can build the documentation
as part of the build process through x.py. Both are viable methods
since documentation is more about the content.

## Document everything

```bash
./x.py doc
```

## If you want to avoid the whole Stage 2 build

```bash
./x.py doc --stage 1
```

First the compiler and rustdoc get built to make sure everything is okay
and then it documents the files.

## Document specific components

```bash
./x.py doc src/doc/book
./x.py doc src/doc/nomicon
./x.py doc src/doc/book src/libstd
```

Much like individual tests or building certain components you can build only
the documentation you want.

## Document internal rustc items

Compiler documentation is not built by default. There's a flag in
config.toml for achieving the same.
But, when enabled, compiler documentation does include internal items.

Next open up config.toml and make sure these two lines are set to true:

```bash
docs = true
compiler-docs = true
```

When you want to build the compiler docs as well run this command:

```bash
./x.py doc
```

This will see that the docs and compiler-docs options are set to true
and build the normally hidden compiler docs!

### Compiler Documentation

The documentation for the rust components are found at [rustc doc].

[rustc doc]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/
2 changes: 1 addition & 1 deletion src/hir.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ You can view the HIR representation of your code by passing the
`-Zunpretty=hir-tree` flag to rustc:

```bash
> cargo rustc -- -Zunpretty=hir-tree
cargo rustc -- -Zunpretty=hir-tree
```

### Out-of-band storage and the `Crate` type
Expand Down
Loading

0 comments on commit e4c4156

Please sign in to comment.