Skip to content

Commit 3aa1347

Browse files
eksemark-i-m
authored andcommitted
Rename CodeMap and FileMap to SourceMap and SourceFile.
Those types were renamed in rust-lang/rust#52953
1 parent 7836a59 commit 3aa1347

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

src/appendix/code-index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ compiler.
77
Item | Kind | Short description | Chapter | Declaration
88
----------------|----------|-----------------------------|--------------------|-------------------
99
`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)
10-
`CodeMap` | struct | Maps AST nodes to their source code. It is composed of `FileMap`s | [The parser] | [src/libsyntax/codemap.rs](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/codemap/struct.CodeMap.html)
1110
`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)
1211
`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)
1312
`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)
1413
`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)
1514
`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)
1615
`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)
17-
`FileMap` | struct | Part of the `CodeMap`. Maps AST nodes to their source code for a single source file | [The parser] | [src/libsyntax_pos/lib.rs](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/codemap/struct.FileMap.html)
1816
`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)
1917
`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)
2018
`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)
2119
`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)
2220
`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)
2321
`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)
22+
`SourceFile` | struct | Part of the `SourceMap`. Maps AST nodes to their source code for a single source file | [The parser] | [src/libsyntax_pos/lib.rs](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/source_map/struct.SourceFile.html)
23+
`SourceMap` | struct | Maps AST nodes to their source code. It is composed of `SourceFile`s | [The parser] | [src/libsyntax/source_map.rs](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/source_map/struct.SourceMap.html)
2424
`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)
2525
`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)
2626
`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)

src/diag.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ This chapter is about how to emit compile errors and lints from the compiler.
99
location in the code being compiled. `Span`s are attached to most constructs in
1010
HIR and MIR, allowing for more informative error reporting.
1111

12-
[span]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/codemap/struct.Span.html
12+
[span]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/source_map/struct.Span.html
1313

14-
A `Span` can be looked up in a [`CodeMap`][codemap] to get a "snippet" useful
14+
A `Span` can be looked up in a [`SourceMap`][sourcemap] to get a "snippet" useful
1515
for displaying errors with [`span_to_snippet`][sptosnip] and other similar
16-
methods on the `CodeMap`.
16+
methods on the `SourceMap`.
1717

18-
[codemap]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/codemap/struct.CodeMap.html
19-
[sptosnip]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/codemap/struct.CodeMap.html#method.span_to_snippet
18+
[sourcemap]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/source_map/struct.SourceMap.html
19+
[sptosnip]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/source_map/struct.SourceMap.html#method.span_to_snippet
2020

2121
## Error messages
2222

@@ -58,7 +58,7 @@ let mut err = sess.struct_span_err(sp, "oh no! this is an error!");
5858
// In some cases, you might need to check if `sp` is generated by a macro to
5959
// avoid printing weird errors about macro-generated code.
6060
61-
if let Ok(snippet) = sess.codemap().span_to_snippet(sp) {
61+
if let Ok(snippet) = sess.source_map().span_to_snippet(sp) {
6262
// Use the snippet to generate a suggested fix
6363
err.span_suggestion(suggestion_sp, "try using a qux here", format!("qux {}", snip));
6464
} else {
@@ -96,7 +96,7 @@ For example, to make our `qux` suggestion machine-applicable, we would do:
9696
```rust,ignore
9797
let mut err = sess.struct_span_err(sp, "oh no! this is an error!");
9898
99-
if let Ok(snippet) = sess.codemap().span_to_snippet(sp) {
99+
if let Ok(snippet) = sess.source_map().span_to_snippet(sp) {
100100
// Add applicability info!
101101
err.span_suggestion_with_applicability(
102102
suggestion_sp,
@@ -214,7 +214,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for WhileTrue {
214214
if let ast::LitKind::Bool(true) = lit.node {
215215
if lit.span.ctxt() == SyntaxContext::empty() {
216216
let msg = "denote infinite loops with `loop { ... }`";
217-
let condition_span = cx.tcx.sess.codemap().def_span(e.span);
217+
let condition_span = cx.tcx.sess.source_map().def_span(e.span);
218218
let mut err = cx.struct_span_lint(WHILE_TRUE, condition_span, msg);
219219
err.span_suggestion_short(condition_span, "use `loop`", "loop".to_owned());
220220
err.emit();

src/rustc-driver.md

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

33
The [`rustc_driver`] is essentially `rustc`'s `main()` function. It acts as
44
the glue for running the various phases of the compiler in the correct order,
5-
managing state such as the [`CodeMap`] \(maps AST nodes to source code),
5+
managing state such as the [`SourceMap`] \(maps AST nodes to source code),
66
[`Session`] \(general build context and error messaging) and the [`TyCtxt`]
77
\(the "typing context", allowing you to query the type system and other cool
88
stuff). The `rustc_driver` crate also provides external users with a method
@@ -71,6 +71,6 @@ thread-locals, although you should rarely need to touch it.
7171
[`CompileState`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/driver/struct.CompileState.html
7272
[`Session`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/session/struct.Session.html
7373
[`TyCtxt`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.TyCtxt.html
74-
[`CodeMap`]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/codemap/struct.CodeMap.html
74+
[`SourceMap`]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/source_map/struct.SourceMap.html
7575
[stupid-stats]: https://github.com/nrc/stupid-stats
7676
[Appendix A]: appendix/stupid-stats.html

src/the-parser.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Like most parsers, the parsing process is composed of two main steps,
1414

1515
The `syntax` crate contains several main players,
1616

17-
- a [`CodeMap`] for mapping AST nodes to their source code
17+
- a [`SourceMap`] for mapping AST nodes to their source code
1818
- the [ast module] contains types corresponding to each AST node
1919
- a [`StringReader`] for lexing source code into tokens
2020
- the [parser module] and [`Parser`] struct are in charge of actually parsing
@@ -23,21 +23,21 @@ The `syntax` crate contains several main players,
2323
nodes.
2424

2525
The main entrypoint to the parser is via the various `parse_*` functions in the
26-
[parser module]. They let you do things like turn a [`FileMap`][filemap] (e.g.
26+
[parser module]. They let you do things like turn a [`SourceFile`][sourcefile] (e.g.
2727
the source in a single file) into a token stream, create a parser from the
2828
token stream, and then execute the parser to get a `Crate` (the root AST node).
2929

3030
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
32-
all the information needed while parsing, as well as the `CodeMap` itself.
32+
all the information needed while parsing, as well as the `SourceMap` itself.
3333

3434
[libsyntax]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/index.html
3535
[rustc_errors]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/index.html
3636
[ast]: https://en.wikipedia.org/wiki/Abstract_syntax_tree
37-
[`CodeMap`]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/codemap/struct.CodeMap.html
37+
[`SourceMap`]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/source_map/struct.SourceMap.html
3838
[ast module]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/ast/index.html
3939
[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
43-
[filemap]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/codemap/struct.FileMap.html
43+
[sourcefile]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/source_map/struct.SourceFile.html

0 commit comments

Comments
 (0)