Skip to content

Commit b5f3538

Browse files
committed
Add new tool for dumping feature status based on tidy
1 parent 7db7489 commit b5f3538

File tree

7 files changed

+47
-1
lines changed

7 files changed

+47
-1
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ members = [
4747
"src/tools/coverage-dump",
4848
"src/tools/rustc-perf-wrapper",
4949
"src/tools/wasm-component-ld",
50+
"src/tools/features-status-dump",
5051
]
5152

5253
exclude = [

src/bootstrap/src/core/build_steps/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ HELP: to skip test's attempt to check tidiness, pass `--skip src/tools/tidy` to
10821082
}
10831083

10841084
builder.info("tidy check");
1085-
cmd.delay_failure().run(builder);
1085+
dbg!(cmd).delay_failure().run(builder);
10861086

10871087
builder.info("x.py completions check");
10881088
let [bash, zsh, fish, powershell] = ["x.py.sh", "x.py.zsh", "x.py.fish", "x.py.ps1"]
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "features-status-dump"
3+
version = "0.1.0"
4+
license = "MIT OR Apache-2.0"
5+
edition = "2021"
6+
7+
[dependencies]
8+
serde = { version = "1.0.125", features = [ "derive" ] }
9+
serde_json = "1.0.59"
10+
tidy = { path = "../tidy" }
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
use std::collections::HashMap;
2+
use std::io::BufWriter;
3+
use std::{env, fs::File};
4+
use std::path::Path;
5+
use tidy::features::{collect_lang_features, collect_lib_features, Feature};
6+
7+
#[derive(serde::Serialize)]
8+
struct FeaturesStatus {
9+
lang_features_status: HashMap<String, Feature>,
10+
lib_features_status: HashMap<String, Feature>,
11+
}
12+
13+
fn main() {
14+
let library_path_str = env::args_os().nth(1).expect("library/ path required");
15+
let compiler_path_str = env::args_os().nth(2).expect("compiler/ path required");
16+
let output_path_str = env::args_os().nth(3).expect("output path required");
17+
let library_path = Path::new(&library_path_str);
18+
let compiler_path = Path::new(&compiler_path_str);
19+
let output_path = Path::new(&output_path_str);
20+
let lang_features_status = collect_lang_features(compiler_path, &mut false);
21+
let lib_features_status = collect_lib_features(library_path)
22+
.into_iter()
23+
.filter(|&(ref name, _)| !lang_features_status.contains_key(name))
24+
.collect();
25+
let features_status = FeaturesStatus {
26+
lang_features_status, lib_features_status
27+
};
28+
let writer = File::create(output_path).expect("output path should be a valid path");
29+
let writer = BufWriter::new(writer);
30+
serde_json::to_writer_pretty(writer, &features_status).unwrap();
31+
}

src/tools/tidy/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ miropt-test-tools = { path = "../miropt-test-tools" }
1212
walkdir = "2"
1313
ignore = "0.4.18"
1414
semver = "1.0"
15+
serde = { version = "1.0.125", features = [ "derive" ] }
1516
termcolor = "1.1.3"
1617
rustc-hash = "2.0.0"
1718
fluent-syntax = "0.11.1"

src/tools/tidy/src/features.rs

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const FEATURE_GROUP_START_PREFIX: &str = "// feature-group-start";
2727
const FEATURE_GROUP_END_PREFIX: &str = "// feature-group-end";
2828

2929
#[derive(Debug, PartialEq, Clone)]
30+
#[derive(serde::Serialize)]
3031
pub enum Status {
3132
Accepted,
3233
Removed,
@@ -45,6 +46,7 @@ impl fmt::Display for Status {
4546
}
4647

4748
#[derive(Debug, Clone)]
49+
#[derive(serde::Serialize)]
4850
pub struct Feature {
4951
pub level: Status,
5052
pub since: Option<Version>,

src/tools/tidy/src/features/version.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ mod tests;
88
pub const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION";
99

1010
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
11+
#[derive(serde::Serialize)]
1112
pub enum Version {
1213
Explicit { parts: [u32; 3] },
1314
CurrentPlaceholder,

0 commit comments

Comments
 (0)