Why does Rust Analyser disagree with the compiler?

259 Views Asked by At

I'm using the latest stable version: rustc 1.46.0 (04488afe3 2020-08-24).

Rust Analyser needs the import:

use chrono::offset::TimeZone;

in order to accept the expression:

Utc.ymd(1970, 1, 1).and_hms_milli(0, 0, 0, 200)

(It highlights the .ymd as {unknown}.)

If I add the import, the compiler issues a warning:

   Compiling foo v0.1.0 (/home/fadedbee/foo)
warning: unused import: `chrono::offset::TimeZone`
 --> src/bar.rs:2:5
  |
2 | use chrono::offset::TimeZone;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

How can I make Rust Analyser (in vscode), and the compiler, both happy?


Update:

As rodrigo correctly deduced, the only uses of .ymd are within a #[cfg(test)] section.

0

There are 0 best solutions below