Skip to content

Commit 3beb46b

Browse files
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
2 parents b38d4ce + 0933fbd commit 3beb46b

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

compiler/rustc_lint/src/types.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -711,15 +711,10 @@ fn ty_is_known_nonnull<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, mode: CItemKi
711711
return false;
712712
}
713713

714-
for variant in &def.variants {
715-
if let Some(field) = transparent_newtype_field(cx.tcx, variant) {
716-
if ty_is_known_nonnull(cx, field.ty(tcx, substs), mode) {
717-
return true;
718-
}
719-
}
720-
}
721-
722-
false
714+
def.variants
715+
.iter()
716+
.filter_map(|variant| transparent_newtype_field(cx.tcx, variant))
717+
.any(|field| ty_is_known_nonnull(cx, field.ty(tcx, substs), mode))
723718
}
724719
_ => false,
725720
}

0 commit comments

Comments
 (0)