22
33extern crate rustc_driver;
44
5- // We use the function we generate from `register_diagnostics!`.
6- use crate :: error_codes:: error_codes;
7-
85use std:: env;
96use std:: error:: Error ;
107use std:: fs:: { self , File } ;
@@ -17,22 +14,6 @@ use std::str::FromStr;
1714use mdbook:: book:: { parse_summary, BookItem , Chapter } ;
1815use mdbook:: { Config , MDBook } ;
1916
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-
3617enum OutputFormat {
3718 HTML ,
3819 Markdown ,
@@ -55,11 +36,8 @@ fn render_markdown(output_path: &Path) -> Result<(), Box<dyn Error>> {
5536
5637 write ! ( output_file, "# Rust Compiler Error Index\n " ) ?;
5738
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) ?
6341 }
6442
6543 Ok ( ( ) )
@@ -105,27 +83,23 @@ This page lists all the error codes emitted by the Rust compiler.
10583"
10684 ) ;
10785
108- let err_codes = error_codes ( ) ;
86+ let err_codes = rustc_error_codes :: DIAGNOSTICS ;
10987 let mut chapters = Vec :: with_capacity ( err_codes. len ( ) ) ;
11088
11189 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+ } ) ) ;
129103 }
130104
131105 let mut config = Config :: from_str ( include_str ! ( "book_config.toml" ) ) ?;
0 commit comments