diff --git a/Cargo.toml b/Cargo.toml index acc61634df..122e4bd6cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ std = [] clock = ["std", "winapi", "iana-time-zone"] oldtime = ["time"] wasmbind = ["wasm-bindgen", "js-sys"] -unstable-locales = ["pure-rust-locales", "alloc"] +unstable-locales = ["pure-rust-locales"] __internal_bench = ["criterion"] __doctest = [] diff --git a/src/date.rs b/src/date.rs index 15f3d436d1..d8c5a6bd70 100644 --- a/src/date.rs +++ b/src/date.rs @@ -13,7 +13,7 @@ use core::{fmt, hash}; #[cfg(feature = "rkyv")] use rkyv::{Archive, Deserialize, Serialize}; -#[cfg(feature = "unstable-locales")] +#[cfg(all(feature = "unstable-locales", any(feature = "alloc", feature = "std")))] use crate::format::Locale; #[cfg(any(feature = "alloc", feature = "std"))] use crate::format::{DelayedFormat, Item, StrftimeItems}; @@ -357,8 +357,7 @@ where } /// Formats the date with the specified formatting items and locale. - #[cfg(feature = "unstable-locales")] - #[cfg_attr(docsrs, doc(cfg(feature = "unstable-locales")))] + #[cfg(all(feature = "unstable-locales", any(feature = "alloc", feature = "std")))] #[inline] #[must_use] pub fn format_localized_with_items<'a, I, B>( @@ -382,8 +381,7 @@ where /// Formats the date with the specified format string and locale. /// See the [`crate::format::strftime`] module /// on the supported escape sequences. - #[cfg(feature = "unstable-locales")] - #[cfg_attr(docsrs, doc(cfg(feature = "unstable-locales")))] + #[cfg(all(feature = "unstable-locales", any(feature = "alloc", feature = "std")))] #[inline] #[must_use] pub fn format_localized<'a>( diff --git a/src/datetime/mod.rs b/src/datetime/mod.rs index 8cf3814a82..334d37769a 100644 --- a/src/datetime/mod.rs +++ b/src/datetime/mod.rs @@ -17,7 +17,7 @@ use std::time::{SystemTime, UNIX_EPOCH}; #[cfg(any(feature = "alloc", feature = "std"))] use crate::format::DelayedFormat; -#[cfg(feature = "unstable-locales")] +#[cfg(all(feature = "unstable-locales", any(feature = "alloc", feature = "std")))] use crate::format::Locale; use crate::format::{parse, parse_and_remainder, ParseError, ParseResult, Parsed, StrftimeItems}; use crate::format::{Fixed, Item}; @@ -837,8 +837,7 @@ where } /// Formats the combined date and time with the specified formatting items and locale. - #[cfg(feature = "unstable-locales")] - #[cfg_attr(docsrs, doc(cfg(feature = "unstable-locales")))] + #[cfg(all(feature = "unstable-locales", any(feature = "alloc", feature = "std")))] #[inline] #[must_use] pub fn format_localized_with_items<'a, I, B>( @@ -865,8 +864,7 @@ where /// /// See the [`crate::format::strftime`] module on the supported escape /// sequences. - #[cfg(feature = "unstable-locales")] - #[cfg_attr(docsrs, doc(cfg(feature = "unstable-locales")))] + #[cfg(all(feature = "unstable-locales", any(feature = "alloc", feature = "std")))] #[inline] #[must_use] pub fn format_localized<'a>( diff --git a/src/format/formatting.rs b/src/format/formatting.rs index ea4cfc02bd..a4ed87a0cc 100644 --- a/src/format/formatting.rs +++ b/src/format/formatting.rs @@ -482,8 +482,7 @@ pub fn format_item( /// Tries to format given arguments with given formatting items. /// Internally used by `DelayedFormat`. -#[cfg(feature = "unstable-locales")] -#[cfg_attr(docsrs, doc(cfg(feature = "unstable-locales")))] +#[cfg(all(feature = "unstable-locales", any(feature = "alloc", feature = "std")))] #[deprecated(since = "0.4.27")] pub fn format_localized<'a, I, B>( w: &mut fmt::Formatter, @@ -502,8 +501,7 @@ where } /// Formats single formatting item -#[cfg(feature = "unstable-locales")] -#[cfg_attr(docsrs, doc(cfg(feature = "unstable-locales")))] +#[cfg(all(feature = "unstable-locales", any(feature = "alloc", feature = "std")))] #[deprecated(since = "0.4.27")] pub fn format_item_localized( w: &mut fmt::Formatter, diff --git a/src/format/mod.rs b/src/format/mod.rs index a7ee67ccab..e27a1b2ade 100644 --- a/src/format/mod.rs +++ b/src/format/mod.rs @@ -56,7 +56,7 @@ pub use formatting::Formatter; #[cfg(any(feature = "alloc", feature = "std"))] pub use formatting::{format, format_item, DelayedFormat}; #[allow(deprecated)] -#[cfg(feature = "unstable-locales")] +#[cfg(all(feature = "unstable-locales", any(feature = "alloc", feature = "std")))] pub use formatting::{format_item_localized, format_localized}; #[cfg(any(feature = "alloc", feature = "std"))] pub(crate) use formatting::{write_rfc2822, write_rfc3339}; diff --git a/src/lib.rs b/src/lib.rs index 8ef20fc58c..06fdff3adf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -229,7 +229,7 @@ //! # #[allow(unused_imports)] //! use chrono::prelude::*; //! -//! # #[cfg(feature = "unstable-locales")] +//! # #[cfg(all(feature = "unstable-locales", any(feature = "alloc", feature = "std")))] //! # fn test() { //! let dt = Utc.with_ymd_and_hms(2014, 11, 28, 12, 0, 9).unwrap(); //! assert_eq!(dt.format("%Y-%m-%d %H:%M:%S").to_string(), "2014-11-28 12:00:09"); @@ -246,9 +246,9 @@ //! let dt_nano = NaiveDate::from_ymd_opt(2014, 11, 28).unwrap().and_hms_nano_opt(12, 0, 9, 1).unwrap().and_local_timezone(Utc).unwrap(); //! assert_eq!(format!("{:?}", dt_nano), "2014-11-28T12:00:09.000000001Z"); //! # } -//! # #[cfg(not(feature = "unstable-locales"))] +//! # #[cfg(not(all(feature = "unstable-locales", any(feature = "alloc", feature = "std"))))] //! # fn test() {} -//! # if cfg!(feature = "unstable-locales") { +//! # if cfg!(all(feature = "unstable-locales", any(feature = "alloc", feature = "std"))) { //! # test(); //! # } //! ``` @@ -426,8 +426,7 @@ pub mod prelude { #[cfg_attr(docsrs, doc(cfg(feature = "clock")))] #[doc(no_inline)] pub use crate::Local; - #[cfg(feature = "unstable-locales")] - #[cfg_attr(docsrs, doc(cfg(feature = "unstable-locales")))] + #[cfg(all(feature = "unstable-locales", any(feature = "alloc", feature = "std")))] #[doc(no_inline)] pub use crate::Locale; #[doc(no_inline)] @@ -458,7 +457,6 @@ pub use datetime::{DateTime, SecondsFormat, MAX_DATETIME, MIN_DATETIME}; pub mod format; /// L10n locales. #[cfg(feature = "unstable-locales")] -#[cfg_attr(docsrs, doc(cfg(feature = "unstable-locales")))] pub use format::Locale; pub use format::{ParseError, ParseResult}; diff --git a/src/naive/date.rs b/src/naive/date.rs index 4afe9006b3..e4b22c4a0b 100644 --- a/src/naive/date.rs +++ b/src/naive/date.rs @@ -13,7 +13,7 @@ use core::{fmt, str}; use rkyv::{Archive, Deserialize, Serialize}; /// L10n locales. -#[cfg(feature = "unstable-locales")] +#[cfg(all(feature = "unstable-locales", any(feature = "alloc", feature = "std")))] use pure_rust_locales::Locale; #[cfg(any(feature = "alloc", feature = "std"))] @@ -1304,8 +1304,7 @@ impl NaiveDate { } /// Formats the date with the specified formatting items and locale. - #[cfg(feature = "unstable-locales")] - #[cfg_attr(docsrs, doc(cfg(feature = "unstable-locales")))] + #[cfg(all(feature = "unstable-locales", any(feature = "alloc", feature = "std")))] #[inline] #[must_use] pub fn format_localized_with_items<'a, I, B>( @@ -1324,8 +1323,7 @@ impl NaiveDate { /// /// See the [`crate::format::strftime`] module on the supported escape /// sequences. - #[cfg(feature = "unstable-locales")] - #[cfg_attr(docsrs, doc(cfg(feature = "unstable-locales")))] + #[cfg(all(feature = "unstable-locales", any(feature = "alloc", feature = "std")))] #[inline] #[must_use] pub fn format_localized<'a>(