diff --git a/CHANGELOG.md b/CHANGELOG.md index 3887e215..b18af7ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ All notable changes to MiniJinja are documented here. - Fixed a bug that caused cycle detection to trigger incorrectly when an included template extended from another template. #538 - Bumped the minimum version of `self_cell` to 1.0.4. #540 +- MiniJinja will now warn if the `serde` feature is disabled. This is in + anticipation of removing the serde dependency in the future. #541 ## 2.0.3 diff --git a/examples/build-script/Cargo.toml b/examples/build-script/Cargo.toml index 426cc0d3..94a5fe1e 100644 --- a/examples/build-script/Cargo.toml +++ b/examples/build-script/Cargo.toml @@ -5,4 +5,4 @@ edition = "2021" publish = false [build-dependencies] -minijinja = { path = "../../minijinja", default-features = false, features = ["builtins"] } +minijinja = { path = "../../minijinja", default-features = false, features = ["serde", "builtins"] } diff --git a/examples/minimal/Cargo.toml b/examples/minimal/Cargo.toml index 594f090a..0e3d0aeb 100644 --- a/examples/minimal/Cargo.toml +++ b/examples/minimal/Cargo.toml @@ -7,4 +7,4 @@ publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -minijinja = { path = "../../minijinja", default-features = false } +minijinja = { path = "../../minijinja", features = ["serde"], default-features = false } diff --git a/minijinja/Cargo.toml b/minijinja/Cargo.toml index 29414ee8..eb37cd8c 100644 --- a/minijinja/Cargo.toml +++ b/minijinja/Cargo.toml @@ -25,6 +25,7 @@ default = [ "multi_template", "adjacent_loop_items", "std_collections", + "serde", ] # API features @@ -35,6 +36,7 @@ loader = ["self_cell", "memo-map"] unicode = ["unicode-ident", "unicase"] custom_syntax = ["dep:aho-corasick"] std_collections = [] +serde = [] # Speedups key_interning = [] diff --git a/minijinja/src/lib.rs b/minijinja/src/lib.rs index 0968a913..afb5a429 100644 --- a/minijinja/src/lib.rs +++ b/minijinja/src/lib.rs @@ -150,6 +150,9 @@ //! filter's case insensitive comparison changes to using unicode and not //! ASCII rules. Without this features only ASCII identifiers can be used //! for variable names and attributes. +//! - `serde`: enables or disables serde support. In current versions of MiniJinja +//! it's not possible to disable serde but it will become possible. To prevent +//! breakage, MiniJinja warns if this feature is disabled. //! //! - **Rust Functionality:** //! @@ -246,6 +249,23 @@ pub use self::value::Value; pub use self::macros::__context; pub use self::vm::State; +// fowards compatibility +#[cfg(not(feature = "serde"))] +const _: () = { + #[deprecated( + since = "2.0.4", + note = "Future versions of MiniJinja will require enabling \ + the 'serde' feature to use serde types. To silence this warning \ + add 'serde' to the least of features of minijinja." + )] + #[allow(unused)] + fn enable_implicit_serde_support() {} + + fn trigger_warning() { + enable_implicit_serde_support(); + } +}; + /// This module gives access to the low level machinery. /// /// This module is only provided by the `unstable_machinery` feature and does not