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

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

Closed
chklauser opened this issue Feb 26, 2015 · 1 comment · Fixed by #1492
Closed

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

chklauser opened this issue Feb 26, 2015 · 1 comment · Fixed by #1492

Comments

@chklauser
Copy link

I have a struct with a DateTime<UTC> field that I would like to send across a channel, like this:

pub struct Signal {
  pub time: DateTime<UTC>,
  pub raw: String
}

But when I want to create the channel, rustc complains that

error: the trait `core::marker::Send` is not implemented for the type `<chrono::offset::utc::UTC as chrono::offset::TimeZone>::Offset` [    E0277]    

let (new_signal_sender, new_signal_rcvr) = channel::<Signal>();
                                           ^~~~~~~~~~~~~~~~~
note: `<chrono::offset::utc::UTC as chrono::offset::TimeZone>::Offset` cannot be sent between threads safely
let (new_signal_sender, new_signal_rcvr) = channel::<Signal>();

Now Send is easily the part of Rust I understand the least, but I would have expected a DateTime object to be "sendable".

@lifthrasiir
Copy link
Contributor

Thank you for reporting. Chrono 0.2.3 fixed this issue.

erickt added a commit to erickt/chrono that referenced this issue 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 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.
erickt added a commit to erickt/chrono that referenced this issue 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 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.
djc pushed a commit that referenced this issue 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.
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 a pull request may close this issue.

2 participants