diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs index e43b591a9cdc..63d75be1da20 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -186,7 +186,9 @@ fn check_pat<'a, 'tcx>( if let ExprKind::Struct(_, ref efields, _) = init_struct.node { for field in pfields { let name = field.node.ident.name; - let efield = efields.iter().find(|f| f.ident.name == name).map(|f| &*f.expr); + let efield = efields + .iter() + .find_map(|f| if f.ident.name == name { Some(&*f.expr) } else { None }); check_pat(cx, &field.node.pat, efield, span, bindings); } } else { diff --git a/clippy_lints/src/utils/attrs.rs b/clippy_lints/src/utils/attrs.rs index fbd36ba71dec..bec8d53714e2 100644 --- a/clippy_lints/src/utils/attrs.rs +++ b/clippy_lints/src/utils/attrs.rs @@ -58,10 +58,16 @@ pub fn get_attr<'a>( attrs.iter().filter(move |attr| { let attr_segments = &attr.path.segments; if attr_segments.len() == 2 && attr_segments[0].ident.to_string() == "clippy" { - if let Some(deprecation_status) = BUILTIN_ATTRIBUTES - .iter() - .find(|(builtin_name, _)| *builtin_name == attr_segments[1].ident.to_string()) - .map(|(_, deprecation_status)| deprecation_status) + if let Some(deprecation_status) = + BUILTIN_ATTRIBUTES + .iter() + .find_map(|(builtin_name, deprecation_status)| { + if *builtin_name == attr_segments[1].ident.to_string() { + Some(deprecation_status) + } else { + None + } + }) { let mut db = sess.struct_span_err(attr_segments[1].ident.span, "Usage of deprecated attribute"); match deprecation_status { diff --git a/tests/compile-test.rs b/tests/compile-test.rs index 65561b7fbd76..663e55d8ea2b 100644 --- a/tests/compile-test.rs +++ b/tests/compile-test.rs @@ -61,10 +61,13 @@ fn config(mode: &str, dir: PathBuf) -> compiletest::Config { let name = path.file_name()?.to_string_lossy(); // NOTE: This only handles a single dep // https://github.com/laumann/compiletest-rs/issues/101 - needs_disambiguation - .iter() - .find(|dep| name.starts_with(&format!("lib{}-", dep))) - .map(|dep| format!("--extern {}={}", dep, path.display())) + needs_disambiguation.iter().find_map(|dep| { + if name.starts_with(&format!("lib{}-", dep)) { + Some(format!("--extern {}={}", dep, path.display())) + } else { + None + } + }) }) .collect::>();