]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/new_without_default.rs
Merge commit '7ea7cd165ad6705603852771bf82cc2fd6560db5' into clippyup2
[rust.git] / tests / ui / new_without_default.rs
index 82aec070b404bdaef3dee8701af51e545cedef23..3b6041823d8786672ec6bb3d7bdae19acaeaa428 100644 (file)
@@ -1,5 +1,5 @@
 #![feature(const_fn)]
-#![allow(dead_code)]
+#![allow(dead_code, clippy::missing_safety_doc)]
 #![warn(clippy::new_without_default)]
 
 pub struct Foo;
@@ -122,9 +122,9 @@ pub unsafe fn new() -> Self {
 }
 
 #[derive(Default)]
-pub struct OptionRefWrapper<'a, T: 'a>(Option<&'a T>);
+pub struct OptionRefWrapper<'a, T>(Option<&'a T>);
 
-impl<'a, T: 'a> OptionRefWrapper<'a, T> {
+impl<'a, T> OptionRefWrapper<'a, T> {
     pub fn new() -> Self {
         OptionRefWrapper(None)
     }
@@ -148,4 +148,15 @@ pub fn new() -> Self {
     }
 }
 
+pub struct NewNotEqualToDerive {
+    foo: i32,
+}
+
+impl NewNotEqualToDerive {
+    // This `new` implementation is not equal to a derived `Default`, so do not suggest deriving.
+    pub fn new() -> Self {
+        NewNotEqualToDerive { foo: 1 }
+    }
+}
+
 fn main() {}