Skip to content

Remove unnessary Copy and Send impls#1492

Merged
djc merged 1 commit intochronotope:mainfrom
erickt:remove-trait
Mar 7, 2024
Merged

Remove unnessary Copy and Send impls#1492
djc merged 1 commit intochronotope:mainfrom
erickt:remove-trait

Conversation

@erickt
Copy link
Copy Markdown
Contributor

@erickt erickt commented Mar 7, 2024

Fuchsia is doing an audit of chrono 0.4.34, and we noticed an unncessary unsafe of Send for DateTime. While it's valid since Tz::Offset is Send, and NaiveDateTime only has u32 fields, there's a potential hazard if NaiveDateTime ever grows unsendable fields (unlikely as that is).

This (and the Copy impl) were added 9 years ago to fix #25, which stemmed from early versions of associate traits not working properly with auto-traits. This has since been fixed, and is no longer necessary with the MSRV 1.61.0.

To make sure this stays working, it includes a test that makes sure that DateTime<Utc> is Send and Copy just to be safe.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.80%. Comparing base (3114597) to head (ee48d16).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1492   +/-   ##
=======================================
  Coverage   91.80%   91.80%           
=======================================
  Files          40       40           
  Lines       18329    18336    +7     
=======================================
+ Hits        16827    16834    +7     
  Misses       1502     1502           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Fuchsia is doing an audit of chrono 0.4.34, and we noticed an unncessary
unsafe of `Send` for `DateTime`. While it's valid since `Tz::Offset` is
`Send`, and `NaiveDateTime` only has `u32` fields, there's a potential
hazard if `NaiveDateTime` ever grows unsendable fields (unlikely as that
is).

This (and the `Copy` impl) were added 9 years ago to fix chronotope#25, which
stemmed from early versions of associate traits not working properly
with auto-traits. This has since been fixed, and is no longer necessary
with the MSRV 1.61.0.
Copy link
Copy Markdown
Member

@djc djc left a comment

Choose a reason for hiding this comment

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

Great, thanks!

@djc djc merged commit e79fe21 into chronotope:main Mar 7, 2024
Comment thread src/datetime/tests.rs
}

#[test]
fn test_datetime_utc_is_copy_and_send() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We have the same test ca. 600 lines above.

@djc djc mentioned this pull request Mar 7, 2024
@djc
Copy link
Copy Markdown
Member

djc commented Mar 7, 2024

Removing the duplicate test in #1494.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UTC Offset is not Send (cannot send DateTime across mps::channel)

3 participants