diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2019-11-13 15:27:59 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2019-11-14 13:05:56 +0100 |
| commit | 356da40db5ad56ed9efbf6c2757422a9fd2fd3d2 (patch) | |
| tree | 1cbddf7fa23b9679cb8dd044721154d471f76490 | |
| parent | ec50a750f96164e588adcc9ef5d47b8ac89869d1 (diff) | |
| download | rust-356da40db5ad56ed9efbf6c2757422a9fd2fd3d2.tar.gz rust-356da40db5ad56ed9efbf6c2757422a9fd2fd3d2.zip | |
Adapt error index generator to the new format
| -rw-r--r-- | Cargo.lock | 1 | ||||
| -rw-r--r-- | src/test/ui/explain.stdout | 2 | ||||
| -rw-r--r-- | src/tools/error_index_generator/build.rs | 34 |
3 files changed, 20 insertions, 17 deletions
diff --git a/Cargo.lock b/Cargo.lock index ff04bc5e26f..781184af9a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3120,6 +3120,7 @@ dependencies = [ "graphviz", "jobserver", "log", + "measureme", "num_cpus", "parking_lot 0.9.0", "polonius-engine", diff --git a/src/test/ui/explain.stdout b/src/test/ui/explain.stdout index 391ac68041e..9ea56271f59 100644 --- a/src/test/ui/explain.stdout +++ b/src/test/ui/explain.stdout @@ -1,4 +1,4 @@ -er [RFC 401][rfc401], if you have a function declaration `foo`: +Per [RFC 401][rfc401], if you have a function declaration `foo`: ``` // For the purposes of this explanation, all of these diff --git a/src/tools/error_index_generator/build.rs b/src/tools/error_index_generator/build.rs index 3261bf5a98b..b04aff4939b 100644 --- a/src/tools/error_index_generator/build.rs +++ b/src/tools/error_index_generator/build.rs @@ -8,21 +8,26 @@ fn main() { // 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("crate::register_diagnostics!", "register_diagnostics!") - .replace(": include_str!(\"./", - ": include_str!(\"../../../../../../../../src/librustc_error_codes/"); - let contents = format!("(|| {{\n{}\n}})()", file); - fs::write(&out_dir.join(&format!("error_{}.rs", idx)), &contents).unwrap(); + let error_codes_path = "../../../src/librustc_error_codes/error_codes.rs"; + + println!("cargo:rerun-if-changed={}", error_codes_path); + let file = fs::read_to_string(error_codes_path).unwrap() + .replace("crate::register_diagnostics!", "register_diagnostics!") + .replace(": include_str!(\"./error_codes/", ": include_str!(\"./"); + let contents = format!("(|| {{\n{}\n}})()", file); + fs::write(&out_dir.join("all_error_codes.rs"), &contents).unwrap(); - idx += 1; + // We copy the md files as well to the target directory. + for entry in WalkDir::new("../../../src/librustc_error_codes/error_codes") { + let entry = entry.unwrap(); + match entry.path().extension() { + Some(s) if s == "md" => {} + _ => continue, } + println!("cargo:rerun-if-changed={}", entry.path().to_str().unwrap()); + let md_content = fs::read_to_string(entry.path()).unwrap(); + fs::write(&out_dir.join(entry.file_name()), &md_content).unwrap(); } let mut all = String::new(); @@ -48,10 +53,7 @@ fn register_all() -> Vec<(&'static str, Option<&'static str>)> { ) } "###); - for idx in 0..idx { - all.push_str(&format!(r#"include!(concat!(env!("OUT_DIR"), "/error_{}.rs"));"#, idx)); - all.push_str("\n"); - } + all.push_str(r#"include!(concat!(env!("OUT_DIR"), "/all_error_codes.rs"));"#); all.push_str("\nlong_codes\n"); all.push_str("}\n"); |
