time-rs / time

The most used Rust library for date and time handling.
https://time-rs.github.io
Apache License 2.0
1.13k stars 281 forks source link

Confusing deprecation message for `time::Instant` #677

Closed johnbatty closed 7 months ago

johnbatty commented 7 months ago

time::Instant was deprecated in 0.3.35: https://github.com/time-rs/time/issues/650

The deprecation error message displayed by clippy is:

error: use of deprecated struct `time::Instant`: import `time::ext::InstantExt` instead

This is confusing advice, as the primary fix is to use std::time::Instant rather than time::Instant. It took me a while to figure this out. There are some additional extension methods defined in time::ext::InstantExt, but these won't be required by most users.

I suggest that the error is changed to:

error: use of deprecated struct `time::Instant`: import `std::time::Instant` instead
jhpratt commented 7 months ago

I'm open to changing the deprecation message, but my initial thought is why you're using time::Instant instead of std::time::Instant if you're not using any of the additional interoperability time provides? It is otherwise a trivial wrapper struct.

johnbatty commented 7 months ago

It wasn't a conscious decision to pick time::Instant over std::time::Instant. I just happened to be already using the time crate (for formatting) and saw that it included Instant. So I'm happy to switch (and already have).

jhpratt commented 7 months ago

The deprecation message has been changed on main.