Avoid infinite cycle in coerce_unsized_old_solver when encountering invalid recursive struct definition by estebank · Pull Request #148677 · rust-lang/rust (original) (raw)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feels really brittle

I don't fully understand what's necessary for this to diverge, but would expect it to be possible to have non-trivial recursion here as well, e.g. why does the following not have issues

struct Vec { //~ ERROR recursive type Vec has infinite size data: Vec<Vec>, //~ ERROR type parameter T is only used recursively } impl Vec { pub fn push(&mut self) -> &mut Self { self } }

I feel like we probably should properly increment the recursion_depth of the obligations and have a recursion limit check here instead