Skip to content

Commit 0933fbd

Browse files
committed
Use Iterator::any and filter_map instead of open-coding them
1 parent 1160cf8 commit 0933fbd

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

compiler/rustc_lint/src/types.rs

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

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

0 commit comments

Comments
 (0)