-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Remove needless returns detected by clippy in the compiler #130114
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
Conversation
r? @fee1-dead rustbot has assigned @fee1-dead. Use |
Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
@eduardosm can you split off the library parts into their own PR? |
Done, libraries part here |
It's not obvious that these are all harmless changes - sometimes the explicit return expresses intent, so it should be preserved to account for future possible refactorings even if it does not make a difference right now.
|
I undid some of the changes, trying to keep only the most obvious ones. |
@@ -336,7 +336,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { | |||
return true; | |||
} | |||
} | |||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it is nicer, for symmetry with the return
just a few lines above, to use return
here.
That's exactly why I don't like just forcing such clippy lints over the entire codebase...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have exactly the opposite opinion. I like the consistency that tools like clippy encourage, and in this case I think the change makes the "early return" and "default/fallthrough" visually distinct, which I find easier to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last two returns here are not distinct in a meaningful sense, so it is not a good idea to make them visually distinct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @saethlin. I think it's just plain odd to have return value;
at the end of a block when it's not suggesting exceptional control flow.
I think it's actually very odd that miri has allow(clippy::needless_return)
on its codebase, but for the rest of the compiler I think this should be fixed.
This comment was marked as off-topic.
This comment was marked as off-topic.
Oops, closed the wrong PR !! Meant to close mine which is a duplicate :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up implementing the exact same changes, so I basically did a complete review of this by doing the changes myself. This LGTM.
@bors r+ rollup |
No description provided.