Skip to content

Commit 86562b4

Browse files
committed
Use Iterator::find instead of open-coding it
1 parent 1160cf8 commit 86562b4

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

compiler/rustc_lint/src/types.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -680,16 +680,11 @@ pub fn transparent_newtype_field<'a, 'tcx>(
680680
variant: &'a ty::VariantDef,
681681
) -> Option<&'a ty::FieldDef> {
682682
let param_env = tcx.param_env(variant.def_id);
683-
for field in &variant.fields {
683+
variant.fields.iter().find(|field| {
684684
let field_ty = tcx.type_of(field.did);
685685
let is_zst = tcx.layout_of(param_env.and(field_ty)).map_or(false, |layout| layout.is_zst());
686-
687-
if !is_zst {
688-
return Some(field);
689-
}
690-
}
691-
692-
None
686+
!is_zst
687+
})
693688
}
694689

695690
/// Is type known to be non-null?

0 commit comments

Comments
 (0)