Skip to content

Type inference that worked on 0.3.17 fails on versions ≥ 0.3.19 #552

Closed
@nmathewson

Description

@nmathewson

Hello!

It looks like the following code, which used to work fine on time 0.3.17, now fails on 0.3.18 and 0.3.19:

use std::time::SystemTime;
use time::ext::NumericalDuration;
use time::OffsetDateTime;

fn main() {
    let now = OffsetDateTime::now_utc();
    let one_hour = 1.hours();

    let _: SystemTime = (now+one_hour*2).into();
}

It gives this error:

   Compiling test-time v0.1.0 (/home/nickm/src/test-time)
error[E0282]: type annotations needed
 --> src/main.rs:9:25
  |
9 |     let _: SystemTime = (now+one_hour*2).into();
  |                         ^^^^^^^^^^^^^^^^ cannot infer type

The last line works fine if you remove the * 2, or if you replace one_hour * 2 with 2.hours(), or if you replace the whole expression with SystemTime::from(now+one_hour*2).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-coreArea: anything not otherwise coveredC-bugCategory: bug in current codeE-hardSignificant experience needed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions