diff options
| author | LingMan <LingMan@users.noreply.github.com> | 2021-06-01 21:07:07 +0200 |
|---|---|---|
| committer | LingMan <LingMan@users.noreply.github.com> | 2021-06-01 21:07:07 +0200 |
| commit | 0933fbd05a96d5685a6b47e5feeeb128d7daa2bf (patch) | |
| tree | fdb0f80e797aedd93b3e30427a219d33743434ab | |
| parent | 1160cf864f2a0014e3442367e1b96496bfbeadf4 (diff) | |
| download | rust-0933fbd05a96d5685a6b47e5feeeb128d7daa2bf.tar.gz rust-0933fbd05a96d5685a6b47e5feeeb128d7daa2bf.zip | |
Use `Iterator::any` and `filter_map` instead of open-coding them
| -rw-r--r-- | compiler/rustc_lint/src/types.rs | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index 9c94bab04e9..8e7706758b6 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -712,15 +712,10 @@ fn ty_is_known_nonnull<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, mode: CItemKi return false; } - for variant in &def.variants { - if let Some(field) = transparent_newtype_field(cx.tcx, variant) { - if ty_is_known_nonnull(cx, field.ty(tcx, substs), mode) { - return true; - } - } - } - - false + def.variants + .iter() + .filter_map(|variant| transparent_newtype_field(cx.tcx, variant)) + .any(|field| ty_is_known_nonnull(cx, field.ty(tcx, substs), mode)) } _ => false, } |
