1 #![allow(dead_code, clippy::missing_safety_doc)]
2 #![warn(clippy::new_without_default)]
15 pub fn new() -> Self {
23 pub fn new() -> Self {
29 fn default() -> Self {
37 pub fn new(_: u32) -> Self {
42 pub struct GenericsOk<T> {
46 impl<U> Default for GenericsOk<U> {
47 fn default() -> Self {
52 impl<'c, V> GenericsOk<V> {
53 pub fn new() -> GenericsOk<V> {
62 impl<'b> Default for LtOk<'b> {
63 fn default() -> Self {
69 pub fn new() -> LtOk<'c> {
79 pub fn new() -> LtKo<'c> {
82 // FIXME: that suggestion is missing lifetimes
90 } // We don't lint private items
96 pub const fn new() -> Const {
98 } // const fns can't be implemented via Default
101 pub struct IgnoreGenericNew;
103 impl IgnoreGenericNew {
104 pub fn new<T>() -> Self {
106 } // the derived Default does not make sense here as the result depends on T
109 pub trait TraitWithNew: Sized {
115 pub struct IgnoreUnsafeNew;
117 impl IgnoreUnsafeNew {
118 pub unsafe fn new() -> Self {
124 pub struct OptionRefWrapper<'a, T>(Option<&'a T>);
126 impl<'a, T> OptionRefWrapper<'a, T> {
127 pub fn new() -> Self {
128 OptionRefWrapper(None)
132 pub struct Allow(Foo);
135 #[allow(clippy::new_without_default)]
136 pub fn new() -> Self {
141 pub struct AllowDerive;
144 #[allow(clippy::new_without_default)]
145 pub fn new() -> Self {
150 pub struct NewNotEqualToDerive {
154 impl NewNotEqualToDerive {
155 // This `new` implementation is not equal to a derived `Default`, so do not suggest deriving.
156 pub fn new() -> Self {
157 NewNotEqualToDerive { foo: 1 }
162 pub struct FooGenerics<T>(std::marker::PhantomData<T>);
163 impl<T> FooGenerics<T> {
164 pub fn new() -> Self {
165 Self(Default::default())
169 pub struct BarGenerics<T>(std::marker::PhantomData<T>);
170 impl<T: Copy> BarGenerics<T> {
171 pub fn new() -> Self {
172 Self(Default::default())