Skip to content

Commit 9356398

Browse files
jieyouxuyaahc
andcommitted
tidy: add build-metrics-gated feature status serialization
Co-authored-by: Jane Losare-Lusby <[email protected]>
1 parent 57e8575 commit 9356398

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

src/tools/tidy/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ 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"], optional = true }
1516
termcolor = "1.1.3"
1617
rustc-hash = "2.0.0"
1718
fluent-syntax = "0.11.1"
1819
similar = "2.5.0"
1920

21+
[features]
22+
build-metrics = ["dep:serde"]
23+
2024
[[bin]]
2125
name = "rust-tidy"
2226
path = "src/main.rs"

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+
#[cfg_attr(feature = "build-metrics", 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+
#[cfg_attr(feature = "build-metrics", 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+
#[cfg_attr(feature = "build-metrics", derive(serde::Serialize))]
1112
pub enum Version {
1213
Explicit { parts: [u32; 3] },
1314
CurrentPlaceholder,

0 commit comments

Comments
 (0)