Compiling with most recent version of chrono 0.4.36 causes compilation error.
Steps to Reproduce
Create a new rust project and add this to Cargo.toml
[package]
name = "testing"
version = "0.1.0"
edition = "2021"
[dependencies]
chrono-tz = "0.8.6"
2. Add the following code to `src/main.rs` file
```rust
use chrono_tz::US::Pacific;
fn main() {
let pacific_time = Pacific.ymd(1990, 5, 6).and_hms(12, 30, 45);
}
run cargo check to see the compilation error.
Expected behavior
The program should compile normally.
Error
error[E0432]: unresolved import `chrono::LocalResult`
--> chrono-tz/src/timezone_impl.rs:318:21
|
318 | use chrono::LocalResult::*;
| ^^^^^^^^^^^ `LocalResult` is a type alias, not a module
error[E0531]: cannot find tuple struct or tuple variant `Single` in this scope
--> chrono-tz/src/timezone_impl.rs:320:23
|
320 | (result @ Single(_), _) => result,
| ^^^^^^ not found in this scope
|
help: consider importing this tuple variant
|
1 + use chrono::MappedLocalTime::Single;
|
error[E0531]: cannot find tuple struct or tuple variant `Single` in this scope
--> chrono-tz/src/timezone_impl.rs:321:26
|
321 | (_, result @ Single(_)) => result,
| ^^^^^^ not found in this scope
|
help: consider importing this tuple variant
|
1 + use chrono::MappedLocalTime::Single;
|
error[E0531]: cannot find tuple struct or tuple variant `Ambiguous` in this scope
--> chrono-tz/src/timezone_impl.rs:322:14
|
322 | (Ambiguous(offset, _), _) => Single(offset),
| ^^^^^^^^^ not found in this scope
|
help: consider importing this tuple variant
|
1 + use chrono::MappedLocalTime::Ambiguous;
|
error[E0425]: cannot find function, tuple struct or tuple variant `Single` in this scope
--> chrono-tz/src/timezone_impl.rs:322:42
|
322 | (Ambiguous(offset, _), _) => Single(offset),
| ^^^^^^ not found in this scope
|
help: consider importing this tuple variant
|
1 + use chrono::MappedLocalTime::Single;
|
error[E0531]: cannot find tuple struct or tuple variant `Ambiguous` in this scope
--> chrono-tz/src/timezone_impl.rs:323:17
|
323 | (_, Ambiguous(offset, _)) => Single(offset),
| ^^^^^^^^^ not found in this scope
|
help: consider importing this tuple variant
|
1 + use chrono::MappedLocalTime::Ambiguous;
|
error[E0425]: cannot find function, tuple struct or tuple variant `Single` in this scope
--> chrono-tz/src/timezone_impl.rs:323:42
|
323 | (_, Ambiguous(offset, _)) => Single(offset),
| ^^^^^^ not found in this scope
|
help: consider importing this tuple variant
|
1 + use chrono::MappedLocalTime::Single;
|
error[E0308]: mismatched types
--> chrono-tz/src/timezone_impl.rs:324:14
|
319 | match (earliest, latest) {
| ------------------ this expression has type `(MappedLocalTime<TzOffset>, MappedLocalTime<TzOffset>)`
...
324 | (None, None) => None,
| ^^^^ expected `MappedLocalTime<TzOffset>`, found `Option<_>`
|
= note: expected enum `MappedLocalTime<TzOffset>`
found enum `Option<_>`
error[E0308]: mismatched types
--> chrono-tz/src/timezone_impl.rs:324:20
|
319 | match (earliest, latest) {
| ------------------ this expression has type `(MappedLocalTime<TzOffset>, MappedLocalTime<TzOffset>)`
...
324 | (None, None) => None,
| ^^^^ expected `MappedLocalTime<TzOffset>`, found `Option<_>`
|
= note: expected enum `MappedLocalTime<TzOffset>`
found enum `Option<_>`
Fix
// chrono-tz/src/timezone_impl.rs
use chrono::MappedLocalTime::{Ambiguous, Single};
// line 289
#[allow(deprecated)]
fn offset_from_local_date(&self, local: &NaiveDate) -> LocalResult<Self::Offset> {
let earliest = self.offset_from_local_datetime(&local.and_time(NaiveTime::MIN));
let latest = self.offset_from_local_datetime(&local.and_hms_opt(23, 59, 59).unwrap());
// comments...
match (earliest, latest) {
(result @ Single(_), _) => result,
(_, result @ Single(_)) => result,
(Ambiguous(offset, _), _) => Single(offset),
(_, Ambiguous(offset, _)) => Single(offset),
(LocalResult::None, LocalResult::None) => LocalResult::None,
}
}
Description
Compiling with most recent version of
chrono 0.4.36
causes compilation error.Steps to Reproduce
Cargo.toml
[dependencies] chrono-tz = "0.8.6"
cargo check
to see the compilation error.Expected behavior
The program should compile normally.
Error
Fix