Skip to content

Commit 472dbec

Browse files
authored
Rollup merge of #85906 - LingMan:iter_find, r=matthewjasper
Use `Iterator::find` instead of open-coding it ```@rustbot``` modify labels +C-cleanup +T-compiler
2 parents dda4a88 + 86562b4 commit 472dbec

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
@@ -679,16 +679,11 @@ pub fn transparent_newtype_field<'a, 'tcx>(
679679
variant: &'a ty::VariantDef,
680680
) -> Option<&'a ty::FieldDef> {
681681
let param_env = tcx.param_env(variant.def_id);
682-
for field in &variant.fields {
682+
variant.fields.iter().find(|field| {
683683
let field_ty = tcx.type_of(field.did);
684684
let is_zst = tcx.layout_of(param_env.and(field_ty)).map_or(false, |layout| layout.is_zst());
685-
686-
if !is_zst {
687-
return Some(field);
688-
}
689-
}
690-
691-
None
685+
!is_zst
686+
})
692687
}
693688

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

0 commit comments

Comments
 (0)