diff --git a/Cargo.lock b/Cargo.lock index 85e5e6c97105c..ec4d904741b40 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1194,6 +1194,15 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" +[[package]] +name = "features-status-dump" +version = "0.1.0" +dependencies = [ + "serde", + "serde_json", + "tidy", +] + [[package]] name = "field-offset" version = "0.3.6" @@ -5371,6 +5380,7 @@ dependencies = [ "regex", "rustc-hash 2.1.0", "semver", + "serde", "similar", "termcolor", "walkdir", diff --git a/Cargo.toml b/Cargo.toml index b773030b4cab4..68d142ebe9265 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,6 +47,7 @@ members = [ "src/tools/coverage-dump", "src/tools/rustc-perf-wrapper", "src/tools/wasm-component-ld", + "src/tools/features-status-dump", ] exclude = [ diff --git a/src/tools/features-status-dump/Cargo.toml b/src/tools/features-status-dump/Cargo.toml new file mode 100644 index 0000000000000..fd5ac7c13ee23 --- /dev/null +++ b/src/tools/features-status-dump/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "features-status-dump" +version = "0.1.0" +license = "MIT OR Apache-2.0" +edition = "2021" + +[dependencies] +serde = { version = "1.0.125", features = [ "derive" ] } +serde_json = "1.0.59" +tidy = { path = "../tidy" } diff --git a/src/tools/features-status-dump/src/main.rs b/src/tools/features-status-dump/src/main.rs new file mode 100644 index 0000000000000..9738310f0717c --- /dev/null +++ b/src/tools/features-status-dump/src/main.rs @@ -0,0 +1,31 @@ +use std::collections::HashMap; +use std::env; +use std::fs::File; +use std::io::BufWriter; +use std::path::Path; + +use tidy::features::{Feature, collect_lang_features, collect_lib_features}; + +#[derive(serde::Serialize)] +struct FeaturesStatus { + lang_features_status: HashMap, + lib_features_status: HashMap, +} + +fn main() { + let library_path_str = env::args_os().nth(1).expect("library/ path required"); + let compiler_path_str = env::args_os().nth(2).expect("compiler/ path required"); + let output_path_str = env::args_os().nth(3).expect("output path required"); + let library_path = Path::new(&library_path_str); + let compiler_path = Path::new(&compiler_path_str); + let output_path = Path::new(&output_path_str); + let lang_features_status = collect_lang_features(compiler_path, &mut false); + let lib_features_status = collect_lib_features(library_path) + .into_iter() + .filter(|&(ref name, _)| !lang_features_status.contains_key(name)) + .collect(); + let features_status = FeaturesStatus { lang_features_status, lib_features_status }; + let writer = File::create(output_path).expect("output path should be a valid path"); + let writer = BufWriter::new(writer); + serde_json::to_writer_pretty(writer, &features_status).unwrap(); +} diff --git a/src/tools/tidy/Cargo.toml b/src/tools/tidy/Cargo.toml index 2f424a482b5bb..4dee71aad7796 100644 --- a/src/tools/tidy/Cargo.toml +++ b/src/tools/tidy/Cargo.toml @@ -12,6 +12,7 @@ miropt-test-tools = { path = "../miropt-test-tools" } walkdir = "2" ignore = "0.4.18" semver = "1.0" +serde = { version = "1.0.125", features = [ "derive" ] } termcolor = "1.1.3" rustc-hash = "2.0.0" fluent-syntax = "0.11.1" diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index 4f24eb2124207..6390d1eeccacd 100644 --- a/src/tools/tidy/src/features.rs +++ b/src/tools/tidy/src/features.rs @@ -27,6 +27,7 @@ const FEATURE_GROUP_START_PREFIX: &str = "// feature-group-start"; const FEATURE_GROUP_END_PREFIX: &str = "// feature-group-end"; #[derive(Debug, PartialEq, Clone)] +#[derive(serde::Serialize)] pub enum Status { Accepted, Removed, @@ -45,6 +46,7 @@ impl fmt::Display for Status { } #[derive(Debug, Clone)] +#[derive(serde::Serialize)] pub struct Feature { pub level: Status, pub since: Option, diff --git a/src/tools/tidy/src/features/version.rs b/src/tools/tidy/src/features/version.rs index 0830c226caf41..13d55b4845851 100644 --- a/src/tools/tidy/src/features/version.rs +++ b/src/tools/tidy/src/features/version.rs @@ -8,6 +8,7 @@ mod tests; pub const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION"; #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[derive(serde::Serialize)] pub enum Version { Explicit { parts: [u32; 3] }, CurrentPlaceholder,