Skip to content

Commit 5304415

Browse files
committed
refactor: improve error-index-generator dependency
1 parent 90677ed commit 5304415

File tree

3 files changed

+3
-20
lines changed

3 files changed

+3
-20
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -1445,6 +1445,7 @@ name = "error_index_generator"
14451445
version = "0.0.0"
14461446
dependencies = [
14471447
"mdbook",
1448+
"rustc_error_codes",
14481449
]
14491450

14501451
[[package]]

src/tools/error_index_generator/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ edition = "2021"
55

66
[dependencies]
77
mdbook = { version = "0.4", default-features = false, features = ["search"] }
8+
rustc_error_codes = { version = "0.0.0", path = "../../../compiler/rustc_error_codes" }
89

910
[[bin]]
1011
name = "error_index_generator"

src/tools/error_index_generator/main.rs

+1-20
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
extern crate rustc_driver;
44

5-
// We use the function we generate from `register_diagnostics!`.
6-
use crate::error_codes::error_codes;
7-
85
use std::env;
96
use std::error::Error;
107
use std::fs::{self, File};
@@ -17,22 +14,6 @@ use std::str::FromStr;
1714
use mdbook::book::{parse_summary, BookItem, Chapter};
1815
use 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-
3617
enum OutputFormat {
3718
HTML,
3819
Markdown,
@@ -102,7 +83,7 @@ This page lists all the error codes emitted by the Rust compiler.
10283
"
10384
);
10485

105-
let err_codes = error_codes();
86+
let err_codes = rustc_error_codes::DIAGNOSTICS;
10687
let mut chapters = Vec::with_capacity(err_codes.len());
10788

10889
for (err_code, explanation) in err_codes.iter() {

0 commit comments

Comments
 (0)