forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#63721 - Mark-Simulacrum:decouple-error-inde…
…x, r=matthewjasper Do not emit JSON dumps of diagnostic codes This decouples the error index generator from libsyntax for the most part (though it still depends on librustdoc for the markdown parsing and generation). Fixes rust-lang#34588
- Loading branch information
Showing
9 changed files
with
93 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
use walkdir::WalkDir; | ||
use std::path::PathBuf; | ||
use std::{env, fs}; | ||
|
||
fn main() { | ||
// The src directory (we are in src/tools/error_index_generator) | ||
// Note that we could skip one of the .. but this ensures we at least loosely find the right | ||
// directory. | ||
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); | ||
let dest = out_dir.join("error_codes.rs"); | ||
let mut idx = 0; | ||
for entry in WalkDir::new("../../../src") { | ||
let entry = entry.unwrap(); | ||
if entry.file_name() == "error_codes.rs" { | ||
println!("cargo:rerun-if-changed={}", entry.path().to_str().unwrap()); | ||
let file = fs::read_to_string(entry.path()).unwrap() | ||
.replace("use syntax::{register_diagnostics, register_long_diagnostics};", "") | ||
.replace("use syntax::register_diagnostics;", "") | ||
.replace("use syntax::register_long_diagnostics;", ""); | ||
let contents = format!("(|| {{\n{}\n}})();", file); | ||
|
||
fs::write(&out_dir.join(&format!("error_{}.rs", idx)), &contents).unwrap(); | ||
|
||
idx += 1; | ||
} | ||
} | ||
|
||
let mut all = String::new(); | ||
all.push_str("fn register_all() -> Vec<(&'static str, Option<&'static str>)> {\n"); | ||
all.push_str("let mut long_codes: Vec<(&'static str, Option<&'static str>)> = Vec::new();\n"); | ||
all.push_str(r#" | ||
macro_rules! register_diagnostics { | ||
($($code:tt),*) => {{ | ||
long_codes.extend([$( | ||
stringify!($code), | ||
)*].iter().cloned().map(|s| (s, None)).collect::<Vec<_>>()); | ||
}}; | ||
($($code:tt),*,) => {{ | ||
long_codes.extend([$( | ||
stringify!($code), | ||
)*].iter().cloned().map(|s| (s, None))); | ||
}} | ||
} | ||
macro_rules! register_long_diagnostics { | ||
($($code:tt: $description:tt),*) => { | ||
{long_codes.extend([$( | ||
(stringify!($code), Some(stringify!($description))), | ||
)*].iter());} | ||
}; | ||
($($code:tt: $description:tt),*,) => { | ||
{long_codes.extend([$( | ||
(stringify!($code), Some(stringify!($description))), | ||
)*].iter());} | ||
} | ||
}"#); | ||
for idx in 0..idx { | ||
all.push_str(&format!(r#"include!(concat!(env!("OUT_DIR"), "/error_{}.rs"));"#, idx)); | ||
} | ||
all.push_str("\nlong_codes\n"); | ||
all.push_str("}\n"); | ||
|
||
fs::write(&dest, all).unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters