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 fn new() -> PrivateStruct
{
98 } // We don't lint public items on private structs
101 pub struct PrivateItem
;
104 fn new() -> PrivateItem
{
106 } // We don't lint private items on public structs
112 pub const fn new() -> Const
{
114 } // const fns can't be implemented via Default
117 pub struct IgnoreGenericNew
;
119 impl IgnoreGenericNew
{
120 pub fn new
<T
>() -> Self {
122 } // the derived Default does not make sense here as the result depends on T
125 pub trait TraitWithNew
: Sized
{
131 pub struct IgnoreUnsafeNew
;
133 impl IgnoreUnsafeNew
{
134 pub unsafe fn new() -> Self {
140 pub struct OptionRefWrapper
<'a
, T
>(Option
<&'a T
>);
142 impl<'a
, T
> OptionRefWrapper
<'a
, T
> {
143 pub fn new() -> Self {
144 OptionRefWrapper(None
)
148 pub struct Allow(Foo
);
151 #[allow(clippy::new_without_default)]
152 pub fn new() -> Self {
157 pub struct AllowDerive
;
160 #[allow(clippy::new_without_default)]
161 pub fn new() -> Self {
166 pub struct NewNotEqualToDerive
{
170 impl NewNotEqualToDerive
{
171 // This `new` implementation is not equal to a derived `Default`, so do not suggest deriving.
172 pub fn new() -> Self {
173 NewNotEqualToDerive { foo: 1 }
178 pub struct FooGenerics
<T
>(std
::marker
::PhantomData
<T
>);
179 impl<T
> FooGenerics
<T
> {
180 pub fn new() -> Self {
181 Self(Default
::default())
185 pub struct BarGenerics
<T
>(std
::marker
::PhantomData
<T
>);
186 impl<T
: Copy
> BarGenerics
<T
> {
187 pub fn new() -> Self {
188 Self(Default
::default())
198 pub fn new() -> Self {
205 // This should not create any lints
206 pub struct DocHidden
;
209 pub fn new() -> Self {