diff options
| author | 许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com> | 2025-01-26 14:42:01 +0800 |
|---|---|---|
| committer | 许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com> | 2025-01-26 14:45:10 +0800 |
| commit | 93563980a33e4b6cf8e3fbfa02bd4479ebd05a70 (patch) | |
| tree | 290c0c6b46683767ac03c1e0fc01866c9a100298 | |
| parent | 57e857576000b3a879de3fe7a9b641ecd645474c (diff) | |
| download | rust-93563980a33e4b6cf8e3fbfa02bd4479ebd05a70.tar.gz rust-93563980a33e4b6cf8e3fbfa02bd4479ebd05a70.zip | |
tidy: add `build-metrics`-gated feature status serialization
Co-authored-by: Jane Losare-Lusby <jlusby42@gmail.com>
| -rw-r--r-- | src/tools/tidy/Cargo.toml | 4 | ||||
| -rw-r--r-- | src/tools/tidy/src/features.rs | 2 | ||||
| -rw-r--r-- | src/tools/tidy/src/features/version.rs | 1 |
3 files changed, 7 insertions, 0 deletions
diff --git a/src/tools/tidy/Cargo.toml b/src/tools/tidy/Cargo.toml index 2f424a482b5..9a4d0891b4a 100644 --- a/src/tools/tidy/Cargo.toml +++ b/src/tools/tidy/Cargo.toml @@ -12,11 +12,15 @@ miropt-test-tools = { path = "../miropt-test-tools" } walkdir = "2" ignore = "0.4.18" semver = "1.0" +serde = { version = "1.0.125", features = ["derive"], optional = true } termcolor = "1.1.3" rustc-hash = "2.0.0" fluent-syntax = "0.11.1" similar = "2.5.0" +[features] +build-metrics = ["dep:serde"] + [[bin]] name = "rust-tidy" path = "src/main.rs" diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index 4f24eb21242..fcd7943e6e0 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)] +#[cfg_attr(feature = "build-metrics", derive(serde::Serialize))] pub enum Status { Accepted, Removed, @@ -45,6 +46,7 @@ impl fmt::Display for Status { } #[derive(Debug, Clone)] +#[cfg_attr(feature = "build-metrics", derive(serde::Serialize))] pub struct Feature { pub level: Status, pub since: Option<Version>, diff --git a/src/tools/tidy/src/features/version.rs b/src/tools/tidy/src/features/version.rs index 0830c226caf..6a902e80f8e 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)] +#[cfg_attr(feature = "build-metrics", derive(serde::Serialize))] pub enum Version { Explicit { parts: [u32; 3] }, CurrentPlaceholder, |
