Skip to content

Commit

Permalink
Use Iterator::find instead of open-coding it
Browse files Browse the repository at this point in the history
  • Loading branch information
LingMan committed Jun 1, 2021
1 parent 1160cf8 commit 86562b4
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions compiler/rustc_lint/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,16 +680,11 @@ pub fn transparent_newtype_field<'a, 'tcx>(
variant: &'a ty::VariantDef,
) -> Option<&'a ty::FieldDef> {
let param_env = tcx.param_env(variant.def_id);
for field in &variant.fields {
variant.fields.iter().find(|field| {
let field_ty = tcx.type_of(field.did);
let is_zst = tcx.layout_of(param_env.and(field_ty)).map_or(false, |layout| layout.is_zst());

if !is_zst {
return Some(field);
}
}

None
!is_zst
})
}

/// Is type known to be non-null?
Expand Down

0 comments on commit 86562b4

Please sign in to comment.