@@ -7,12 +7,13 @@ are making a new code, you should write an extended write-up.
77
88### Allocating a fresh code
99
10- If you want to create a new error, you first need to find the next available
11- code. This is a bit tricky since the codes are defined in various crates. To do
12- it, run this obscure command:
10+ Error codes are stored in ` compiler/rustc_error_codes ` .
11+
12+ To create a new error, you first need to find the next available
13+ code. You can find it with ` tidy ` :
1314
1415```
15- ./x.py test --stage 0 tidy
16+ ./x.py test tidy
1617```
1718
1819This will invoke the tidy script, which generally checks that your code obeys
@@ -31,17 +32,16 @@ tidy check (x86_64-apple-darwin)
3132Here we see the highest error code in use is ` E0591 ` , so we _ probably_ want
3233` E0592 ` . To be sure, run ` rg E0592 ` and check, you should see no references.
3334
34- Next, open ` src/{crate}/diagnostics.rs ` within the crate where you wish to issue
35- the error (e.g., ` compiler/rustc_typeck/src/diagnostics.rs ` ). Ideally, you will add
36- the code (in its proper numerical order) into the ` register_long_diagnostics! `
37- macro, sort of like this:
35+ Ideally, you will write an extended description for your error,
36+ which will go in ` rustc_error_codes/src/error_codes/E0592.md ` .
37+ To register the error, open ` rustc_error_codes/src/error_codes.rs ` and add the
38+ code (in its proper numerical order) into` register_diagnostics! ` macro, like
39+ this:
3840
3941``` rust
40- register_long_diagnostics ! {
42+ register_diagnostics ! {
4143 ...
42- E0592 : r ## "
43- Your extended error text goes here!
44- " ## ,
44+ E0592 : include_str! (" ./error_codes/E0592.md" ),
4545}
4646```
4747
0 commit comments