I wonder why you think self-calls a problem in practice. I would expect us to always lint on that today, with something like this error -- maybe that lint is not yet powerful enough to catch the self-call via trait dispatch though? I wonder if we could detect that.

I imagine self-calls are sufficiently easy to detect and rare enough that we could also add sideeffect calls to them...

@simulacrum

We do lint on it, I agree, but people may not fix the lint. It seems like if we can lint on it, we could also prevent UB. =)

Anyway, I'm not sure if it'll be a problem in practice, but as I said it's the only case of this bug in practice that I've encountered. In general, the fact that a function recurses on itself is less obvious and more likely to happen by accident than (I think) writing a purposefully infinite loop that has no side effects (which .. isn't really a very common thing to do?)