From d4bb2508b2c3daf79109de53ae87c7c4390af383 Mon Sep 17 00:00:00 2001 From: Paul Dicker Date: Fri, 11 Aug 2023 22:01:19 +0200 Subject: [PATCH] Correct feature gates --- src/format/formatting.rs | 7 +++++++ src/format/mod.rs | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/format/formatting.rs b/src/format/formatting.rs index 429b9658b0..b581562120 100644 --- a/src/format/formatting.rs +++ b/src/format/formatting.rs @@ -10,17 +10,22 @@ use core::borrow::Borrow; use core::fmt; use core::fmt::Write; +#[cfg(any(feature = "alloc", feature = "std", feature = "serde", feature = "rustc-serialize"))] use crate::datetime::SecondsFormat; #[cfg(any(feature = "alloc", feature = "std"))] use crate::offset::Offset; +#[cfg(any(feature = "alloc", feature = "std", feature = "serde", feature = "rustc-serialize"))] use crate::{Datelike, FixedOffset, NaiveDateTime, Timelike}; #[cfg(any(feature = "alloc", feature = "std"))] use crate::{NaiveDate, NaiveTime, Weekday}; +#[cfg(any(feature = "alloc", feature = "std"))] use super::locales; +#[cfg(any(feature = "alloc", feature = "std", feature = "serde", feature = "rustc-serialize"))] use super::{Colons, OffsetFormat, OffsetPrecision, Pad}; #[cfg(any(feature = "alloc", feature = "std"))] use super::{Fixed, InternalFixed, InternalInternal, Item, Locale, Numeric}; +#[cfg(any(feature = "alloc", feature = "std"))] use locales::*; /// A *temporary* object which can be used as an argument to `format!` or others. @@ -445,6 +450,7 @@ fn format_inner( } } +#[cfg(any(feature = "alloc", feature = "std", feature = "serde", feature = "rustc-serialize"))] impl OffsetFormat { /// Writes an offset from UTC with the format defined by `self`. fn format(&self, w: &mut impl Write, off: FixedOffset) -> fmt::Result { @@ -526,6 +532,7 @@ impl OffsetFormat { /// Writes the date, time and offset to the string. same as `%Y-%m-%dT%H:%M:%S%.f%:z` #[inline] +#[cfg(any(feature = "alloc", feature = "std", feature = "serde", feature = "rustc-serialize"))] pub(crate) fn write_rfc3339( w: &mut impl Write, dt: NaiveDateTime, diff --git a/src/format/mod.rs b/src/format/mod.rs index 42ee3c2fb2..b7bd4d0edf 100644 --- a/src/format/mod.rs +++ b/src/format/mod.rs @@ -48,19 +48,21 @@ pub(crate) mod scan; pub mod strftime; +#[cfg(any(feature = "alloc", feature = "std"))] pub(crate) mod locales; pub(crate) use formatting::write_hundreds; #[cfg(any(feature = "alloc", feature = "std"))] pub(crate) use formatting::write_rfc2822; +#[cfg(any(feature = "alloc", feature = "std", feature = "serde", feature = "rustc-serialize"))] pub(crate) use formatting::write_rfc3339; #[cfg(any(feature = "alloc", feature = "std"))] pub use formatting::{format, format_item, DelayedFormat}; #[cfg(feature = "unstable-locales")] pub use formatting::{format_item_localized, format_localized}; -#[cfg(feature = "unstable-locales")] +#[cfg(all(feature = "unstable-locales", any(feature = "alloc", feature = "std")))] pub use locales::Locale; -#[cfg(not(feature = "unstable-locales"))] +#[cfg(all(not(feature = "unstable-locales"), any(feature = "alloc", feature = "std")))] pub(crate) use locales::Locale; pub use parse::{parse, parse_and_remainder}; pub use parsed::Parsed;