Skip to content

Commit 2ef6c92

Browse files
JohnTitormark-i-m
authored andcommitted
Fix links and paths
1 parent 702f224 commit 2ef6c92

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

src/appendix/code-index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ compiler.
66

77
Item | Kind | Short description | Chapter | Declaration
88
----------------|----------|-----------------------------|--------------------|-------------------
9-
`BodyId` | struct | One of four types of HIR node identifiers | [Identifiers in the HIR] | [src/librustc/hir/mod.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/struct.BodyId.html)
9+
`BodyId` | struct | One of four types of HIR node identifiers | [Identifiers in the HIR] | [src/librustc_hir/hir.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/struct.BodyId.html)
1010
`Compiler` | struct | Represents a compiler session and can be used to drive a compilation. | [The Rustc Driver and Interface] | [src/librustc_interface/interface.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/interface/struct.Compiler.html)
11-
`ast::Crate` | struct | A syntax-level representation of a parsed crate | [The parser] | [src/librustc/hir/mod.rs](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/ast/struct.Crate.html)
12-
`hir::Crate` | struct | A more abstract, compiler-friendly form of a crate's AST | [The Hir] | [src/librustc/hir/mod.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/struct.Crate.html)
13-
`DefId` | struct | One of four types of HIR node identifiers | [Identifiers in the HIR] | [src/librustc/hir/def_id.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/def_id/struct.DefId.html)
11+
`ast::Crate` | struct | A syntax-level representation of a parsed crate | [The parser] | [src/libsyntax/ast.rs](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/ast/struct.Crate.html)
12+
`rustc_hir::Crate` | struct | A more abstract, compiler-friendly form of a crate's AST | [The Hir] | [src/librustc_hir/hir.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/struct.Crate.html)
13+
`DefId` | struct | One of four types of HIR node identifiers | [Identifiers in the HIR] | [src/librustc_hir/def_id.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/def_id/struct.DefId.html)
1414
`DiagnosticBuilder` | struct | A struct for building up compiler diagnostics, such as errors or lints | [Emitting Diagnostics] | [src/librustc_errors/diagnostic_builder.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.DiagnosticBuilder.html)
1515
`DocContext` | struct | A state container used by rustdoc when crawling through a crate to gather its documentation | [Rustdoc] | [src/librustdoc/core.rs](https://github.com/rust-lang/rust/blob/master/src/librustdoc/core.rs)
16-
`HirId` | struct | One of four types of HIR node identifiers | [Identifiers in the HIR] | [src/librustc/hir/mod.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/struct.HirId.html)
16+
`HirId` | struct | One of four types of HIR node identifiers | [Identifiers in the HIR] | [src/librustc_hir/hir_id.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir_id/struct.HirId.html)
1717
`NodeId` | struct | One of four types of HIR node identifiers. Being phased out | [Identifiers in the HIR] | [src/libsyntax/ast.rs](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/ast/struct.NodeId.html)
1818
`P` | struct | An owned immutable smart pointer. By contrast, `&T` is not owned, and `Box<T>` is not immutable. | None | [src/syntax/ptr.rs](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/ptr/struct.P.html)
1919
`ParamEnv` | struct | Information about generic parameters or `Self`, useful for working with associated or generic items | [Parameter Environment] | [src/librustc/ty/mod.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.ParamEnv.html)

src/hir.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ data structure basically just contains the root module, the HIR
2727
`Crate` structure contains a number of maps and other things that
2828
serve to organize the content of the crate for easier access.
2929

30-
[`Crate`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/struct.Crate.html
30+
[`Crate`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/struct.Crate.html
3131

3232
For example, the contents of individual items (e.g. modules,
3333
functions, traits, impls, etc) in the HIR are not immediately
@@ -45,7 +45,7 @@ struct) would only have the **`ItemId`** `I` of `bar()`. To get the
4545
details of the function `bar()`, we would lookup `I` in the
4646
`items` map.
4747

48-
[`Mod`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/struct.Mod.html
48+
[`Mod`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/struct.Mod.html
4949

5050
One nice result from this representation is that one can iterate
5151
over all items in the crate by iterating over the key-value pairs
@@ -55,14 +55,14 @@ as well as "bodies" (explained below).
5555

5656
The other reason to set up the representation this way is for better
5757
integration with incremental compilation. This way, if you gain access
58-
to an [`&hir::Item`] (e.g. for the mod `foo`), you do not immediately
58+
to an [`&rustc_hir::Item`] (e.g. for the mod `foo`), you do not immediately
5959
gain access to the contents of the function `bar()`. Instead, you only
6060
gain access to the **id** for `bar()`, and you must invoke some
6161
function to lookup the contents of `bar()` given its id; this gives
6262
the compiler a chance to observe that you accessed the data for
6363
`bar()`, and then record the dependency.
6464

65-
[`&hir::Item`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/struct.Item.html
65+
[`&rustc_hir::Item`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/struct.Item.html
6666

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

@@ -97,9 +97,9 @@ sorts of identifiers in active use:
9797
tree causes the [`NodeId`]s of all subsequent code in the crate to change.
9898
This is terrible for incremental compilation, as you can perhaps imagine.
9999

100-
[`DefId`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/def_id/struct.DefId.html
101-
[`HirId`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/struct.HirId.html
102-
[`BodyId`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/struct.BodyId.html
100+
[`DefId`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/def_id/struct.DefId.html
101+
[`HirId`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir_id/struct.HirId.html
102+
[`BodyId`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/struct.BodyId.html
103103
[`NodeId`]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/ast/struct.NodeId.html
104104

105105
We also have an internal map to go from `DefId` to what’s called "Def path". "Def path" is like a
@@ -141,9 +141,9 @@ that `n` must be some HIR expression, you can do
141141
[`&hir::Expr`][Expr], panicking if `n` is not in fact an expression.
142142

143143
[find]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/map/struct.Map.html#method.find
144-
[`Node`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/enum.Node.html
144+
[`Node`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/enum.Node.html
145145
[expect_expr]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/map/struct.Map.html#method.expect_expr
146-
[Expr]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/struct.Expr.html
146+
[Expr]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/struct.Expr.html
147147

148148
Finally, you can use the HIR map to find the parents of nodes, via
149149
calls like [`tcx.hir.get_parent_node(n)`][get_parent_node].
@@ -152,14 +152,14 @@ calls like [`tcx.hir.get_parent_node(n)`][get_parent_node].
152152

153153
### HIR Bodies
154154

155-
A [`hir::Body`] represents some kind of executable code, such as the body
155+
A [`rustc_hir::Body`] represents some kind of executable code, such as the body
156156
of a function/closure or the definition of a constant. Bodies are
157157
associated with an **owner**, which is typically some kind of item
158158
(e.g. an `fn()` or `const`), but could also be a closure expression
159159
(e.g. `|x, y| x + y`). You can use the HIR map to find the body
160160
associated with a given def-id ([`maybe_body_owned_by`]) or to find
161161
the owner of a body ([`body_owner_def_id`]).
162162

163-
[`hir::Body`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/struct.Body.html
163+
[`rustc_hir::Body`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/struct.Body.html
164164
[`maybe_body_owned_by`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/map/struct.Map.html#method.maybe_body_owned_by
165165
[`body_owner_def_id`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/map/struct.Map.html#method.body_owner_def_id

src/rustdoc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ is the `impl Clean<Crate> for visit_ast::RustdocVisitor`, which is called by
8484

8585
You see, I actually lied a little earlier: There's another AST transformation
8686
that happens before the events in `clean/mod.rs`. In `visit_ast.rs` is the
87-
type `RustdocVisitor`, which *actually* crawls a `hir::Crate` to get the first
87+
type `RustdocVisitor`, which *actually* crawls a `rustc_hir::Crate` to get the first
8888
intermediate representation, defined in `doctree.rs`. This pass is mainly to
8989
get a few intermediate wrappers around the HIR types and to process visibility
9090
and inlining. This is where `#[doc(inline)]`, `#[doc(no_inline)]`, and

src/ty.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ quite a few modules and types for `Ty` in the compiler ([Ty documentation][ty]).
1515
[ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/index.html
1616

1717
The specific `Ty` we are referring to is [`rustc::ty::Ty`][ty_ty] (and not
18-
[`rustc::hir::Ty`][hir_ty]). The distinction is important, so we will discuss it first before going
18+
[`rustc_hir::Ty`][hir_ty]). The distinction is important, so we will discuss it first before going
1919
into the details of `ty::Ty`.
2020

2121
[ty_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/type.Ty.html
22-
[hir_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/struct.Ty.html
22+
[hir_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/struct.Ty.html
2323

24-
## `hir::Ty` vs `ty::Ty`
24+
## `rustc_hir::Ty` vs `ty::Ty`
2525

2626
The HIR in rustc can be thought of as the high-level intermediate representation. It is more or less
2727
the AST (see [this chapter](hir.md)) as it represents the
@@ -30,7 +30,7 @@ representation of types, but in reality it reflects more of what the user wrote,
3030
wrote so as to represent that type.
3131

3232
In contrast, `ty::Ty` represents the semantics of a type, that is, the *meaning* of what the user
33-
wrote. For example, `hir::Ty` would record the fact that a user used the name `u32` twice in their
33+
wrote. For example, `rustc_hir::Ty` would record the fact that a user used the name `u32` twice in their
3434
program, but the `ty::Ty` would record the fact that both usages refer to the same type.
3535

3636
**Example: `fn foo(x: u32) → u32 { }`** In this function we see that `u32` appears twice. We know
@@ -49,26 +49,26 @@ look like `fn foo<'a>(x: &'a u32) -> &'a u32)`.
4949
In the HIR level, these things are not spelled out and you can say the picture is rather incomplete.
5050
However, at the `ty::Ty` level, these details are added and it is complete. Moreover, we will have
5151
exactly one `ty::Ty` for a given type, like `u32`, and that `ty::Ty` is used for all `u32`s in the
52-
whole program, not a specific usage, unlike `hir::Ty`.
52+
whole program, not a specific usage, unlike `rustc_hir::Ty`.
5353

5454
Here is a summary:
5555

56-
| [`hir::Ty`][hir_ty] | [`ty::Ty`][ty_ty] |
56+
| [`rustc_hir::Ty`][hir_ty] | [`ty::Ty`][ty_ty] |
5757
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
5858
| Describe the *syntax* of a type: what the user wrote (with some desugaring). | Describe the *semantics* of a type: the meaning of what the user wrote. |
59-
| Each `hir::Ty` has its own spans corresponding to the appropriate place in the program. | Doesn’t correspond to a single place in the user’s program. |
60-
| `hir::Ty` has generics and lifetimes; however, some of those lifetimes are special markers like [`LifetimeName::Implicit`][implicit]. | `ty::Ty` has the full type, including generics and lifetimes, even if the user left them out |
61-
| `fn foo(x: u32) → u32 { }` - Two `hir::Ty` representing each usage of `u32`. Each has its own `Span`s, etc.- `hir::Ty` doesn’t tell us that both are the same type | `fn foo(x: u32) → u32 { }` - One `ty::Ty` for all instances of `u32` throughout the program.- `ty::Ty` tells us that both usages of `u32` mean the same type. |
62-
| `fn foo(x: &u32) -> &u32)`- Two `hir::Ty` again.- Lifetimes for the references show up in the `hir::Ty`s using a special marker, [`LifetimeName::Implicit`][implicit]. | `fn foo(x: &u32) -> &u32)`- A single `ty::Ty`.- The `ty::Ty` has the hidden lifetime param |
59+
| Each `rustc_hir::Ty` has its own spans corresponding to the appropriate place in the program. | Doesn’t correspond to a single place in the user’s program. |
60+
| `rustc_hir::Ty` has generics and lifetimes; however, some of those lifetimes are special markers like [`LifetimeName::Implicit`][implicit]. | `ty::Ty` has the full type, including generics and lifetimes, even if the user left them out |
61+
| `fn foo(x: u32) → u32 { }` - Two `rustc_hir::Ty` representing each usage of `u32`. Each has its own `Span`s, etc.- `rustc_hir::Ty` doesn’t tell us that both are the same type | `fn foo(x: u32) → u32 { }` - One `ty::Ty` for all instances of `u32` throughout the program.- `ty::Ty` tells us that both usages of `u32` mean the same type. |
62+
| `fn foo(x: &u32) -> &u32)`- Two `rustc_hir::Ty` again.- Lifetimes for the references show up in the `rustc_hir::Ty`s using a special marker, [`LifetimeName::Implicit`][implicit]. | `fn foo(x: &u32) -> &u32)`- A single `ty::Ty`.- The `ty::Ty` has the hidden lifetime param |
6363

64-
[implicit]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/enum.LifetimeName.html#variant.Implicit
64+
[implicit]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/enum.LifetimeName.html#variant.Implicit
6565

6666
**Order** HIR is built directly from the AST, so it happens before any `ty::Ty` is produced. After
6767
HIR is built, some basic type inference and type checking is done. During the type inference, we
6868
figure out what the `ty::Ty` of everything is and we also check if the type of something is
6969
ambiguous. The `ty::Ty` then, is used for type checking while making sure everything has the
7070
expected type. The [`astconv` module][astconv], is where the code responsible for converting a
71-
`hir::Ty` into a `ty::Ty` is located. This occurs during the type-checking phase, but also in other
71+
`rustc_hir::Ty` into a `ty::Ty` is located. This occurs during the type-checking phase, but also in other
7272
parts of the compiler that want to ask questions like "what argument types does this function
7373
expect"?.
7474

@@ -85,7 +85,7 @@ we determine that they semantically are the same type and that’s the `ty::Ty`
8585

8686
Consider another example: `fn foo<T>(x: T) -> u32` and suppose that someone invokes `foo::<u32>(0)`.
8787
This means that `T` and `u32` (in this invocation) actually turns out to be the same type, so we
88-
would eventually end up with the same `ty::Ty` in the end, but we have distinct `hir::Ty`. (This is
88+
would eventually end up with the same `ty::Ty` in the end, but we have distinct `rustc_hir::Ty`. (This is
8989
a bit over-simplified, though, since during type checking, we would check the function generically
9090
and would still have a `T` distinct from `u32`. Later, when doing code generation, we would always
9191
be handling "monomorphized" (fully substituted) versions of each function, and hence we would know
@@ -104,7 +104,7 @@ mod b {
104104
}
105105
```
106106

107-
Here the type `X` will vary depending on context, clearly. If you look at the `hir::Ty`, you will
107+
Here the type `X` will vary depending on context, clearly. If you look at the `rustc_hir::Ty`, you will
108108
get back that `X` is an alias in both cases (though it will be mapped via name resolution to
109109
distinct aliases). But if you look at the `ty::Ty` signature, it will be either `fn(u32) -> u32` or
110110
`fn(i32) -> i32` (with type aliases fully expanded).
@@ -466,7 +466,7 @@ You may have a couple of followup questions…
466466
replace a `SubstRef` with another list of types.
467467

468468
[Here is an example of actually using `subst` in the compiler][substex]. The exact details are not
469-
too important, but in this piece of code, we happen to be converting from the `hir::Ty` to a real
469+
too important, but in this piece of code, we happen to be converting from the `rustc_hir::Ty` to a real
470470
`ty::Ty`. You can see that we first get some substitutions (`substs`). Then we call `type_of` to
471471
get a type and call `ty.subst(substs)` to get a new version of `ty` with the substitutions made.
472472

@@ -475,7 +475,7 @@ get a type and call `ty.subst(substs)` to get a new version of `ty` with the sub
475475
**Note on indices:** It is possible for the indices in `Param` to not match with what we expect. For
476476
example, the index could be out of bounds or it could be the index of a lifetime when we were
477477
expecting a type. These sorts of errors would be caught earlier in the compiler when translating
478-
from a `hir::Ty` to a `ty::Ty`. If they occur later, that is a compiler bug.
478+
from a `rustc_hir::Ty` to a `ty::Ty`. If they occur later, that is a compiler bug.
479479

480480
### `TypeFoldable` and `TypeFolder`
481481

0 commit comments

Comments
 (0)