Description
I tried this code:
let item = sickle_builder::types::time::Date::from_calendar_date(
2020,
sickle_builder::types::time::Month::January,
1,
)?;
let y: i32 = item.year();
let m: tiberius::time::time::Month = item.month();
let d: u8 = item.day();
let date: tiberius::time::Date = tiberius::time::time::Date::from_calendar_date(y, m, d)?;
I expected to see this happen: No error
Instead, this happened:
error[E0308]: `?` operator has incompatible types
--> sickle-query/src/mssql_queryable.rs:53:21
|
53 | tiberius::time::time::Date::from_calendar_date(y, m, d)?
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `tiberius::time::Date`, found struct `sickle_builder::types::time::Date`
|
= note: `?` operator cannot convert from `sickle_builder::types::time::Date` to `tiberius::time::Date`
sickle_query::types::time
and tiberius::time
are re-exports of the time
crate. For multiple reasons, these may be different versions with different features and are not be assumed to be the same. However, it seems that rustc is detecting that they are the same crate, and then "forgets" the path or assumes the wrong path on line 53. But though the path is explicitly given on both the left and right hand sides of the assignment, so there is no ambiguity.
Confirmed this for nightly with cargo +nightly build --workspace --all-targets --all-features
Note: This seems different than #102882, because I am explicitly stating the paths of which re-export to use, and am not making assumptions that they are the same. rustc seems to arbitrarily pick/unify/dedup a different re-export than what is explicitly stated on one side of the assignment, then fails to do the same with the other side.
Meta
rustc --version --verbose
:
rustc 1.65.0 (897e37553 2022-11-02)
binary: rustc
commit-hash: 897e37553bba8b42751c67658967889d11ecd120
commit-date: 2022-11-02
host: x86_64-unknown-linux-gnu
release: 1.65.0
LLVM version: 15.0.0
Backtrace
No backtrace; it doesn't build.