diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index 6900502e8e1..f7f9dccfbce 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -155,7 +155,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) { &generics_sugg, &where_clause_sugg ), - Applicability::MaybeIncorrect, + Applicability::MachineApplicable, ); }, ); diff --git a/tests/ui/new_without_default.fixed b/tests/ui/new_without_default.fixed index 0c4283ad0c1..56359a4cbc3 100644 --- a/tests/ui/new_without_default.fixed +++ b/tests/ui/new_without_default.fixed @@ -102,7 +102,6 @@ impl<'c> LtKo<'c> { pub fn new() -> LtKo<'c> { unimplemented!() } - // FIXME: that suggestion is missing lifetimes } struct Private; @@ -273,3 +272,30 @@ impl IgnoreLifetimeNew { Self } } + +// From issue #11267 + +pub struct MyStruct +where + K: std::hash::Hash + Eq + PartialEq, +{ + _kv: Option<(K, V)>, +} + +impl Default for MyStruct +where + K: std::hash::Hash + Eq + PartialEq, + { + fn default() -> Self { + Self::new() + } +} + +impl MyStruct +where + K: std::hash::Hash + Eq + PartialEq, +{ + pub fn new() -> Self { + Self { _kv: None } + } +}