Skip to content
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

Final return statements versus implicit return #814

Closed
ketsuban opened this issue Feb 7, 2016 · 4 comments
Closed

Final return statements versus implicit return #814

ketsuban opened this issue Feb 7, 2016 · 4 comments
Labels

Comments

@ketsuban
Copy link

ketsuban commented Feb 7, 2016

Exhibit A

fn i_am_the_walrus(foo: u32) -> u64 {
    ((foo as u64) << 32) + (foo as u64)
}

Exhibit B

fn i_am_the_walrus(foo: u32) -> u64 {
    return ((foo as u64) << 32) + (foo as u64);
}

Given that the Book refers to B as “poor style”, is it within rustfmt's bailiwick (being that it is a tool for resolving stylistic disagreements) to replace it with A?

@nrc
Copy link
Member

nrc commented Feb 7, 2016

Yes, this would be good to do. I wonder how general we can make the rule? I expect at some point you need more semantic info than rustfmt has access to.

@nrc nrc added the fun! :) label Feb 7, 2016
@eefriedman
Copy link
Contributor

See also rust-lang/rust#31439 .

@sanxiyn
Copy link
Member

sanxiyn commented Feb 16, 2016

This (the rule part, not the formatting part) is implemented as needless_return in Clippy.

@topecongiro
Copy link
Contributor

Closing this as this is more of clippy-stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants