diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2021-06-07 01:06:50 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-07 01:06:50 +0200 |
| commit | b71bc9119259b7494797de621a98a2cd4d91d563 (patch) | |
| tree | 3352679a5508eb36fcc03e415232c3872f00c14b | |
| parent | 83664bd16bbe776cca3790f8c10ccc752de50e8d (diff) | |
| parent | 0933fbd05a96d5685a6b47e5feeeb128d7daa2bf (diff) | |
Rollup merge of #85912 - LingMan:iter_any, r=nagisa
Use `Iterator::any` and `filter_map` instead of open-coding them ``@rustbot`` modify labels +C-cleanup +T-compiler
| -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 5d2256100ff..9050ae6f523 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -711,15 +711,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, } |
