Description
The following code compiles in 1.49 and newer (tested1.49 and two recent nightlies) but does not in 1.48 or older (easily testable with godbolt)
fn x<A, E>(_a: A) -> Result<(), E>
where
A: T<E = E>
{
Ok(())
}
struct X;
trait T {
type E: core::fmt::Debug;
}
impl T for X {
type E = ();
}
pub fn main() {
let a = X;
x(a).expect("Practically it will work, but how might it fail?");
}
with older versions giving "E
doesn't implement Debug
". It seems that in 1.49, the concrete E used as a consequence of how the X in a implements T is inferred by this version and used to satisfy the expect
's requirement of implementing Debug
.
I've gone through the change logs between 1.48 and 1.49, and nothing there hints at such behavior. If the change is unintentional, it should be known as a bug (because it'd produce regressions once it's flipped back). If it is intentional, it should be documented in the change log (can that be amended later on?) to make users with a keen eye for MSRVs aware it's there and compatibility with older versions can suffer (or I should get better at reading change logs).