Skip to content

Commit

Permalink
refactor: improve error-index-generator dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Ezrashaw committed Feb 26, 2023
1 parent 90677ed commit 5304415
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 20 deletions.
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,7 @@ name = "error_index_generator"
version = "0.0.0"
dependencies = [
"mdbook",
"rustc_error_codes",
]

[[package]]
Expand Down
1 change: 1 addition & 0 deletions src/tools/error_index_generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edition = "2021"

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

[[bin]]
name = "error_index_generator"
Expand Down
21 changes: 1 addition & 20 deletions src/tools/error_index_generator/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

extern crate rustc_driver;

// We use the function we generate from `register_diagnostics!`.
use crate::error_codes::error_codes;

use std::env;
use std::error::Error;
use std::fs::{self, File};
Expand All @@ -17,22 +14,6 @@ use std::str::FromStr;
use mdbook::book::{parse_summary, BookItem, Chapter};
use mdbook::{Config, MDBook};

macro_rules! register_diagnostics {
($($error_code:ident: $message:expr,)+ ; $($undocumented:ident,)* ) => {
pub fn error_codes() -> Vec<(&'static str, Option<&'static str>)> {
let mut errors: Vec<(&str, Option<&str>)> = vec![
$((stringify!($error_code), Some($message)),)+
$((stringify!($undocumented), None),)*
];
errors.sort();
errors
}
}
}

#[path = "../../../compiler/rustc_error_codes/src/error_codes.rs"]
mod error_codes;

enum OutputFormat {
HTML,
Markdown,
Expand Down Expand Up @@ -102,7 +83,7 @@ This page lists all the error codes emitted by the Rust compiler.
"
);

let err_codes = error_codes();
let err_codes = rustc_error_codes::DIAGNOSTICS;
let mut chapters = Vec::with_capacity(err_codes.len());

for (err_code, explanation) in err_codes.iter() {
Expand Down

0 comments on commit 5304415

Please sign in to comment.