@@ -33,40 +33,22 @@ written, as always: ask your reviewer or ask around on the Rust Zulip.
3333
3434Error codes are stored in ` compiler/rustc_error_codes ` .
3535
36- To create a new error, you first need to find the next available
37- code. You can find it with ` tidy ` :
36+ To create a new error, you first need to find the next available code.
37+ You can find it by opening ` rustc_error_codes/src/lib.rs ` and scrolling down
38+ to the end of the ` error_codes! ` macro declaration.
3839
39- ```
40- ./x test tidy
41- ```
42-
43- This will invoke the tidy script, which generally checks that your code obeys
44- our coding conventions. Some of these jobs check error codes and ensure that
45- there aren't duplicates, etc (the tidy check is defined in
46- ` src/tools/tidy/src/error_codes.rs ` ). Once it is finished with that, tidy will
47- print out the highest used error code:
48-
49- ```
50- ...
51- tidy check
52- Found 505 error codes
53- Highest error code: `E0591`
54- ...
55- ```
56-
57- Here we see the highest error code in use is ` E0591 ` , so we _ probably_ want
58- ` E0592 ` . To be sure, run ` rg E0592 ` and check, you should see no references.
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.
5942
6043You will have to write an extended description for your error,
61- which will go in ` rustc_error_codes/src/error_codes/E0592.md ` .
62- To register the error, open ` rustc_error_codes/src/error_codes.rs ` and add the
63- code (in its proper numerical order) into` register_diagnostics! ` macro, like
64- this:
44+ which will go in ` rustc_error_codes/src/error_codes/E0806.md ` .
45+ To register the error, add the code (in its proper numerical order) to
46+ the ` error_codes! ` macro, like this:
6547
6648``` rust
67- register_diagnostics! {
68- ...
69- E0592 : include_str! ( " ./error_codes/E0592.md " ) ,
49+ macro_rules! error_codes {
50+ ...
51+ 0806 ,
7052}
7153```
7254
@@ -75,7 +57,7 @@ To actually issue the error, you can use the `struct_span_code_err!` macro:
7557``` rust
7658struct_span_code_err! (self . dcx (), // some path to the `DiagCtxt` here
7759 span , // whatever span in the source you want
78- E0592 , // your new error code
60+ E0806 , // your new error code
7961 fluent :: example :: an_error_message )
8062 . emit () // actually issue the error
8163```
0 commit comments