jiff/src
Andrew Gallant b9119a3b21 rangeint: remove PartialEq and PartialOrd impls for i{8,16,32,64,128}
Unfortunately, these impls can cause inference regressions when
non-robust code is written that assumes there is only one
Partial{Eq,Ord} impl for a particular integer type.

It would be one thing if these trait impls were external or somehow
fundamental to Jiff's design. But they only existed as a convenience. So
we remove the trait impls and take our medicine. We already had a
`Constant` wrapper type (also used for trait impls), so we just switch
all equality and inequality comparisons over to that.

I tested this with the following program:

```rust
use env_logger;

fn main() {
    let x: u64 = 1;
    let y: i128 = 0;
    assert!(y < x.into());

    let x: u32 = 1;
    let y: i64 = 0;
    assert!(y < x.into());

    let x: u16 = 1;
    let y: i32 = 0;
    assert!(y < x.into());

    let x: u8 = 1;
    let y: i16 = 0;
    assert!(y < x.into());
}
```

And this `Cargo.toml`:

```toml
[package]
publish = false
name = "jiff-inference-regression"
version = "0.1.0"
edition = "2024"

[patch.crates-io]
jiff = { path = "/home/andrew/rust/jiff/fixit" }

[dependencies]
env_logger = { version = "0.11.7", features = ["humantime"] }

[[bin]]
name = "jiff-inference-regression"
path = "main.rs"

[profile.release]
debug = true
```

I took this path because it's either this or the reporter fixes their
code. Arguably, the reporter should fix their code since it's likely
their code will break when or if some other crate adds similar trait
impls. But as I said, these trait impls are just for convenience, so
the pragmatic trade-off is to remove them and thus not be the source of
whatever problems folks hit.

[I asked the lang team about this problem][lang-zulip-question], and
they seem to agree that this is the right course of action. (And there
are ideas swirling around on how to mitigate this problem, but that's
for the future.)

Fixes #293

[lang-zulip-question]: 504689811
2025-03-10 18:35:16 -04:00
..
civil rangeint: remove PartialEq and PartialOrd impls for i{8,16,32,64,128} 2025-03-10 18:35:16 -04:00
fmt rangeint: remove PartialEq and PartialOrd impls for i{8,16,32,64,128} 2025-03-10 18:35:16 -04:00
shared tz: fix comment and remove superfluous repr(align(..)) 2025-03-07 16:07:01 -05:00
tz rangeint: remove PartialEq and PartialOrd impls for i{8,16,32,64,128} 2025-03-10 18:35:16 -04:00
util rangeint: remove PartialEq and PartialOrd impls for i{8,16,32,64,128} 2025-03-10 18:35:16 -04:00
duration.rs perf: do a ton of optimizations 2025-02-16 15:50:26 -05:00
error.rs shared: move more date algorithms to itime 2025-03-05 18:48:44 -05:00
lib.rs ci: split the "main" job into more pieces 2025-03-06 10:09:11 -05:00
logging.rs first substantial commit 2024-07-21 20:15:13 -04:00
now.rs tz: add support for the Android platform 2025-01-12 15:38:41 -05:00
signed_duration.rs signed_duration: implement Sum 2025-02-28 08:05:34 -05:00
span.rs rangeint: remove PartialEq and PartialOrd impls for i{8,16,32,64,128} 2025-03-10 18:35:16 -04:00
timestamp.rs rangeint: remove PartialEq and PartialOrd impls for i{8,16,32,64,128} 2025-03-10 18:35:16 -04:00
zoned.rs rangeint: remove PartialEq and PartialOrd impls for i{8,16,32,64,128} 2025-03-10 18:35:16 -04:00