Skip to content

Commit

Permalink
Rollup merge of rust-lang#85906 - LingMan:iter_find, r=matthewjasper
Browse files Browse the repository at this point in the history
Use `Iterator::find` instead of open-coding it

``@rustbot`` modify labels +C-cleanup +T-compiler
  • Loading branch information
JohnTitor committed Jun 8, 2021
2 parents b7c611e + 86562b4 commit 9df63ac
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 @@ -679,16 +679,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 9df63ac

Please sign in to comment.