Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger a warning if serde is disabled #541

Merged
merged 2 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion examples/build-script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
2 changes: 1 addition & 1 deletion examples/minimal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
2 changes: 2 additions & 0 deletions minijinja/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ default = [
"multi_template",
"adjacent_loop_items",
"std_collections",
"serde",
]

# API features
Expand All @@ -35,6 +36,7 @@ loader = ["self_cell", "memo-map"]
unicode = ["unicode-ident", "unicase"]
custom_syntax = ["dep:aho-corasick"]
std_collections = []
serde = []

# Speedups
key_interning = []
Expand Down
20 changes: 20 additions & 0 deletions minijinja/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:**
//!
Expand Down Expand Up @@ -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
Expand Down