diff --git a/clippy_utils/src/eager_or_lazy.rs b/clippy_utils/src/eager_or_lazy.rs index eb3f442ac754..49adc0ba7c06 100644 --- a/clippy_utils/src/eager_or_lazy.rs +++ b/clippy_utils/src/eager_or_lazy.rs @@ -49,7 +49,7 @@ impl ops::BitOrAssign for EagernessSuggestion { /// Determine the eagerness of the given function call. fn fn_eagerness(cx: &LateContext<'_>, fn_id: DefId, name: Symbol, have_one_arg: bool) -> EagernessSuggestion { - use EagernessSuggestion::{Eager, Lazy, NoChange}; + use EagernessSuggestion::{Lazy, NoChange}; let ty = match cx.tcx.impl_of_assoc(fn_id) { Some(id) => cx.tcx.type_of(id).instantiate_identity(), @@ -57,14 +57,7 @@ fn fn_eagerness(cx: &LateContext<'_>, fn_id: DefId, name: Symbol, have_one_arg: }; if (matches!(name, sym::is_empty | sym::len) || name.as_str().starts_with("as_")) && have_one_arg { - if matches!( - cx.tcx.crate_name(fn_id.krate), - sym::std | sym::core | sym::alloc | sym::proc_macro - ) { - Eager - } else { - NoChange - } + NoChange } else if let ty::Adt(def, subs) = ty.kind() { // Types where the only fields are generic types (or references to) with no trait bounds other // than marker traits. diff --git a/tests/ui/option_if_let_else.fixed b/tests/ui/option_if_let_else.fixed index 0f86de5646cd..03e7262d0c5b 100644 --- a/tests/ui/option_if_let_else.fixed +++ b/tests/ui/option_if_let_else.fixed @@ -162,7 +162,7 @@ fn main() { let s = String::new(); // Lint, both branches immutably borrow `s`. - let _ = Some(0).map_or(s.len(), |x| s.len() + x); + let _ = Some(0).map_or_else(|| s.len(), |x| s.len() + x); //~^ option_if_let_else let s = String::new(); diff --git a/tests/ui/option_if_let_else.stderr b/tests/ui/option_if_let_else.stderr index 2e2fe6f20492..4bc24b20163a 100644 --- a/tests/ui/option_if_let_else.stderr +++ b/tests/ui/option_if_let_else.stderr @@ -216,11 +216,11 @@ LL + } LL ~ }); | -error: use Option::map_or instead of an if let/else +error: use Option::map_or_else instead of an if let/else --> tests/ui/option_if_let_else.rs:197:13 | LL | let _ = if let Some(x) = Some(0) { s.len() + x } else { s.len() }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(0).map_or(s.len(), |x| s.len() + x)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(0).map_or_else(|| s.len(), |x| s.len() + x)` error: use Option::map_or instead of an if let/else --> tests/ui/option_if_let_else.rs:202:13