Skip to content

Commit

Permalink
chore: Add deprecation warning for features
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Dygalo <[email protected]>
  • Loading branch information
Stranger6667 committed Sep 14, 2024
1 parent 1d48eaf commit d0e89be
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions crates/jsonschema/src/compilation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ pub struct JSONSchema {
pub(crate) static DEFAULT_SCOPE: Lazy<Url> =
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.
Expand All @@ -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()
}

Expand Down

0 comments on commit d0e89be

Please sign in to comment.