From d0e89be2072a8e041123a0a71e22ee32f289f7d7 Mon Sep 17 00:00:00 2001 From: Dmitry Dygalo Date: Sat, 14 Sep 2024 18:21:12 +0200 Subject: [PATCH] chore: Add deprecation warning for features Signed-off-by: Dmitry Dygalo --- .github/workflows/ci.yml | 2 +- crates/jsonschema/src/compilation/mod.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e93cd92..c3294db1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -170,7 +170,7 @@ jobs: - uses: Swatinem/rust-cache@v2 - - run: cargo clippy --all-targets --all-features -- -D warnings + - run: cargo clippy --all-targets --all-features features: name: Check features diff --git a/crates/jsonschema/src/compilation/mod.rs b/crates/jsonschema/src/compilation/mod.rs index a52512b9..eba99154 100644 --- a/crates/jsonschema/src/compilation/mod.rs +++ b/crates/jsonschema/src/compilation/mod.rs @@ -34,6 +34,16 @@ pub struct JSONSchema { pub(crate) static DEFAULT_SCOPE: Lazy = Lazy::new(|| Url::parse(DEFAULT_ROOT_URL).expect("Is a valid URL")); +/// This function exists solely to trigger a deprecation warning if any +/// deprecated features are enabled. +#[deprecated( + since = "0.19.0", + note = "The features 'draft201909', 'draft202012', and 'cli' are deprecated and will be removed in a future version." +)] +#[allow(dead_code)] +#[cfg(any(feature = "draft201909", feature = "draft202012", feature = "cli"))] +fn deprecated_features_used() {} + impl JSONSchema { /// Return a default `CompilationOptions` that can configure /// `JSONSchema` compilation flow. @@ -51,6 +61,8 @@ impl JSONSchema { /// ``` #[must_use] pub fn options() -> CompilationOptions { + #[cfg(any(feature = "draft201909", feature = "draft202012", feature = "cli"))] + deprecated_features_used(); CompilationOptions::default() }