1 use std::collections::HashMap;
3 struct FooDefault<'a> {
18 impl std::default::Default for FooDefault<'_> {
19 fn default() -> Self {
25 e: Default::default(),
29 i: [vec![], vec![], vec![]],
37 struct TupleDefault(bool, i32, u64);
39 impl std::default::Default for TupleDefault {
40 fn default() -> Self {
49 impl std::default::Default for FooND1 {
50 fn default() -> Self {
59 impl std::default::Default for FooND2 {
60 fn default() -> Self {
75 impl Default for FooNDNew {
76 fn default() -> Self {
81 struct FooNDVec(Vec<i32>);
83 impl Default for FooNDVec {
84 fn default() -> Self {
89 struct StrDefault<'a>(&'a str);
91 impl Default for StrDefault<'_> {
92 fn default() -> Self {
98 struct AlreadyDerived(i32, bool);
107 fn default() -> Self {
118 fn default() -> Self {
123 struct RustIssue26925<T> {
127 // We should watch out for cases where a manual impl is needed because a
128 // derive adds different type bounds (https://github.com/rust-lang/rust/issues/26925).
129 // For example, a struct with Option<T> does not require T: Default, but a derive adds
130 // that type bound anyways. So until #26925 get fixed we should disable lint
131 // for the following case
132 impl<T> Default for RustIssue26925<T> {
133 fn default() -> Self {
138 struct SpecializedImpl<A, B> {
143 impl<T: Default> Default for SpecializedImpl<T, T> {
144 fn default() -> Self {
152 struct WithoutSelfCurly {
156 impl Default for WithoutSelfCurly {
157 fn default() -> Self {
158 WithoutSelfCurly { a: false }
162 struct WithoutSelfParan(bool);
164 impl Default for WithoutSelfParan {
165 fn default() -> Self {
166 WithoutSelfParan(false)
170 // https://github.com/rust-lang/rust-clippy/issues/7655
172 pub struct SpecializedImpl2<T> {
176 impl Default for SpecializedImpl2<String> {
177 fn default() -> Self {
178 Self { v: Vec::new() }
182 // https://github.com/rust-lang/rust-clippy/issues/7654
191 impl Default for Color {
192 fn default() -> Self {
193 Color { r: 0, g: 0, b: 0 }
203 impl Default for Color2 {
205 fn default() -> Self {
206 Self { r: 0, g: 0, b: 0 }
210 pub struct RepeatDefault1 {
214 impl Default for RepeatDefault1 {
215 fn default() -> Self {
216 RepeatDefault1 { a: [0; 32] }
220 pub struct RepeatDefault2 {
224 impl Default for RepeatDefault2 {
225 fn default() -> Self {
226 RepeatDefault2 { a: [0; 33] }
230 // https://github.com/rust-lang/rust-clippy/issues/7753
232 pub enum IntOrString {
237 impl Default for IntOrString {
238 fn default() -> Self {