1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
12 #![warn(clippy::new_without_default, clippy::new_without_default_derive)]
25 pub fn new() -> Self {
33 pub fn new() -> Self {
39 fn default() -> Self {
47 pub fn new(_: u32) -> Self {
52 pub struct GenericsOk<T> {
56 impl<U> Default for GenericsOk<U> {
57 fn default() -> Self {
62 impl<'c, V> GenericsOk<V> {
63 pub fn new() -> GenericsOk<V> {
72 impl<'b> Default for LtOk<'b> {
73 fn default() -> Self {
79 pub fn new() -> LtOk<'c> {
89 pub fn new() -> LtKo<'c> {
92 // FIXME: that suggestion is missing lifetimes
100 } // We don't lint private items
106 pub const fn new() -> Const {
108 } // const fns can't be implemented via Default
111 pub struct IgnoreGenericNew;
113 impl IgnoreGenericNew {
114 pub fn new<T>() -> Self {
116 } // the derived Default does not make sense here as the result depends on T
119 pub trait TraitWithNew: Sized {
125 pub struct IgnoreUnsafeNew;
127 impl IgnoreUnsafeNew {
128 pub unsafe fn new() -> Self {
134 pub struct OptionRefWrapper<'a, T: 'a>(Option<&'a T>);
136 impl<'a, T: 'a> OptionRefWrapper<'a, T> {
137 pub fn new() -> Self {
138 OptionRefWrapper(None)