Skip to content

Commit 196d10e

Browse files
zackmdavismark-i-m
authored andcommitted
rewrite suggestions intro to be less bizarrely edition/rustfix centric
The suggestions API was introduced in April 2015 (rust-lang/rust@906a9728ff), long predating rustfix (initial commit July 2016) or editions (RFC 2052 approved September 2017).
1 parent 8564564 commit 196d10e

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/diag.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,21 @@ err.emit();
7474

7575
## Suggestions
7676

77-
We would like to make edition transitions as smooth as possible. To that end,
78-
[`rustfix`][rustfix] can use compiler suggestions to automatically fix
79-
code. For example, we could use `rustfix` to mechanically apply the `qux`
80-
suggestion from the previous example. However, not all suggestions are
81-
mechanically applicable. We use the
77+
In addition to telling the user exactly _why_ their code is wrong, it's
78+
oftentimes furthermore possible to tell them how to fix it. To this end,
79+
`DiagnosticBuilder` offers a structured suggestions API, which formats code
80+
suggestions pleasingly in the terminal, or (when the `--error-format json` flag
81+
is passed) as JSON for consumption by tools, most notably the [Rust Language
82+
Server][rls] and [`rustfix`][rustfix].
83+
84+
[rls]: https://github.com/rust-lang-nursery/rls
85+
[rustfix]: https://github.com/rust-lang-nursery/rustfix
86+
87+
Not all suggestions should be applied mechanically. Use the
8288
[`span_suggestion_with_applicability`][sswa] method of `DiagnosticBuilder` to
83-
inform the emitter of whether a suggestion is mechanically applicable or not.
84-
This information, in turn, is outputed by rustc when the error format is
85-
`json`, which is used by `rustfix`.
89+
make a suggestion while providing a hint to tools whether the suggestion is
90+
mechanically applicable or not.
8691

87-
[rustfix]: https://github.com/rust-lang-nursery/rustfix/
8892
[sswa]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.DiagnosticBuilder.html#method.span_suggestion_with_applicability
8993

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

0 commit comments

Comments
 (0)