mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-22 06:48:00 +00:00
Merge pull request #2966 from dtolnay/noserdecore
Enforce derive cannot be used against serde_core
This commit is contained in:
@@ -34,14 +34,6 @@ rustdoc-args = [
|
||||
"--extern-html-root-url=std=https://doc.rust-lang.org",
|
||||
]
|
||||
|
||||
# This cfg cannot be enabled, but it still forces Cargo to keep serde_derive's
|
||||
# version in lockstep with serde's, even if someone depends on the two crates
|
||||
# separately with serde's "derive" feature disabled. Every serde_derive release
|
||||
# is compatible with exactly one serde release because the generated code
|
||||
# involves nonpublic APIs which are not bound by semver.
|
||||
[target.'cfg(any())'.dependencies]
|
||||
serde_derive = { version = "=1.0.219", path = "../serde_derive" }
|
||||
|
||||
|
||||
### FEATURES #################################################################
|
||||
|
||||
|
||||
@@ -256,3 +256,9 @@ extern crate serde_derive;
|
||||
#[cfg(feature = "serde_derive")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "derive")))]
|
||||
pub use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! __require_serde_not_serde_core {
|
||||
() => {};
|
||||
}
|
||||
|
||||
@@ -29,6 +29,14 @@ rustdoc-args = [
|
||||
"--extern-html-root-url=std=https://doc.rust-lang.org",
|
||||
]
|
||||
|
||||
# This cfg cannot be enabled, but it still forces Cargo to keep serde_derive's
|
||||
# version in lockstep with serde's, even if someone depends on the two crates
|
||||
# separately with serde's "derive" feature disabled. Every serde_derive release
|
||||
# is compatible with exactly one serde release because the generated code
|
||||
# involves nonpublic APIs which are not bound by semver.
|
||||
[target.'cfg(any())'.dependencies]
|
||||
serde_derive = { version = "=1.0.219", path = "../serde_derive" }
|
||||
|
||||
|
||||
### FEATURES #################################################################
|
||||
|
||||
|
||||
@@ -266,3 +266,13 @@ mod seed;
|
||||
|
||||
#[cfg(all(not(feature = "std"), no_core_error))]
|
||||
mod std_error;
|
||||
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! __require_serde_not_serde_core {
|
||||
() => {
|
||||
::core::compile_error!(
|
||||
"Serde derive requires a dependency on the serde crate, not serde_core"
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -22,6 +22,9 @@ pub fn wrap_in_const(serde_path: Option<&syn::Path>, code: TokenStream) -> Token
|
||||
)]
|
||||
const _: () = {
|
||||
#use_serde
|
||||
|
||||
_serde::__require_serde_not_serde_core!();
|
||||
|
||||
#code
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user