Skip to content

Commit 95bdeac

Browse files
zackmdavismark-i-m
authored andcommitted
add links for Span, CodeMap, and rustfix
It's unfortunate that `code-monospaced` links don't render with link colors (such that the reader needs to hover over them just to tell that it is a link), but that's presumably a bug in MdBook, and not something we need concern ourselves with here.
1 parent 3787248 commit 95bdeac

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

src/diag.md

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ This chapter is about how to emit compile errors and lints from the compiler.
55

66
## `Span`
77

8-
`Span` is the primary data structure in `rustc` used to represent a ___location in
9-
the code being compiled. `Span`s are attached to most constructs in HIR and MIR,
10-
allowing for easier error reporting whenever an error comes up.
8+
[`Span`][span] is the primary data structure in `rustc` used to represent a
9+
___location in the code being compiled. `Span`s are attached to most constructs in
10+
HIR and MIR, allowing for easier error reporting whenever an error comes up.
1111

12-
A `Span` can be looked up in a `CodeMap` to get a "snippet" useful for
13-
displaying errors with [`span_to_snippet` and other similar methods][sptosnip]
14-
on the `CodeMap`.
12+
[span]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/codemap/struct.Span.html
1513

14+
A `Span` can be looked up in a [`CodeMap`][codemap] to get a "snippet" useful
15+
for displaying errors with [`span_to_snippet`][sptosnip] and other similar
16+
methods on the `CodeMap`.
17+
18+
[codemap]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/codemap/struct.CodeMap.html
1619
[sptosnip]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/codemap/struct.CodeMap.html#method.span_to_snippet
1720

1821
## Error messages
@@ -70,14 +73,16 @@ err.emit();
7073
## Suggestions
7174

7275
We would like to make edition transitions as smooth as possible. To that end,
73-
`rustfix` can use compiler suggestions to automatically fix code. For example,
74-
we could use `rustfix` to mechanically apply the `qux` suggestion from the
75-
previous example. However, not all suggestions are mechanically applicable. We
76-
use the [`span_suggestion_with_applicability`][sswa] method of
77-
`DiagnosticBuilder` to inform the emitter of whether a suggestion is
78-
mechanically applicable or not. This information, in turn, is outputed by
79-
rustc when the error format is `json`, which is used by `rustfix`.
80-
76+
[`rustfix`][rustfix] can use compiler suggestions to automatically fix
77+
code. For example, we could use `rustfix` to mechanically apply the `qux`
78+
suggestion from the previous example. However, not all suggestions are
79+
mechanically applicable. We use the
80+
[`span_suggestion_with_applicability`][sswa] method of `DiagnosticBuilder` to
81+
inform the emitter of whether a suggestion is mechanically applicable or not.
82+
This information, in turn, is outputed by rustc when the error format is
83+
`json`, which is used by `rustfix`.
84+
85+
[rustfix]: https://github.com/rust-lang-nursery/rustfix/
8186
[sswa]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.DiagnosticBuilder.html#method.span_suggestion_with_applicability
8287

8388
For example, to make our `qux` suggestion machine-applicable, we would do:

0 commit comments

Comments
 (0)