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

[CI] Lint Windows target and documentation links #1062

Merged
merged 6 commits into from
May 15, 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
26 changes: 19 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-gnu, x86_64-pc-windows-msvc
- uses: Swatinem/rust-cache@v2
- run: |
cargo fmt --check -- --color=always
cargo fmt --check --manifest-path fuzz/Cargo.toml
- run: |
cargo clippy --color=always -- -D warnings -A clippy::manual-non-exhaustive
cargo clippy --manifest-path fuzz/Cargo.toml --color=always -- -D warnings
- run: cargo fmt --check -- --color=always
- run: cargo fmt --check --manifest-path fuzz/Cargo.toml
- run: cargo clippy --color=always -- -D warnings
djc marked this conversation as resolved.
Show resolved Hide resolved
- run: cargo clippy --color=always --target x86_64-pc-windows-msvc -- -D warnings
- run: cargo clippy --manifest-path fuzz/Cargo.toml --color=always -- -D warnings
env:
RUSTFLAGS: "-Dwarnings"

Expand All @@ -27,3 +28,14 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: EmbarkStudios/cargo-deny-action@v1

check-doc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- run: cargo install cargo-deadlinks
- run: RUSTFLAGS="--cfg docsrs" cargo deadlinks -- --features=serde
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is also a good thing to test 👍

- run: cargo doc --all-features --no-deps
env:
RUSTDOCFLAGS: -Dwarnings
22 changes: 11 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
tz: ["ACST-9:30", "EST4", "UTC0", "Asia/Katmandu"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo test --all-features --color=always -- --color=always
Expand All @@ -25,7 +25,7 @@ jobs:
tz: ["ACST-9:30", "EST4", "UTC0", "Asia/Katmandu"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo test --lib --all-features --color=always -- --color=always
Expand All @@ -40,7 +40,7 @@ jobs:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.56.1
Expand All @@ -56,7 +56,7 @@ jobs:
rust_version: ["stable", "beta", "nightly"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust_version }}
Expand All @@ -73,7 +73,7 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@cargo-hack
- uses: Swatinem/rust-cache@v2
Expand All @@ -88,7 +88,7 @@ jobs:
target: [thumbv6m-none-eabi, x86_64-fortanix-unknown-sgx]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
Expand All @@ -103,12 +103,12 @@ jobs:
target: [wasm32-unknown-unknown, wasm32-wasi, wasm32-unknown-emscripten, aarch64-apple-ios, aarch64-linux-android]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v3
with:
node-version: "12"
- run: |
Expand All @@ -123,7 +123,7 @@ jobs:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
Expand All @@ -138,15 +138,15 @@ jobs:
- x86_64-sun-solaris
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: cargo install cross
- uses: Swatinem/rust-cache@v2
- run: cross check --target ${{ matrix.target }}

check-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
- run: cargo +nightly doc --all-features --no-deps
env:
Expand Down
15 changes: 9 additions & 6 deletions src/naive/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ impl Days {
}

/// ISO 8601 calendar date without timezone.
/// Allows for every [proleptic Gregorian date](#calendar-date)
/// from Jan 1, 262145 BCE to Dec 31, 262143 CE.
/// Allows for every [proleptic Gregorian date] from Jan 1, 262145 BCE to Dec 31, 262143 CE.
/// Also supports the conversion from ISO 8601 ordinal and week date.
///
/// # Calendar Date
Expand Down Expand Up @@ -186,6 +185,8 @@ impl Days {
/// The year number is the same as that of the [calendar date](#calendar-date).
///
/// This is currently the internal format of Chrono's date types.
///
/// [proleptic Gregorian date]: crate::NaiveDate#calendar-date
#[derive(PartialEq, Eq, Hash, PartialOrd, Ord, Copy, Clone)]
#[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize))]
pub struct NaiveDate {
Expand Down Expand Up @@ -1654,8 +1655,7 @@ impl Datelike for NaiveDate {
/// An addition of `Duration` to `NaiveDate` discards the fractional days,
/// rounding to the closest integral number of days towards `Duration::zero()`.
///
/// Panics on underflow or overflow.
/// Use [`NaiveDate::checked_add_signed`](#method.checked_add_signed) to detect that.
/// Panics on underflow or overflow. Use [`NaiveDate::checked_add_signed`] to detect that.
///
/// # Example
///
Expand All @@ -1673,6 +1673,8 @@ impl Datelike for NaiveDate {
/// assert_eq!(from_ymd(2014, 1, 1) + Duration::days(365*4 + 1), from_ymd(2018, 1, 1));
/// assert_eq!(from_ymd(2014, 1, 1) + Duration::days(365*400 + 97), from_ymd(2414, 1, 1));
/// ```
///
/// [`NaiveDate::checked_add_signed`]: crate::NaiveDate::checked_add_signed
impl Add<OldDuration> for NaiveDate {
type Output = NaiveDate;

Expand Down Expand Up @@ -1762,8 +1764,7 @@ impl Sub<Days> for NaiveDate {
/// rounding to the closest integral number of days towards `Duration::zero()`.
/// It is the same as the addition with a negated `Duration`.
///
/// Panics on underflow or overflow.
/// Use [`NaiveDate::checked_sub_signed`](#method.checked_sub_signed) to detect that.
/// Panics on underflow or overflow. Use [`NaiveDate::checked_sub_signed`] to detect that.
///
/// # Example
///
Expand All @@ -1781,6 +1782,8 @@ impl Sub<Days> for NaiveDate {
/// assert_eq!(from_ymd(2014, 1, 1) - Duration::days(365*4 + 1), from_ymd(2010, 1, 1));
/// assert_eq!(from_ymd(2014, 1, 1) - Duration::days(365*400 + 97), from_ymd(1614, 1, 1));
/// ```
///
/// [`NaiveDate::checked_sub_signed`]: crate::NaiveDate::checked_sub_signed
impl Sub<OldDuration> for NaiveDate {
type Output = NaiveDate;

Expand Down
20 changes: 11 additions & 9 deletions src/naive/datetime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ impl NaiveDateTime {
}

impl Datelike for NaiveDateTime {
/// Returns the year number in the [calendar date](./index.html#calendar-date).
/// Returns the year number in the [calendar date](./struct.NaiveDate.html#calendar-date).
///
/// See also the [`NaiveDate::year`] method.
///
Expand Down Expand Up @@ -1377,10 +1377,9 @@ impl Timelike for NaiveDateTime {

/// An addition of `Duration` to `NaiveDateTime` yields another `NaiveDateTime`.
///
/// As a part of Chrono's [leap second handling](./struct.NaiveTime.html#leap-second-handling),
/// the addition assumes that **there is no leap second ever**,
/// except when the `NaiveDateTime` itself represents a leap second
/// in which case the assumption becomes that **there is exactly a single leap second ever**.
/// As a part of Chrono's [leap second handling], the addition assumes that **there is no leap
/// second ever**, except when the `NaiveDateTime` itself represents a leap second in which case
/// the assumption becomes that **there is exactly a single leap second ever**.
///
/// Panics on underflow or overflow. Use [`NaiveDateTime::checked_add_signed`]
/// to detect that.
Expand Down Expand Up @@ -1424,6 +1423,8 @@ impl Timelike for NaiveDateTime {
/// assert_eq!(leap + Duration::days(1),
/// from_ymd(2016, 7, 9).and_hms_milli_opt(3, 5, 59, 300).unwrap());
/// ```
///
/// [leap second handling]: crate::NaiveTime#leap-second-handling
impl Add<OldDuration> for NaiveDateTime {
type Output = NaiveDateTime;

Expand Down Expand Up @@ -1488,10 +1489,9 @@ impl Add<Months> for NaiveDateTime {
/// A subtraction of `Duration` from `NaiveDateTime` yields another `NaiveDateTime`.
/// It is the same as the addition with a negated `Duration`.
///
/// As a part of Chrono's [leap second handling](./struct.NaiveTime.html#leap-second-handling),
/// the addition assumes that **there is no leap second ever**,
/// except when the `NaiveDateTime` itself represents a leap second
/// in which case the assumption becomes that **there is exactly a single leap second ever**.
/// As a part of Chrono's [leap second handling] the subtraction assumes that **there is no leap
/// second ever**, except when the `NaiveDateTime` itself represents a leap second in which case
/// the assumption becomes that **there is exactly a single leap second ever**.
///
/// Panics on underflow or overflow. Use [`NaiveDateTime::checked_sub_signed`]
/// to detect that.
Expand Down Expand Up @@ -1533,6 +1533,8 @@ impl Add<Months> for NaiveDateTime {
/// assert_eq!(leap - Duration::days(1),
/// from_ymd(2016, 7, 7).and_hms_milli_opt(3, 6, 0, 300).unwrap());
/// ```
///
/// [leap second handling]: crate::NaiveTime#leap-second-handling
impl Sub<OldDuration> for NaiveDateTime {
type Output = NaiveDateTime;

Expand Down
18 changes: 10 additions & 8 deletions src/naive/time/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -987,10 +987,9 @@ impl Timelike for NaiveTime {
/// An addition of `Duration` to `NaiveTime` wraps around and never overflows or underflows.
/// In particular the addition ignores integral number of days.
///
/// As a part of Chrono's [leap second handling](#leap-second-handling),
/// the addition assumes that **there is no leap second ever**,
/// except when the `NaiveTime` itself represents a leap second
/// in which case the assumption becomes that **there is exactly a single leap second ever**.
/// As a part of Chrono's [leap second handling], the addition assumes that **there is no leap
/// second ever**, except when the `NaiveTime` itself represents a leap second in which case the
/// assumption becomes that **there is exactly a single leap second ever**.
///
/// # Example
///
Expand Down Expand Up @@ -1033,6 +1032,8 @@ impl Timelike for NaiveTime {
/// assert_eq!(leap + Duration::seconds(-10), from_hmsm(3, 5, 50, 300));
/// assert_eq!(leap + Duration::days(1), from_hmsm(3, 5, 59, 300));
/// ```
///
/// [leap second handling]: crate::NaiveTime#leap-second-handling
impl Add<OldDuration> for NaiveTime {
type Output = NaiveTime;

Expand All @@ -1053,10 +1054,9 @@ impl AddAssign<OldDuration> for NaiveTime {
/// In particular the addition ignores integral number of days.
/// It is the same as the addition with a negated `Duration`.
///
/// As a part of Chrono's [leap second handling](#leap-second-handling),
/// the addition assumes that **there is no leap second ever**,
/// except when the `NaiveTime` itself represents a leap second
/// in which case the assumption becomes that **there is exactly a single leap second ever**.
/// As a part of Chrono's [leap second handling], the subtraction assumes that **there is no leap
/// second ever**, except when the `NaiveTime` itself represents a leap second in which case the
/// assumption becomes that **there is exactly a single leap second ever**.
///
/// # Example
///
Expand Down Expand Up @@ -1094,6 +1094,8 @@ impl AddAssign<OldDuration> for NaiveTime {
/// assert_eq!(leap - Duration::seconds(60), from_hmsm(3, 5, 0, 300));
/// assert_eq!(leap - Duration::days(1), from_hmsm(3, 6, 0, 300));
/// ```
///
/// [leap second handling]: crate::NaiveTime#leap-second-handling
impl Sub<OldDuration> for NaiveTime {
type Output = NaiveTime;

Expand Down
3 changes: 2 additions & 1 deletion src/offset/local/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ impl LocalSysTime {

let date =
NaiveDate::from_ymd_opt(st.wYear as i32, st.wMonth as u32, st.wDay as u32).unwrap();
let time = NaiveTime::from_hms(st.wHour as u32, st.wMinute as u32, st.wSecond as u32);
let time =
NaiveTime::from_hms_opt(st.wHour as u32, st.wMinute as u32, st.wSecond as u32).unwrap();

let offset = FixedOffset::east_opt(self.offset).unwrap();
DateTime::from_utc(date.and_time(time) - offset, offset)
Expand Down