Yuri6037 / time-tz

Implementation of tz database (IANA) for time Rust crate.
BSD 3-Clause "New" or "Revised" License
22 stars 7 forks source link

rust-analyzer no type inference timezones #15

Closed Zercerium closed 7 months ago

Zercerium commented 1 year ago

Hi,

is it expected that there is no type inference happening? For example if I use let berlin = timezones::db::europe::BERLIN; it shows &{unknown} and also everything behind db:: is not recognised. I'm on Mac and tried the current and the pre-release version of rust-analyzer with rust 1.71. I didn't changed the rust-analyzer settings (rust-analyzer.cargo.buildScripts.enable is true, like default). Builds works fine. Any Suggestion what I could try out?

Yuri6037 commented 1 year ago

Hi, I've just checked and I have the same issue. Interesting note is that it works under CLion. This appears to be a bug in rust analyzer.

Zercerium commented 1 year ago

Ok it seems that the generated timezones.rs file ist just to big and rust-analyzer gives up. If I reduce the entries in tzfiles and don't generate the static WIN_TIMEZONES everything works as expected. (Sometimes you have to restart rust-analyzer after the changes to pick up again)

Yuri6037 commented 1 year ago

if it's only a file size problem I could try to divide up the generator in multiple files.

Zercerium commented 1 year ago

I'm not sure what exactly triggers (file size, symbols in file, ...) the problem and couldn't find a similar issue with a first search.

a novice try with generating the file multiple times with different names and included these files under different mods, got some errors due to the different mods now, worked. (autocompletion and type inference)

the possibility to Limiting the Timezone Table to Zones of Interest like chrono_tz could also help, even if most of unused things should be stripped away at the build process? (probably another issue)

Yuri6037 commented 1 year ago

There is apparently a token limit but the error does not show up under macOS systems: https://github.com/rust-lang/rust-analyzer/issues/15335

Zercerium commented 7 months ago

fixed upstream in rust-analyzer thanks to https://github.com/rust-lang/rust-analyzer/pull/15819