Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new tool for dumping feature status based on tidy #135844

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -5371,6 +5380,7 @@ dependencies = [
"regex",
"rustc-hash 2.1.0",
"semver",
"serde",
"similar",
"termcolor",
"walkdir",
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
10 changes: 10 additions & 0 deletions src/tools/features-status-dump/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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" }
31 changes: 31 additions & 0 deletions src/tools/features-status-dump/src/main.rs
Original file line number Diff line number Diff line change
@@ -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<String, Feature>,
lib_features_status: HashMap<String, Feature>,
}

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();
}
1 change: 1 addition & 0 deletions src/tools/tidy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions src/tools/tidy/src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -45,6 +46,7 @@ impl fmt::Display for Status {
}

#[derive(Debug, Clone)]
#[derive(serde::Serialize)]
pub struct Feature {
pub level: Status,
pub since: Option<Version>,
Expand Down
1 change: 1 addition & 0 deletions src/tools/tidy/src/features/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading