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

Normalize semicolon inside/outside blocks for () returning expressions #7322

Closed
ojeda opened this issue Jun 4, 2021 · 3 comments · Fixed by #9826
Closed

Normalize semicolon inside/outside blocks for () returning expressions #7322

ojeda opened this issue Jun 4, 2021 · 3 comments · Fixed by #9826
Labels
A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-pedantic Lint: Belongs in the pedantic lint group

Comments

@ojeda
Copy link
Contributor

ojeda commented Jun 4, 2021

What it does

For () returning expressions, check that the semicolon is inside/outside the block.

Either way it is fine, but consistency is best. Having the semicolon inside may be slightly nicer and more similar to, say, conditionals and loop bodies.

Categories (optional)

  • Kind: clippy::style

Drawbacks

It is subjective, so perhaps we should offer both ways, one enabled by default.

Example

unsafe { f(x) };

Could be written as:

unsafe { f(x); }
@bjorn3
Copy link
Member

bjorn3 commented Jun 4, 2021

This should preferably work for all blocks, not just unsafe blocks. Maybe it should also work for if else and match.

@ojeda ojeda changed the title Normalize semicolon inside/outside unsafe blocks for () returning expressions Normalize semicolon inside/outside blocks for () returning expressions Jun 4, 2021
@flip1995 flip1995 added good-first-issue These issues are a good way to get started with Clippy L-pedantic Lint: Belongs in the pedantic lint group labels Jun 9, 2021
@mbartlett21
Copy link
Contributor

Having the semicolon outside means that rustfmt then doesn't make the block three lines.

E.g:

unsafe { my_fn(); }

// Helpfully formats to:
unsafe {
    my_fn();
}

@1c3t3a
Copy link
Contributor

1c3t3a commented Jul 16, 2021

@rustbot claim
I'm going to work on this the coming week!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-pedantic Lint: Belongs in the pedantic lint group
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants