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

Suggest adding a semicolon to a closure without block #97371

Merged

Conversation

ChayimFriedman2
Copy link
Contributor

This transforms || expr into || { expr; }.

Closes #97359.

This transforms `|| expr` into `|| { expr; }`.
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 24, 2022
@rust-highfive
Copy link
Collaborator

r? @oli-obk

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 24, 2022
Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some code golfing, logic is sound.

compiler/rustc_typeck/src/check/coercion.rs Outdated Show resolved Hide resolved
compiler/rustc_typeck/src/check/coercion.rs Outdated Show resolved Hide resolved
&self,
err: &mut Diagnostic,
expression: &'tcx hir::Expr<'tcx>,
expected: Ty<'tcx>,
needs_block: bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of the bool argument, but I can't come up with anything clearer right now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither am I :) Maybe an enum will do?

@oli-obk
Copy link
Contributor

oli-obk commented May 31, 2022

@bors r+

@bors
Copy link
Contributor

bors commented May 31, 2022

📌 Commit 6afaffb has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 31, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request May 31, 2022
Rollup of 6 pull requests

Successful merges:

 - rust-lang#97089 (Improve settings theme display)
 - rust-lang#97229 (Document the current aliasing rules for `Box<T>`.)
 - rust-lang#97371 (Suggest adding a semicolon to a closure without block)
 - rust-lang#97455 (Stabilize `toowned_clone_into`)
 - rust-lang#97565 (Add doc alias `memset` to `write_bytes`)
 - rust-lang#97569 (Remove `memset` alias from `fill_with`.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 38d8167 into rust-lang:master May 31, 2022
@rustbot rustbot added this to the 1.63.0 milestone May 31, 2022
@ChayimFriedman2 ChayimFriedman2 deleted the closure-non-block-add-semicolon branch May 31, 2022 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Consider adding a semicolon here" for a closure without block
5 participants