2
2
3
3
extern crate rustc_driver;
4
4
5
- // We use the function we generate from `register_diagnostics!`.
6
- use crate :: error_codes:: error_codes;
7
-
8
5
use std:: env;
9
6
use std:: error:: Error ;
10
7
use std:: fs:: { self , File } ;
@@ -17,22 +14,6 @@ use std::str::FromStr;
17
14
use mdbook:: book:: { parse_summary, BookItem , Chapter } ;
18
15
use mdbook:: { Config , MDBook } ;
19
16
20
- macro_rules! register_diagnostics {
21
- ( $( $error_code: ident: $message: expr, ) + ; $( $undocumented: ident, ) * ) => {
22
- pub fn error_codes( ) -> Vec <( & ' static str , Option <& ' static str >) > {
23
- let mut errors: Vec <( & str , Option <& str >) > = vec![
24
- $( ( stringify!( $error_code) , Some ( $message) ) , ) +
25
- $( ( stringify!( $undocumented) , None ) , ) *
26
- ] ;
27
- errors. sort( ) ;
28
- errors
29
- }
30
- }
31
- }
32
-
33
- #[ path = "../../../compiler/rustc_error_codes/src/error_codes.rs" ]
34
- mod error_codes;
35
-
36
17
enum OutputFormat {
37
18
HTML ,
38
19
Markdown ,
@@ -55,11 +36,8 @@ fn render_markdown(output_path: &Path) -> Result<(), Box<dyn Error>> {
55
36
56
37
write ! ( output_file, "# Rust Compiler Error Index\n " ) ?;
57
38
58
- for ( err_code, description) in error_codes ( ) . iter ( ) {
59
- match description {
60
- Some ( ref desc) => write ! ( output_file, "## {}\n {}\n " , err_code, desc) ?,
61
- None => { }
62
- }
39
+ for ( err_code, description) in rustc_error_codes:: DIAGNOSTICS . iter ( ) {
40
+ write ! ( output_file, "## {}\n {}\n " , err_code, description) ?
63
41
}
64
42
65
43
Ok ( ( ) )
@@ -105,27 +83,23 @@ This page lists all the error codes emitted by the Rust compiler.
105
83
"
106
84
) ;
107
85
108
- let err_codes = error_codes ( ) ;
86
+ let err_codes = rustc_error_codes :: DIAGNOSTICS ;
109
87
let mut chapters = Vec :: with_capacity ( err_codes. len ( ) ) ;
110
88
111
89
for ( err_code, explanation) in err_codes. iter ( ) {
112
- if let Some ( explanation) = explanation {
113
- introduction. push_str ( & format ! ( " * [{0}](./{0}.html)\n " , err_code) ) ;
114
-
115
- let content = add_rust_attribute_on_codeblock ( explanation) ;
116
- chapters. push ( BookItem :: Chapter ( Chapter {
117
- name : err_code. to_string ( ) ,
118
- content : format ! ( "# Error code {}\n \n {}\n " , err_code, content) ,
119
- number : None ,
120
- sub_items : Vec :: new ( ) ,
121
- // We generate it into the `error_codes` folder.
122
- path : Some ( PathBuf :: from ( & format ! ( "{}.html" , err_code) ) ) ,
123
- source_path : None ,
124
- parent_names : Vec :: new ( ) ,
125
- } ) ) ;
126
- } else {
127
- introduction. push_str ( & format ! ( " * {}\n " , err_code) ) ;
128
- }
90
+ introduction. push_str ( & format ! ( " * [{0}](./{0}.html)\n " , err_code) ) ;
91
+
92
+ let content = add_rust_attribute_on_codeblock ( explanation) ;
93
+ chapters. push ( BookItem :: Chapter ( Chapter {
94
+ name : err_code. to_string ( ) ,
95
+ content : format ! ( "# Error code {}\n \n {}\n " , err_code, content) ,
96
+ number : None ,
97
+ sub_items : Vec :: new ( ) ,
98
+ // We generate it into the `error_codes` folder.
99
+ path : Some ( PathBuf :: from ( & format ! ( "{}.html" , err_code) ) ) ,
100
+ source_path : None ,
101
+ parent_names : Vec :: new ( ) ,
102
+ } ) ) ;
129
103
}
130
104
131
105
let mut config = Config :: from_str ( include_str ! ( "book_config.toml" ) ) ?;
0 commit comments