mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-22 04:28:00 +00:00
fix: add explicit prelude exports for wasm32v1-none target
wasm32v1-none target does not automatically inject prelude items like Sized, Clone, Copy, etc. into scope. This commit: - Uses fully qualified paths (::core, ::std) to avoid ambiguity with internal `mod core` shadowing - Explicitly re-exports rust_2021 prelude items - Adds explicit imports for essential prelude traits: Sized, Clone, Copy, Send, Sync, Unpin, Default, Eq, Ord, PartialEq, PartialOrd, Iterator traits, and Fn traits - Adds `extern crate core;` for no_std targets in lib.rs This fixes compilation errors like "relaxing a default bound only does something for ?Sized" when building for wasm32v1-none target. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,11 +6,27 @@ macro_rules! crate_root {
|
||||
mod lib {
|
||||
mod core {
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub use core::*;
|
||||
pub use ::core::*;
|
||||
#[cfg(feature = "std")]
|
||||
pub use std::*;
|
||||
pub use ::std::*;
|
||||
}
|
||||
|
||||
// Re-export the full prelude for wasm32v1-none and other targets
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub use ::core::prelude::rust_2021::*;
|
||||
#[cfg(feature = "std")]
|
||||
pub use ::std::prelude::rust_2021::*;
|
||||
|
||||
// Prelude items that may not be re-exported by glob import
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub use ::core::option::Option::{self, None, Some};
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub use ::core::result::Result::{self, Err, Ok};
|
||||
#[cfg(feature = "std")]
|
||||
pub use ::std::option::Option::{self, None, Some};
|
||||
#[cfg(feature = "std")]
|
||||
pub use ::std::result::Result::{self, Err, Ok};
|
||||
|
||||
pub use self::core::{f32, f64};
|
||||
pub use self::core::{iter, num, str};
|
||||
|
||||
@@ -20,7 +36,16 @@ macro_rules! crate_root {
|
||||
pub use self::core::cell::{Cell, RefCell};
|
||||
pub use self::core::cmp::Reverse;
|
||||
pub use self::core::fmt::{self, Debug, Display, Write as FmtWrite};
|
||||
pub use self::core::marker::PhantomData;
|
||||
pub use self::core::marker::{PhantomData, Sized};
|
||||
pub use self::core::clone::Clone;
|
||||
pub use self::core::marker::{Copy, Send, Sync, Unpin};
|
||||
pub use self::core::default::Default;
|
||||
pub use self::core::cmp::{Eq, Ord, PartialEq, PartialOrd};
|
||||
pub use self::core::convert::{AsMut, AsRef, From, Into};
|
||||
pub use self::core::iter::{
|
||||
DoubleEndedIterator, ExactSizeIterator, Extend, IntoIterator, Iterator,
|
||||
};
|
||||
pub use self::core::ops::{Drop, Fn, FnMut, FnOnce};
|
||||
pub use self::core::num::Wrapping;
|
||||
pub use self::core::ops::{Bound, Range, RangeFrom, RangeInclusive, RangeTo};
|
||||
pub use self::core::result;
|
||||
|
||||
@@ -103,6 +103,10 @@
|
||||
#[cfg(feature = "alloc")]
|
||||
extern crate alloc;
|
||||
|
||||
// Explicitly import core crate for no_std targets (especially wasm32v1-none)
|
||||
#[cfg(not(feature = "std"))]
|
||||
extern crate core;
|
||||
|
||||
#[macro_use]
|
||||
mod crate_root;
|
||||
#[macro_use]
|
||||
|
||||
Reference in New Issue
Block a user