Skip to content

Commit 9bccc26

Browse files
committed
sembr src/diagnostics/error-codes.md
1 parent d0601e7 commit 9bccc26

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

src/diagnostics/error-codes.md

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
# Error codes
2-
We generally try to assign each error message a unique code like `E0123`. These
3-
codes are defined in the compiler in the `diagnostics.rs` files found in each
4-
crate, which basically consist of macros. All error codes have an associated
5-
explanation: new error codes must include them. Note that not all _historical_
6-
(no longer emitted) error codes have explanations.
2+
We generally try to assign each error message a unique code like `E0123`.
3+
These codes are defined in the compiler in the `diagnostics.rs` files found in each
4+
crate, which basically consist of macros.
5+
All error codes have an associated explanation: new error codes must include them.
6+
Note that not all _historical_ (no longer emitted) error codes have explanations.
77

88
## Error explanations
99

1010
The explanations are written in Markdown (see the [CommonMark Spec] for
11-
specifics around syntax), and all of them are linked in the [`rustc_error_codes`]
12-
crate. Please read [RFC 1567] for details on how to format and write long error
13-
codes. As of <!-- date-check --> February 2023, there is an
14-
effort[^new-explanations] to replace this largely outdated RFC with a new more
15-
flexible standard.
11+
specifics around syntax), and all of them are linked in the [`rustc_error_codes`] crate.
12+
Please read [RFC 1567] for details on how to format and write long error codes.
13+
As of <!-- date-check --> February 2023, there is an
14+
effort[^new-explanations] to replace this largely outdated RFC with a new more flexible standard.
1615

1716
Error explanations should expand on the error message and provide details about
18-
_why_ the error occurs. It is not helpful for users to copy-paste a quick fix;
19-
explanations should help users understand why their code cannot be accepted by
20-
the compiler. Rust prides itself on helpful error messages and long-form
21-
explanations are no exception. However, before error explanations are
17+
_why_ the error occurs.
18+
It is not helpful for users to copy-paste a quick fix;
19+
explanations should help users understand why their code cannot be accepted by the compiler.
20+
Rust prides itself on helpful error messages and long-form explanations are no exception.
21+
However, before error explanations are
2222
overhauled[^new-explanations] it is a bit open as to how exactly they should be
2323
written, as always: ask your reviewer or ask around on the Rust Zulip.
2424

@@ -33,12 +33,12 @@ written, as always: ask your reviewer or ask around on the Rust Zulip.
3333

3434
Error codes are stored in `compiler/rustc_error_codes`.
3535

36-
To create a new error, you first need to find the next available code.
36+
To create a new error, you first need to find the next available code.
3737
You can find it by opening `rustc_error_codes/src/lib.rs` and scrolling down
3838
to the end of the `error_codes!` macro declaration.
3939

40-
Here we might see the highest error code in use is `E0805`, so we _probably_ want
41-
`E0806`. To be sure, run `rg E0806` and check, you should see no references.
40+
Here we might see the highest error code in use is `E0805`, so we _probably_ want `E0806`.
41+
To be sure, run `rg E0806` and check, you should see no references.
4242

4343
You will have to write an extended description for your error,
4444
which will go in `rustc_error_codes/src/error_codes/E0806.md`.
@@ -62,8 +62,7 @@ struct_span_code_err!(self.dcx(), // some path to the `DiagCtxt` here
6262
.emit() // actually issue the error
6363
```
6464

65-
If you want to add notes or other snippets, you can invoke methods before you
66-
call `.emit()`:
65+
If you want to add notes or other snippets, you can invoke methods before you call `.emit()`:
6766

6867
```rust
6968
struct_span_code_err!(...)

0 commit comments

Comments
 (0)