about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-02-16 17:51:25 +0100
committerGitHub <noreply@github.com>2023-02-16 17:51:25 +0100
commit64a4f70c177d80f98dc9d2f955bec05bc4139ade (patch)
tree3013f9a9f736f14c7dd95a625747d851dcc6d1c3 /compiler/rustc_resolve/src
parent04128982ffbf2609a94fa6b7786fe98c85c6b113 (diff)
parent5bf6a46032b6c746da5a95dc5c6e0ac46ac9b075 (diff)
downloadrust-64a4f70c177d80f98dc9d2f955bec05bc4139ade.tar.gz
rust-64a4f70c177d80f98dc9d2f955bec05bc4139ade.zip
Rollup merge of #108090 - WaffleLapkin:if_not_now_then_when…, r=oli-obk
`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`

Resurrection of #108079
Diffstat (limited to 'compiler/rustc_resolve/src')
-rw-r--r--compiler/rustc_resolve/src/late/diagnostics.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs
index a3195a64366..5205d055cf9 100644
--- a/compiler/rustc_resolve/src/late/diagnostics.rs
+++ b/compiler/rustc_resolve/src/late/diagnostics.rs
@@ -1700,11 +1700,9 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
                                         let crate_mod =
                                             Res::Def(DefKind::Mod, crate_id.as_def_id());
 
-                                        if filter_fn(crate_mod) {
-                                            Some(TypoSuggestion::typo_from_ident(*ident, crate_mod))
-                                        } else {
-                                            None
-                                        }
+                                        filter_fn(crate_mod).then(|| {
+                                            TypoSuggestion::typo_from_ident(*ident, crate_mod)
+                                        })
                                     })
                             }));