Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to doc_auto_cfg #1305

Merged
merged 3 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo install cargo-deadlinks
- run: RUSTFLAGS="--cfg docsrs" cargo deadlinks -- --features=serde
- run: cargo deadlinks -- --all-features
- run: cargo doc --all-features --no-deps
env:
RUSTDOCFLAGS: -Dwarnings
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bincode = { version = "1.3.0" }
wasm-bindgen-test = "0.3"

[package.metadata.docs.rs]
features = ["serde, rkyv"]
features = ["arbitrary, rkyv, serde, unstable-locales"]
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.playground]
Expand Down
4 changes: 0 additions & 4 deletions src/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ where
{
/// Formats the date with the specified formatting items.
#[cfg(any(feature = "alloc", feature = "std"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "std"))))]
#[inline]
#[must_use]
pub fn format_with_items<'a, I, B>(&self, items: I) -> DelayedFormat<I>
Expand All @@ -349,7 +348,6 @@ where
/// See the [`crate::format::strftime`] module
/// on the supported escape sequences.
#[cfg(any(feature = "alloc", feature = "std"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "std"))))]
#[inline]
#[must_use]
pub fn format<'a>(&self, fmt: &'a str) -> DelayedFormat<StrftimeItems<'a>> {
Expand All @@ -358,7 +356,6 @@ where

/// Formats the date with the specified formatting items and locale.
#[cfg(feature = "unstable-locales")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-locales")))]
#[inline]
#[must_use]
pub fn format_localized_with_items<'a, I, B>(
Expand All @@ -383,7 +380,6 @@ where
/// See the [`crate::format::strftime`] module
/// on the supported escape sequences.
#[cfg(feature = "unstable-locales")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-locales")))]
#[inline]
#[must_use]
pub fn format_localized<'a>(
Expand Down
40 changes: 0 additions & 40 deletions src/datetime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,6 @@ impl<Tz: TimeZone> DateTime<Tz> {
/// Panics if the date can not be represented in this format: the year may not be negative and
/// can not have more than 4 digits.
#[cfg(any(feature = "alloc", feature = "std"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "std"))))]
#[must_use]
pub fn to_rfc2822(&self) -> String {
let mut result = String::with_capacity(32);
Expand All @@ -548,7 +547,6 @@ impl<Tz: TimeZone> DateTime<Tz> {

/// Returns an RFC 3339 and ISO 8601 date and time string such as `1996-12-19T16:39:57-08:00`.
#[cfg(any(feature = "alloc", feature = "std"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "std"))))]
#[must_use]
pub fn to_rfc3339(&self) -> String {
// For some reason a string with a capacity less than 32 is ca 20% slower when benchmarking.
Expand Down Expand Up @@ -585,7 +583,6 @@ impl<Tz: TimeZone> DateTime<Tz> {
/// "2018-01-26T10:30:09+08:00");
/// ```
#[cfg(any(feature = "alloc", feature = "std"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "std"))))]
#[must_use]
pub fn to_rfc3339_opts(&self, secform: SecondsFormat, use_z: bool) -> String {
let mut result = String::with_capacity(38);
Expand Down Expand Up @@ -647,7 +644,6 @@ impl Default for DateTime<Utc> {
}

#[cfg(feature = "clock")]
#[cfg_attr(docsrs, doc(cfg(feature = "clock")))]
impl Default for DateTime<Local> {
fn default() -> Self {
Local.from_utc_datetime(&NaiveDateTime::default())
Expand All @@ -673,7 +669,6 @@ impl From<DateTime<Utc>> for DateTime<FixedOffset> {

/// Convert a `DateTime<Utc>` instance into a `DateTime<Local>` instance.
#[cfg(feature = "clock")]
#[cfg_attr(docsrs, doc(cfg(feature = "clock")))]
impl From<DateTime<Utc>> for DateTime<Local> {
/// Convert this `DateTime<Utc>` instance into a `DateTime<Local>` instance.
///
Expand All @@ -696,7 +691,6 @@ impl From<DateTime<FixedOffset>> for DateTime<Utc> {

/// Convert a `DateTime<FixedOffset>` instance into a `DateTime<Local>` instance.
#[cfg(feature = "clock")]
#[cfg_attr(docsrs, doc(cfg(feature = "clock")))]
impl From<DateTime<FixedOffset>> for DateTime<Local> {
/// Convert this `DateTime<FixedOffset>` instance into a `DateTime<Local>` instance.
///
Expand All @@ -709,7 +703,6 @@ impl From<DateTime<FixedOffset>> for DateTime<Local> {

/// Convert a `DateTime<Local>` instance into a `DateTime<Utc>` instance.
#[cfg(feature = "clock")]
#[cfg_attr(docsrs, doc(cfg(feature = "clock")))]
impl From<DateTime<Local>> for DateTime<Utc> {
/// Convert this `DateTime<Local>` instance into a `DateTime<Utc>` instance.
///
Expand All @@ -722,7 +715,6 @@ impl From<DateTime<Local>> for DateTime<Utc> {

/// Convert a `DateTime<Local>` instance into a `DateTime<FixedOffset>` instance.
#[cfg(feature = "clock")]
#[cfg_attr(docsrs, doc(cfg(feature = "clock")))]
impl From<DateTime<Local>> for DateTime<FixedOffset> {
/// Convert this `DateTime<Local>` instance into a `DateTime<FixedOffset>` instance.
///
Expand Down Expand Up @@ -868,7 +860,6 @@ where
{
/// Formats the combined date and time with the specified formatting items.
#[cfg(any(feature = "alloc", feature = "std"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "std"))))]
#[inline]
#[must_use]
pub fn format_with_items<'a, I, B>(&self, items: I) -> DelayedFormat<I>
Expand All @@ -893,7 +884,6 @@ where
/// assert_eq!(formatted, "02/04/2017 12:50");
/// ```
#[cfg(any(feature = "alloc", feature = "std"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "std"))))]
#[inline]
#[must_use]
pub fn format<'a>(&self, fmt: &'a str) -> DelayedFormat<StrftimeItems<'a>> {
Expand All @@ -902,7 +892,6 @@ 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")))]
#[inline]
#[must_use]
pub fn format_localized_with_items<'a, I, B>(
Expand Down Expand Up @@ -930,7 +919,6 @@ where
/// See the [`crate::format::strftime`] module on the supported escape
/// sequences.
#[cfg(feature = "unstable-locales")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-locales")))]
#[inline]
#[must_use]
pub fn format_localized<'a>(
Expand Down Expand Up @@ -1401,7 +1389,6 @@ impl str::FromStr for DateTime<Utc> {
/// # Ok::<(), chrono::ParseError>(())
/// ```
#[cfg(feature = "clock")]
#[cfg_attr(docsrs, doc(cfg(feature = "clock")))]
impl str::FromStr for DateTime<Local> {
type Err = ParseError;

Expand All @@ -1411,7 +1398,6 @@ impl str::FromStr for DateTime<Local> {
}

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl From<SystemTime> for DateTime<Utc> {
fn from(t: SystemTime) -> DateTime<Utc> {
let (sec, nsec) = match t.duration_since(UNIX_EPOCH) {
Expand All @@ -1432,15 +1418,13 @@ impl From<SystemTime> for DateTime<Utc> {
}

#[cfg(feature = "clock")]
#[cfg_attr(docsrs, doc(cfg(feature = "clock")))]
impl From<SystemTime> for DateTime<Local> {
fn from(t: SystemTime) -> DateTime<Local> {
DateTime::<Utc>::from(t).with_timezone(&Local)
}
}

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl<Tz: TimeZone> From<DateTime<Tz>> for SystemTime {
fn from(dt: DateTime<Tz>) -> SystemTime {
let sec = dt.timestamp();
Expand All @@ -1459,14 +1443,6 @@ impl<Tz: TimeZone> From<DateTime<Tz>> for SystemTime {
feature = "wasmbind",
not(any(target_os = "emscripten", target_os = "wasi"))
))]
#[cfg_attr(
docsrs,
doc(cfg(all(
target_arch = "wasm32",
feature = "wasmbind",
not(any(target_os = "emscripten", target_os = "wasi"))
)))
)]
impl From<js_sys::Date> for DateTime<Utc> {
fn from(date: js_sys::Date) -> DateTime<Utc> {
DateTime::<Utc>::from(&date)
Expand All @@ -1478,14 +1454,6 @@ impl From<js_sys::Date> for DateTime<Utc> {
feature = "wasmbind",
not(any(target_os = "emscripten", target_os = "wasi"))
))]
#[cfg_attr(
docsrs,
doc(cfg(all(
target_arch = "wasm32",
feature = "wasmbind",
not(any(target_os = "emscripten", target_os = "wasi"))
)))
)]
impl From<&js_sys::Date> for DateTime<Utc> {
fn from(date: &js_sys::Date) -> DateTime<Utc> {
Utc.timestamp_millis_opt(date.get_time() as i64).unwrap()
Expand All @@ -1497,14 +1465,6 @@ impl From<&js_sys::Date> for DateTime<Utc> {
feature = "wasmbind",
not(any(target_os = "emscripten", target_os = "wasi"))
))]
#[cfg_attr(
docsrs,
doc(cfg(all(
target_arch = "wasm32",
feature = "wasmbind",
not(any(target_os = "emscripten", target_os = "wasi"))
)))
)]
impl From<DateTime<Utc>> for js_sys::Date {
/// Converts a `DateTime<Utc>` to a JS `Date`. The resulting value may be lossy,
/// any values that have a millisecond timestamp value greater/less than ±8,640,000,000,000,000
Expand Down
4 changes: 0 additions & 4 deletions src/datetime/rustc_serialize.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg_attr(docsrs, doc(cfg(feature = "rustc-serialize")))]

use super::{DateTime, SecondsFormat};
#[cfg(feature = "clock")]
use crate::offset::Local;
Expand Down Expand Up @@ -82,7 +80,6 @@ impl Decodable for TsSeconds<Utc> {
}

#[cfg(feature = "clock")]
#[cfg_attr(docsrs, doc(cfg(feature = "clock")))]
impl Decodable for DateTime<Local> {
fn decode<D: Decoder>(d: &mut D) -> Result<DateTime<Local>, D::Error> {
match d.read_str()?.parse::<DateTime<FixedOffset>>() {
Expand All @@ -93,7 +90,6 @@ impl Decodable for DateTime<Local> {
}

#[cfg(feature = "clock")]
#[cfg_attr(docsrs, doc(cfg(feature = "clock")))]
#[allow(deprecated)]
impl Decodable for TsSeconds<Local> {
#[allow(deprecated)]
Expand Down
3 changes: 0 additions & 3 deletions src/datetime/serde.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg_attr(docsrs, doc(cfg(feature = "serde")))]

use core::fmt;
use serde::{de, ser};

Expand Down Expand Up @@ -107,7 +105,6 @@ impl<'de> de::Deserialize<'de> for DateTime<Utc> {
/// See [the `serde` module](./serde/index.html) for alternate
/// serialization formats.
#[cfg(feature = "clock")]
#[cfg_attr(docsrs, doc(cfg(feature = "clock")))]
impl<'de> de::Deserialize<'de> for DateTime<Local> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
Expand Down
7 changes: 0 additions & 7 deletions src/format/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ use locales::*;
/// A *temporary* object which can be used as an argument to `format!` or others.
/// This is normally constructed via `format` methods of each date and time type.
#[cfg(any(feature = "alloc", feature = "std"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "std"))))]
#[derive(Debug)]
pub struct DelayedFormat<I> {
/// The date view, if any.
Expand Down Expand Up @@ -103,7 +102,6 @@ impl<'a, I: Iterator<Item = B> + Clone, B: Borrow<Item<'a>>> DelayedFormat<I> {

/// Makes a new `DelayedFormat` value out of local date and time and locale.
#[cfg(feature = "unstable-locales")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-locales")))]
#[must_use]
pub fn new_with_locale(
date: Option<NaiveDate>,
Expand All @@ -116,7 +114,6 @@ impl<'a, I: Iterator<Item = B> + Clone, B: Borrow<Item<'a>>> DelayedFormat<I> {

/// Makes a new `DelayedFormat` value out of local date and time, UTC offset and locale.
#[cfg(feature = "unstable-locales")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-locales")))]
#[must_use]
pub fn new_with_offset_and_locale<Off>(
date: Option<NaiveDate>,
Expand Down Expand Up @@ -157,7 +154,6 @@ impl<'a, I: Iterator<Item = B> + Clone, B: Borrow<Item<'a>>> fmt::Display for De
/// Tries to format given arguments with given formatting items.
/// Internally used by `DelayedFormat`.
#[cfg(any(feature = "alloc", feature = "std"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "std"))))]
pub fn format<'a, I, B>(
w: &mut fmt::Formatter,
date: Option<&NaiveDate>,
Expand All @@ -177,7 +173,6 @@ where
}
/// Formats single formatting item
#[cfg(any(feature = "alloc", feature = "std"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "std"))))]
pub fn format_item(
w: &mut fmt::Formatter,
date: Option<&NaiveDate>,
Expand All @@ -193,7 +188,6 @@ 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")))]
pub fn format_localized<'a, I, B>(
w: &mut fmt::Formatter,
date: Option<&NaiveDate>,
Expand All @@ -215,7 +209,6 @@ where

/// Formats single formatting item
#[cfg(feature = "unstable-locales")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-locales")))]
pub fn format_item_localized(
w: &mut fmt::Formatter,
date: Option<&NaiveDate>,
Expand Down
3 changes: 0 additions & 3 deletions src/format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,11 @@ pub enum Item<'a> {
Literal(&'a str),
/// Same as `Literal` but with the string owned by the item.
#[cfg(any(feature = "alloc", feature = "std"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "std"))))]
OwnedLiteral(Box<str>),
/// Whitespace. Prints literally but reads zero or more whitespace.
Space(&'a str),
/// Same as `Space` but with the string owned by the item.
#[cfg(any(feature = "alloc", feature = "std"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "std"))))]
OwnedSpace(Box<str>),
/// Numeric item. Can be optionally padded to the maximal length (if any) when formatting;
/// the parser simply ignores any padded whitespace and zeroes.
Expand Down Expand Up @@ -437,7 +435,6 @@ impl fmt::Display for ParseError {
}

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl Error for ParseError {
#[allow(deprecated)]
fn description(&self) -> &str {
Expand Down
1 change: 0 additions & 1 deletion src/format/strftime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ impl<'a> StrftimeItems<'a> {

/// Creates a new parsing iterator from the `strftime`-like format string.
#[cfg(feature = "unstable-locales")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-locales")))]
#[must_use]
pub const fn new_with_locale(s: &'a str, locale: Locale) -> StrftimeItems<'a> {
StrftimeItems { remainder: s, queue: &[], locale_str: "", locale: Some(locale) }
Expand Down
Loading
Loading