time-rs / time

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

Renaming of `FormatItem` is a breaking change #675

Closed arkeet closed 2 months ago

arkeet commented 3 months ago

I noticed sqlx-sqlite (0.7.4) does not build with 0.3.35 (but built with 0.3.34):

error[E0432]: unresolved import `time::format_description::FormatItem`
   --> .../sqlx-sqlite-0.7.4/src/types/time.rs:192:72
    |
192 |     use time::format_description::{modifier, Component::*, FormatItem, FormatItem::*};
    |                                                                        ^^^^^^^^^^ `FormatItem` is a type alias, not a module

So evidently replacing an enum with a type alias is a breaking change. One possible fix is to replace the type alias with a re-export i.e. pub use BorrowedFormatItem as FormatItem;, but unfortunately deprecating re-exports doesn't work: https://github.com/rust-lang/rust/issues/30827

obi1kenobi commented 3 months ago

A few folks have asked me directly, so for posterity: cargo-semver-checks would not have caught this today.

This is a breaking but not semver-major change, so it should be a "warn" or opt-in lint. cargo-semver-checks doesn't currently have such a capability, but it's something we're planning to add in the immediate future. After that, cargo-semver-checks will catch it and many more similar hazards (see "opt-in warnings" sections here).

obi1kenobi commented 3 months ago

Tangentially, if the maintainers of this repo might be interested in adopting cargo-semver-checks, I'd be happy to open a PR for it.

jhpratt commented 2 months ago

If I pub use the item rather than pub type, that would solve this? Ignoring the fact that use items cannot be deprecated.

obi1kenobi commented 2 months ago

Yes, it would: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=ab4fb87dddb1e161fcfefd8e8d4e2190

jhpratt commented 2 months ago

This has been fixed and released. FormatItem is now re-exported via pub use, with pub type remaining in place for documentation purposes (namely showing the deprecation).