How to find all recursive calls in a crate?

I have a parser where I used recursion, and I realised that some recursive calls might allow to repeat symbols I don't want to be repeated. So I need to go through all (at least direct) recursive calls.

Is there a tool (or some other way) that lists all recursive calls in a crate? Or at least a tool (or some other way) to find functions that directly call itself?

You can at least turn it direct self recursion into a type error by using let function_name = (); at the top of the function.

I would guess that using rust-analyzer's Peek references might be easier unless there are lots of callers It would at least seem possible to implement something like what you are looking for within RA but I'm not aware of anything.

1 Like

Thank you! Your first option sounds good, but it would be quite tedious for all the candidate function. The second option sounds good in principle, however I have never used Rust analyzer. So it would be a lot of work for me as well.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.