c2rust icon indicating copy to clipboard operation
c2rust copied to clipboard

transpile: Convert final return statement into tail expression

Open Rua opened this issue 3 weeks ago • 2 comments

  • Fixes #1506.
  • Fixes #1496.

Rua avatar Dec 06 '25 18:12 Rua

I ran into an unexpected snag with this one: the stmts_block helper function is adding back the semicolon if it's missing. Ideally I would just remove that behaviour, but that has the obvious potential to break a lot of things, so does anyone know why it's there and what other things rely on it?

Rua avatar Dec 07 '25 10:12 Rua

I was able to remove the semicolon-adding code from stmts_block without any adverse effects in the tests, so let's hope it wasn't needed anywhere else. I think this is ready for review now.

Rua avatar Dec 10 '25 19:12 Rua

In order to solve #1506 I had to add another variant to the ImplicitReturnType enum, because with Void it was adding a return that doesn't belong there. I don't know if that's actually the correct solution here. I don't quite understand the label break stuff in the compound statements translation, and there is likely some interaction with #1509 as well.

Rua avatar Dec 17 '25 15:12 Rua