From 5b110898ec6572b04d08949ed05ea466c8ae86ff Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Thu, 15 Aug 2024 10:42:35 -0400 Subject: [PATCH] lint: remove ambiguous_negative_literal allow's in doc tests In favor of a global one. But also, while these aren't technically needed any more[1,2], we leave them be for now while things settle. [1]: https://github.com/rust-lang/rust/pull/128449 [2]: https://github.com/rust-lang/rust/issues/128287 --- src/civil/date.rs | 24 ------------------------ src/civil/datetime.rs | 20 -------------------- src/civil/time.rs | 6 ------ src/lib.rs | 2 ++ src/span.rs | 26 -------------------------- src/timestamp.rs | 16 ---------------- src/tz/offset.rs | 8 -------- src/zoned.rs | 20 -------------------- 8 files changed, 2 insertions(+), 120 deletions(-) diff --git a/src/civil/date.rs b/src/civil/date.rs index 79d84fc..ee56cbe 100644 --- a/src/civil/date.rs +++ b/src/civil/date.rs @@ -1367,8 +1367,6 @@ impl Date { /// # Example: negative spans are supported /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::Date, ToSpan}; /// /// let d = Date::constant(2024, 3, 31); @@ -1382,8 +1380,6 @@ impl Date { /// # Example: error on overflow /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::Date, ToSpan}; /// /// let d = Date::constant(2024, 3, 31); @@ -1475,8 +1471,6 @@ impl Date { /// # Example: negative spans are supported /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::Date, ToSpan}; /// /// let d = Date::constant(2024, 3, 31); @@ -1490,8 +1484,6 @@ impl Date { /// # Example: error on overflow /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::Date, ToSpan}; /// /// let d = Date::constant(2024, 3, 31); @@ -1543,8 +1535,6 @@ impl Date { /// # Example: negative spans are supported /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::Date, ToSpan}; /// /// let d = Date::constant(2024, 3, 31); @@ -1557,8 +1547,6 @@ impl Date { /// # Example: saturation on overflow /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::Date, ToSpan}; /// /// let d = Date::constant(2024, 3, 31); @@ -1616,8 +1604,6 @@ impl Date { /// # Example: negative spans are supported /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::Date, ToSpan}; /// /// let d = Date::constant(2024, 3, 31); @@ -1630,8 +1616,6 @@ impl Date { /// # Example: saturation on overflow /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::Date, ToSpan}; /// /// let d = Date::constant(2024, 3, 31); @@ -1685,8 +1669,6 @@ impl Date { /// # Examples /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::Date, ToSpan}; /// /// let earlier = Date::constant(2006, 8, 24); @@ -1857,8 +1839,6 @@ impl Date { /// # Examples /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::Date, ToSpan}; /// /// let earlier = Date::constant(2006, 8, 24); @@ -2055,8 +2035,6 @@ impl Date { /// When did the most recent Friday the 13th occur? /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::{Date, Weekday}, ToSpan}; /// /// let start = Date::constant(2024, 3, 13); @@ -2711,8 +2689,6 @@ impl DateDifference { /// This shows how to always round "up" towards positive infinity. /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::{Date, DateDifference}, RoundMode, ToSpan, Unit}; /// /// let d1 = "2024-01-15".parse::()?; diff --git a/src/civil/datetime.rs b/src/civil/datetime.rs index c764572..327b68a 100644 --- a/src/civil/datetime.rs +++ b/src/civil/datetime.rs @@ -1482,8 +1482,6 @@ impl DateTime { /// # Example: negative spans are supported /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::date, ToSpan}; /// /// let dt = date(2024, 3, 31).at(19, 5, 59, 999_999_999); @@ -1498,8 +1496,6 @@ impl DateTime { /// # Example: error on overflow /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::date, ToSpan}; /// /// let dt = date(2024, 3, 31).at(13, 13, 13, 13); @@ -1585,8 +1581,6 @@ impl DateTime { /// # Example: negative spans are supported /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::date, ToSpan}; /// /// let dt = date(2024, 3, 31).at(19, 5, 59, 999_999_999); @@ -1601,8 +1595,6 @@ impl DateTime { /// # Example: error on overflow /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::date, ToSpan}; /// /// let dt = date(2024, 3, 31).at(13, 13, 13, 13); @@ -1650,8 +1642,6 @@ impl DateTime { /// # Example: negative spans are supported /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::date, ToSpan}; /// /// let dt = date(2024, 3, 31).at(19, 5, 59, 999_999_999); @@ -1664,8 +1654,6 @@ impl DateTime { /// # Example: saturation on overflow /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::{DateTime, date}, ToSpan}; /// /// let dt = date(2024, 3, 31).at(13, 13, 13, 13); @@ -1720,8 +1708,6 @@ impl DateTime { /// # Example: negative spans are supported /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::date, ToSpan}; /// /// let dt = date(2024, 3, 31).at(19, 5, 59, 999_999_999); @@ -1734,8 +1720,6 @@ impl DateTime { /// # Example: saturation on overflow /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::{DateTime, date}, ToSpan}; /// /// let dt = date(2024, 3, 31).at(13, 13, 13, 13); @@ -1796,8 +1780,6 @@ impl DateTime { /// # Example /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::date, ToSpan}; /// /// let earlier = date(2006, 8, 24).at(22, 30, 0, 0); @@ -1968,8 +1950,6 @@ impl DateTime { /// # Example /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::date, ToSpan}; /// /// let earlier = date(2006, 8, 24).at(22, 30, 0, 0); diff --git a/src/civil/time.rs b/src/civil/time.rs index 5e5025b..37c512d 100644 --- a/src/civil/time.rs +++ b/src/civil/time.rs @@ -1180,8 +1180,6 @@ impl Time { /// # Examples /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::Time, ToSpan}; /// /// let t1 = Time::constant(22, 35, 1, 0); @@ -1269,8 +1267,6 @@ impl Time { /// # Examples /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::Time, ToSpan}; /// /// let t1 = Time::constant(22, 35, 1, 0); @@ -1472,8 +1468,6 @@ impl Time { /// Or go backwards every 6.5 hours: /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::Time, ToSpan}; /// /// let start = Time::constant(23, 0, 0, 0); diff --git a/src/lib.rs b/src/lib.rs index 299837a..9e07fe7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -606,6 +606,8 @@ specifiers and other APIs. #![deny(missing_docs)] // See: https://github.com/rust-lang/rust/pull/121364 #![allow(unknown_lints, ambiguous_negative_literals)] +// See: https://github.com/rust-lang/rust/pull/121364 +#![doc(test(attr(allow(unknown_lints, ambiguous_negative_literals))))] // It should be possible to support other pointer widths, but this library // hasn't been tested nor thought about much in contexts with pointers less diff --git a/src/span.rs b/src/span.rs index 52d1ce9..528b488 100644 --- a/src/span.rs +++ b/src/span.rs @@ -95,8 +95,6 @@ use crate::{ /// A span may be negative. All of these are equivalent: /// /// ``` -/// # // See: https://github.com/rust-lang/rust/pull/121364 -/// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{Span, ToSpan}; /// /// let span = -Span::new().days(5); @@ -125,8 +123,6 @@ use crate::{ /// then all of its units are negative: /// /// ``` -/// # // See: https://github.com/rust-lang/rust/pull/121364 -/// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::ToSpan; /// /// let span = -5.days().hours(10).minutes(1); @@ -139,8 +135,6 @@ use crate::{ /// as negative: /// /// ``` -/// # // See: https://github.com/rust-lang/rust/pull/121364 -/// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::ToSpan; /// /// // It's the same thing. @@ -552,8 +546,6 @@ use crate::{ /// span positive before converting it to a `Duration`: /// /// ``` -/// # // See: https://github.com/rust-lang/rust/pull/121364 -/// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use std::time::Duration; /// /// use jiff::{Span, ToSpan}; @@ -1165,8 +1157,6 @@ impl Span { /// # Example /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::ToSpan; /// /// let span = -100.seconds(); @@ -1232,8 +1222,6 @@ impl Span { /// # Example /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::ToSpan; /// /// assert!(!2.months().is_negative()); @@ -1251,8 +1239,6 @@ impl Span { /// # Example /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::ToSpan; /// /// assert!(!2.months().is_negative()); @@ -1289,8 +1275,6 @@ impl Span { /// # Example /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::ToSpan; /// /// let span = 4.days().seconds(8); @@ -1312,8 +1296,6 @@ impl Span { /// happens on overflow. /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::ToSpan; /// /// let span = 4.days().seconds(8); @@ -1678,8 +1660,6 @@ impl Span { /// # Example: negative spans are less than zero /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::ToSpan; /// /// let span1 = -1.second(); @@ -2080,8 +2060,6 @@ impl Span { /// the span positive before converting it to a `Duration`: /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use std::time::Duration; /// /// use jiff::{civil::date, Span, ToSpan}; @@ -2984,8 +2962,6 @@ impl core::ops::Mul for i64 { /// span positive before converting it to a `Duration`: /// /// ``` -/// # // See: https://github.com/rust-lang/rust/pull/121364 -/// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use std::time::Duration; /// /// use jiff::{Span, ToSpan}; @@ -3235,8 +3211,6 @@ impl quickcheck::Arbitrary for Span { /// # Example /// /// ``` -/// # // See: https://github.com/rust-lang/rust/pull/121364 -/// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::ToSpan; /// /// assert_eq!(5.days().to_string(), "P5d"); diff --git a/src/timestamp.rs b/src/timestamp.rs index 5d13ec7..11fdd39 100644 --- a/src/timestamp.rs +++ b/src/timestamp.rs @@ -1223,8 +1223,6 @@ impl Timestamp { /// as subtracting `5` hours from the Unix epoch. /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{Timestamp, ToSpan}; /// /// let ts = Timestamp::UNIX_EPOCH.checked_add(-5.hours())?; @@ -1253,8 +1251,6 @@ impl Timestamp { /// # Example: error on overflow /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{Timestamp, ToSpan}; /// /// let ts = Timestamp::MAX; @@ -1327,8 +1323,6 @@ impl Timestamp { /// same as adding `5` hours from the Unix epoch. /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{Timestamp, ToSpan}; /// /// let ts = Timestamp::UNIX_EPOCH.checked_sub(-5.hours())?; @@ -1357,8 +1351,6 @@ impl Timestamp { /// # Example: error on overflow /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{Timestamp, ToSpan}; /// /// let ts = Timestamp::MIN; @@ -1414,8 +1406,6 @@ impl Timestamp { /// This example shows that arithmetic saturates on overflow. /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{Timestamp, ToSpan}; /// /// assert_eq!( @@ -1460,8 +1450,6 @@ impl Timestamp { /// This example shows that arithmetic saturates on overflow. /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{Timestamp, ToSpan}; /// /// assert_eq!( @@ -1529,8 +1517,6 @@ impl Timestamp { /// # Example /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{Timestamp, ToSpan}; /// /// let earlier: Timestamp = "2006-08-24T22:30:00Z".parse()?; @@ -1676,8 +1662,6 @@ impl Timestamp { /// # Example /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{Timestamp, ToSpan}; /// /// let earlier: Timestamp = "2006-08-24T22:30:00Z".parse()?; diff --git a/src/tz/offset.rs b/src/tz/offset.rs index 7faec35..75d82df 100644 --- a/src/tz/offset.rs +++ b/src/tz/offset.rs @@ -568,8 +568,6 @@ impl Offset { /// This example shows some cases where checked addition will fail. /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{tz::Offset, ToSpan}; /// /// // Adding units above 'hour' always results in an error. @@ -649,8 +647,6 @@ impl Offset { /// This example shows some cases where checked subtraction will fail. /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{tz::Offset, ToSpan}; /// /// // Subtracting units above 'hour' always results in an error. @@ -679,8 +675,6 @@ impl Offset { /// This example shows some cases where saturation will occur. /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{tz::Offset, ToSpan}; /// /// // Adding units above 'day' always results in saturation. @@ -715,8 +709,6 @@ impl Offset { /// This example shows some cases where saturation will occur. /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{tz::Offset, ToSpan}; /// /// // Adding units above 'day' always results in saturation. diff --git a/src/zoned.rs b/src/zoned.rs index d41adcc..99da058 100644 --- a/src/zoned.rs +++ b/src/zoned.rs @@ -1996,8 +1996,6 @@ impl Zoned { /// # Example: negative spans are supported /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::date, ToSpan}; /// /// let zdt = date(2024, 3, 31) @@ -2016,8 +2014,6 @@ impl Zoned { /// # Example: error on overflow /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::date, ToSpan}; /// /// let zdt = date(2024, 3, 31).at(13, 13, 13, 13).intz("America/New_York")?; @@ -2226,8 +2222,6 @@ impl Zoned { /// # Example: negative spans are supported /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::date, ToSpan}; /// /// let zdt = date(2024, 3, 31) @@ -2246,8 +2240,6 @@ impl Zoned { /// # Example: error on overflow /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::date, ToSpan}; /// /// let zdt = date(2024, 3, 31).at(13, 13, 13, 13).intz("America/New_York")?; @@ -2313,8 +2305,6 @@ impl Zoned { /// # Example: negative spans are supported /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::date, ToSpan}; /// /// let zdt = date(2024, 3, 31) @@ -2333,8 +2323,6 @@ impl Zoned { /// # Example: saturation on overflow /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::date, Timestamp, ToSpan}; /// /// let zdt = date(2024, 3, 31).at(13, 13, 13, 13).intz("America/New_York")?; @@ -2407,8 +2395,6 @@ impl Zoned { /// # Example: negative spans are supported /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::date, ToSpan}; /// /// let zdt = date(2024, 3, 31) @@ -2427,8 +2413,6 @@ impl Zoned { /// # Example: saturation on overflow /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::date, Timestamp, ToSpan}; /// /// let zdt = date(2024, 3, 31).at(13, 13, 13, 13).intz("America/New_York")?; @@ -2499,8 +2483,6 @@ impl Zoned { /// # Example /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::date, ToSpan}; /// /// let earlier = date(2006, 8, 24).at(22, 30, 0, 0).intz("America/New_York")?; @@ -2693,8 +2675,6 @@ impl Zoned { /// # Example /// /// ``` - /// # // See: https://github.com/rust-lang/rust/pull/121364 - /// # #![allow(unknown_lints, ambiguous_negative_literals)] /// use jiff::{civil::date, ToSpan}; /// /// let earlier = date(2006, 8, 24).at(22, 30, 0, 0).intz("America/New_York")?;