diff --git a/serde/src/lib.rs b/serde/src/lib.rs index f0ea1d2c..227a0913 100644 --- a/serde/src/lib.rs +++ b/serde/src/lib.rs @@ -97,7 +97,9 @@ // Serde types in rustdoc of other crates get linked to here. #![doc(html_root_url = "https://docs.rs/serde/1.0.228")] // Support using Serde without the standard library! -#![cfg_attr(not(feature = "std"), no_std)] +// Also force no_std on target_os = "none" (wasm32v1-none) even if std feature is enabled +// This handles Cargo feature unification where std gets enabled for no_std targets +#![cfg_attr(any(not(feature = "std"), target_os = "none"), no_std)] // Show which crate feature enables conditionally compiled APIs in documentation. #![cfg_attr(docsrs, feature(doc_cfg, rustdoc_internals))] #![cfg_attr(docsrs, allow(internal_features))] @@ -168,6 +170,10 @@ #[cfg(feature = "alloc")] extern crate alloc; +// Explicitly import core crate for no_std targets (especially wasm32v1-none) +#[cfg(any(not(feature = "std"), target_os = "none"))] +extern crate core; + // Rustdoc has a lot of shortcomings related to cross-crate re-exports that make // the rendered documentation of serde_core traits in serde more challenging to // understand than the equivalent documentation of the same items in serde_core.