about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--clippy_lints/src/new_without_default.rs2
-rw-r--r--tests/ui/new_without_default.fixed28
2 files changed, 28 insertions, 2 deletions
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 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault {
                                                 &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<K, V>
+where
+    K: std::hash::Hash + Eq + PartialEq,
+{
+    _kv: Option<(K, V)>,
+}
+
+impl<K, V> Default for MyStruct<K, V>
+where
+    K: std::hash::Hash + Eq + PartialEq,
+ {
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
+impl<K, V> MyStruct<K, V>
+where
+    K: std::hash::Hash + Eq + PartialEq,
+{
+    pub fn new() -> Self {
+        Self { _kv: None }
+    }
+}