Skip to content

Commit 8e6bcbe

Browse files
authored
Merge pull request rust-lang#153 from mark-i-m/code_index_01
A few more data structures to the code index
2 parents 460342c + 318057e commit 8e6bcbe

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

src/appendix/code-index.md

+16-2
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,38 @@ 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)
910
`CodeMap` | struct | The CodeMap maps the AST nodes to their source code | [The parser] | [src/libsyntax/codemap.rs](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/codemap/struct.CodeMap.html)
1011
`CompileState` | struct | State that is passed to a callback at each compiler pass | [The Rustc Driver] | [src/librustc_driver/driver.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/driver/struct.CompileState.html)
12+
`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)
1113
`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)
1214
`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)
1315
`ast::Crate` | struct | 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)
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)
1417
`hir::Crate` | struct | 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)
15-
`ParseSess` | struct | This struct contains information about a parsing session | [the Parser] | [src/libsyntax/parse/mod.rs](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/parse/struct.ParseSess.html)
16-
`Session` | struct | The data associated with a compilation session | [the Parser], [The Rustc Driver] | [src/librustc/session/mod.html](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/session/struct.Session.html)
18+
`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)
19+
`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)
20+
`ParseSess` | struct | This struct contains information about a parsing session | [The parser] | [src/libsyntax/parse/mod.rs](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/parse/struct.ParseSess.html)
21+
`Rib` | struct | Represents a single scope of names | [Name resolution] | [src/librustc_resolve/lib.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_resolve/struct.Rib.html)
22+
`Session` | struct | The data associated with a compilation session | [The parser], [The Rustc Driver] | [src/librustc/session/mod.html](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/session/struct.Session.html)
1723
`Span` | struct | A location in the user's source code, used for error reporting primarily | [Emitting Diagnostics] | [src/libsyntax_pos/span_encoding.rs](https://doc.rust-lang.org/nightly/nightly-rustc/syntax_pos/struct.Span.html)
1824
`StringReader` | struct | This is the lexer used during parsing. It consumes characters from the raw source code being compiled and produces a series of tokens for use by the rest of the parser | [The parser] | [src/libsyntax/parse/lexer/mod.rs](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/parse/lexer/struct.StringReader.html)
25+
`syntax::token_stream::TokenStream` | struct | An abstract sequence of tokens, organized into `TokenTree`s | [The parser], [Macro expansion] | [src/libsyntax/tokenstream.rs](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/tokenstream/struct.TokenStream.html)
1926
`TraitDef` | struct | This struct contains a trait's definition with type information | [The `ty` modules] | [src/librustc/ty/trait_def.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/trait_def/struct.TraitDef.html)
27+
`TraitRef` | struct | The combination of a trait and its input types (e.g. `P0: Trait<P1...Pn>`) | [Trait Solving: Goals and Clauses], [Trait Solving: Lowering impls] | [src/librustc/ty/sty.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.TraitRef.html)
2028
`Ty<'tcx>` | struct | This is the internal representation of a type used for type checking | [Type checking] | [src/librustc/ty/mod.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/type.Ty.html)
2129
`TyCtxt<'cx, 'tcx, 'tcx>` | type | 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] | [src/librustc/ty/context.rs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.TyCtxt.html)
2230

2331
[The HIR]: hir.html
32+
[Identifiers in the HIR]: hir.html#hir-id
2433
[The parser]: the-parser.html
2534
[The Rustc Driver]: rustc-driver.html
2635
[Type checking]: type-checking.html
2736
[The `ty` modules]: ty.html
2837
[Rustdoc]: rustdoc.html
2938
[Emitting Diagnostics]: diag.html
39+
[Macro expansion]: macro-expansion.html
40+
[Name resolution]: name-resolution.html
41+
[Parameter Environment]: param_env.html
42+
[Trait Solving: Goals and Clauses]: traits/goals-and-clauses.html#domain-goals
43+
[Trait Solving: Lowering impls]: traits/lowering-rules.html#lowering-impls

src/hir.md

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ function to lookup the contents of `bar()` given its id; this gives the
5757
compiler a chance to observe that you accessed the data for `bar()`,
5858
and then record the dependency.
5959

60+
<a name="hir-id"></a>
61+
6062
### Identifiers in the HIR
6163

6264
Most of the code that has to deal with things in HIR tends not to

src/the-parser.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The parser is responsible for converting raw Rust source code into a structured
44
form which is easier for the compiler to work with, usually called an [*Abstract
5-
Syntax Tree*][ast]. An AST mirrors the structure of a Rust program in memory,
5+
Syntax Tree*][ast]. An AST mirrors the structure of a Rust program in memory,
66
using a `Span` to link a particular AST node back to its source text.
77

88
The bulk of the parser lives in the [libsyntax] crate.
@@ -27,16 +27,16 @@ in the [parser module]. They let you do things like turn a filemap into a
2727
token stream, create a parser from the token stream, and then execute the
2828
parser to get a `Crate` (the root AST node).
2929

30-
To minimise the amount of copying that is done, both the `StringReader` and
30+
To minimise the amount of copying that is done, both the `StringReader` and
3131
`Parser` have lifetimes which bind them to the parent `ParseSess`. This contains
3232
all the information needed while parsing, as well as the `CodeMap` itself.
3333

34-
[libsyntax]: https://github.com/rust-lang/rust/tree/master/src/libsyntax
35-
[rustc_errors]: https://github.com/rust-lang/rust/tree/master/src/librustc_errors
34+
[libsyntax]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/index.html
35+
[rustc_errors]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/index.html
3636
[ast]: https://en.wikipedia.org/wiki/Abstract_syntax_tree
3737
[`CodeMap`]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/codemap/struct.CodeMap.html
3838
[ast module]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/ast/index.html
39-
[parser module]: https://github.com/rust-lang/rust/tree/master/src/libsyntax/parse
39+
[parser module]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/parse/index.html
4040
[`Parser`]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/parse/parser/struct.Parser.html
4141
[`StringReader`]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/parse/lexer/struct.StringReader.html
4242
[visit module]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/visit/index.html

0 commit comments

Comments
 (0)