-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
return statements are sometimes required, even when they shouldn't be #159
Comments
I believe this is because we do not currently handle last expressions that are not considered branches. auto_enums/src/auto_enum/expr.rs Lines 21 to 37 in 5c3ffbe
|
My guess is that you will have to special case the last expression in a function because afaik that's the only place this edge case appears. It's also probably worth noting that returning I can look at a PR if you don't have the time. I ended up not using this at work for other reasons unrelated to the quality of the crate. Yay code simplification, heh. |
Yeah, the code I linked to is a function (child_expr) that handles that case, but even if the last expression itself is not considered to have a branch, it would indeed need to handle the last expression as one of the branches if a return is found in another expression. auto_enums/src/auto_enum/mod.rs Lines 206 to 207 in 5c3ffbe
I don't have the bandwidth to work on the fix this right now, so if you could take a look that would be great! |
I'll try to at least poke at it this weekend. |
I couldn't untangle the many nested visitors and such to figure out how to funnel the data around generically, which is problematic because the same bug applies to closures. That said, here is a diff that shows some broken test cases:
Hopefully that helps you or whoever else comes after figure this out quickly. Unfortunately without familiarity, this is taking much longer than I can justify spending on it at the moment. I will circle back if this ever becomes a blocker, but since I'm not currently using the crate this bug is low priority for me at the moment. |
My repro is unfortunately private code, so sorry...if it's not obvious what's going on I'll work up something else for you. But if you do something like this:
Then it only picks up the variants that explicitly had a return statement, and ignores the final expression in the function.
The text was updated successfully, but these errors were encountered: