-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
if $c:expr { Some($r:expr) } else { None }
=>> $c.then(|| $r)
#108079
Conversation
r? @nagisa (rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
@@ -271,7 +271,7 @@ impl<'a> AstValidator<'a> { | |||
|
|||
self.session.emit_err(InvalidVisibility { | |||
span: vis.span, | |||
implied: if vis.kind.is_pub() { Some(vis.span) } else { None }, | |||
implied: vis.kind.is_pub().then(|| vis.span), |
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.
These cases may be simpler as then_some
(even if longer 🙃 ). I don't have a strong opinion on then_some
usage, beyond it generating less code
☀️ Test successful - checks-actions |
r+ when doing |
This PR's merge into master has been force pushed away since we didn't run tests in practice. Please re-open the PR (as a new PR). |
Perhaps rustbot could add the |
…, r=oli-obk `if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)` Resurrection of rust-lang#108079
TL;DR: turn
into
This is part one of many of refactoring compiler to use
.then
where it makes code cleaner. This PR does only changes that are simple & clear wins (in my opinion anyway).