mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-22 06:48:00 +00:00
fix: add explicit prelude imports for wasm32v1-none no_std + alloc
When building serde_core for wasm32v1-none target with no_std but with the alloc feature enabled, the Rust compiler doesn't automatically inject the prelude. This causes ?Sized bounds to fail with "bound modifier ? can only be applied to Sized" errors. This commit adds explicit prelude imports to all modules that: 1. Use `use crate::lib::*;` for serde's internal lib facade 2. Use `?Sized` bounds in their code The fix adds: ```rust #[allow(unused_imports)] #[cfg(not(feature = "std"))] use ::core::prelude::rust_2021::*; ``` This ensures Sized, Clone, Copy, and other prelude traits are in scope for the ?Sized syntax to work correctly on wasm32v1-none targets. Affected files: - serde_core/src/de/impls.rs - serde_core/src/de/mod.rs - serde_core/src/private/doc.rs - serde_core/src/ser/fmt.rs - serde_core/src/ser/impls.rs - serde_core/src/ser/impossible.rs - serde_core/src/ser/mod.rs Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
use crate::lib::*;
|
||||
|
||||
// Explicit prelude import for wasm32v1-none target compatibility
|
||||
// These may appear unused but are required for ?Sized bounds on wasm32v1-none
|
||||
#[allow(unused_imports)]
|
||||
#[cfg(not(feature = "std"))]
|
||||
use ::core::prelude::rust_2021::*;
|
||||
|
||||
use crate::de::{
|
||||
Deserialize, Deserializer, EnumAccess, Error, MapAccess, SeqAccess, Unexpected, VariantAccess,
|
||||
Visitor,
|
||||
|
||||
@@ -114,6 +114,11 @@
|
||||
|
||||
use crate::lib::*;
|
||||
|
||||
// Explicit prelude import for wasm32v1-none target compatibility
|
||||
#[allow(unused_imports)]
|
||||
#[cfg(not(feature = "std"))]
|
||||
use ::core::prelude::rust_2021::*;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pub mod value;
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
use crate::lib::*;
|
||||
|
||||
// Explicit prelude import for wasm32v1-none target compatibility
|
||||
#[allow(unused_imports)]
|
||||
#[cfg(not(feature = "std"))]
|
||||
use ::core::prelude::rust_2021::*;
|
||||
|
||||
use crate::ser;
|
||||
|
||||
#[doc(hidden)]
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
use crate::lib::*;
|
||||
|
||||
// Explicit prelude import for wasm32v1-none target compatibility
|
||||
#[allow(unused_imports)]
|
||||
#[cfg(not(feature = "std"))]
|
||||
use ::core::prelude::rust_2021::*;
|
||||
|
||||
use crate::ser::{Error, Impossible, Serialize, Serializer};
|
||||
|
||||
impl Error for fmt::Error {
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
use crate::lib::*;
|
||||
|
||||
// Explicit prelude import for wasm32v1-none target compatibility
|
||||
// These may appear unused but are required for ?Sized bounds on wasm32v1-none
|
||||
#[allow(unused_imports)]
|
||||
#[cfg(not(feature = "std"))]
|
||||
use ::core::prelude::rust_2021::*;
|
||||
|
||||
use crate::ser::{Error, Serialize, SerializeTuple, Serializer};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
use crate::lib::*;
|
||||
|
||||
// Explicit prelude import for wasm32v1-none target compatibility
|
||||
#[allow(unused_imports)]
|
||||
#[cfg(not(feature = "std"))]
|
||||
use ::core::prelude::rust_2021::*;
|
||||
|
||||
use crate::ser::{
|
||||
self, Serialize, SerializeMap, SerializeSeq, SerializeStruct, SerializeStructVariant,
|
||||
SerializeTuple, SerializeTupleStruct, SerializeTupleVariant,
|
||||
|
||||
@@ -109,6 +109,11 @@
|
||||
|
||||
use crate::lib::*;
|
||||
|
||||
// Explicit prelude import for wasm32v1-none target compatibility
|
||||
#[allow(unused_imports)]
|
||||
#[cfg(not(feature = "std"))]
|
||||
use ::core::prelude::rust_2021::*;
|
||||
|
||||
mod fmt;
|
||||
mod impls;
|
||||
mod impossible;
|
||||
|
||||
Reference in New Issue
Block a user