Closed
Description
This code fails to compile on the latest nightly (1.85):
Playground link: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=c912d455ab2679f04d8b3e8dedf694dc
pub struct Vec2;
pub trait Point {
type S: Scalar;
}
impl Point for Vec2 {
type S = f32;
}
pub trait Point2: Point<S = Self::S2> {
type S2: Scalar;
}
impl Point2 for Vec2 {
type S2 = Self::S;
}
pub trait Scalar: Default {}
impl Scalar for f32 {}
pub struct Bar<T: Default>(pub Vec<T>);
pub struct Foo<P: Point>(pub Vec<P>);
impl<P: Point2> From<Foo<P>> for Bar<P::S> {
fn from(r: Foo<P>) -> Self {
Self(r.0.iter().map(|_| Default::default()).collect())
}
}
pub trait DoThing {
fn do_thing();
}
impl DoThing for Foo<Vec2> {
fn do_thing() {
let _ = Bar::from(Foo::<Vec2>(vec![]));
}
}
I expected to see this happen: It compiles without any errors
Instead, this happened: On nightly, it fails to compile with
error[E0275]: overflow evaluating the requirement `<Vec2 as Point>::S == _`
On stable (1.83.0) and beta (1.84.0-beta.6), it compiles just fine.
I encountered this bug while compiling this library, and then reduced the code until I got the example above: https://github.com/MetabuildDev/selo
Meta
rustc --version --verbose
:
rustc 1.85.0-nightly (14ee63a3c 2024-12-29)
binary: rustc
commit-hash: 14ee63a3c651bb7a243c8b07333749ab4b152e13
commit-date: 2024-12-29
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.6