diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2021-06-08 13:26:28 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-08 13:26:28 +0900 |
| commit | 472dbec026c03598747f6a7d5f75f164d107ce56 (patch) | |
| tree | 0307891946397a4fd86f71e319c385080c492a3c | |
| parent | dda4a881e006c808093543eece098565c3142c46 (diff) | |
| parent | 86562b4fdb39e2810e84c2107297a682cdec8042 (diff) | |
| download | rust-472dbec026c03598747f6a7d5f75f164d107ce56.tar.gz rust-472dbec026c03598747f6a7d5f75f164d107ce56.zip | |
Rollup merge of #85906 - LingMan:iter_find, r=matthewjasper
Use `Iterator::find` instead of open-coding it ```@rustbot``` modify labels +C-cleanup +T-compiler
| -rw-r--r-- | compiler/rustc_lint/src/types.rs | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index 9050ae6f523..a3a87a48768 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -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? |
