@@ -22,8 +22,8 @@ use std::collections::BTreeMap;
22
22
use std:: collections:: HashMap ;
23
23
use std:: collections:: HashSet ;
24
24
use std:: collections:: VecDeque ;
25
- use std:: ops:: Mul ;
26
25
use std:: iter:: FromIterator ;
26
+ use std:: ops:: Mul ;
27
27
use std:: rc:: { self , Rc } ;
28
28
use std:: sync:: { self , Arc } ;
29
29
@@ -32,22 +32,51 @@ use option_helpers::IteratorFalsePositives;
32
32
pub struct T ;
33
33
34
34
impl T {
35
- pub fn add ( self , other : T ) -> T { self }
35
+ pub fn add ( self , other : T ) -> T {
36
+ self
37
+ }
38
+
39
+ // no error, not public interface
40
+ pub ( crate ) fn drop ( & mut self ) { }
36
41
37
- pub ( crate ) fn drop ( & mut self ) { } // no error, not public interfact
38
- fn neg ( self ) -> Self { self } // no error, private function
39
- fn eq ( & self , other : T ) -> bool { true } // no error, private function
42
+ // no error, private function
43
+ fn neg ( self ) -> Self {
44
+ self
45
+ }
46
+
47
+ // no error, private function
48
+ fn eq ( & self , other : T ) -> bool {
49
+ true
50
+ }
40
51
41
- fn sub ( & self , other : T ) -> & T { self } // no error, self is a ref
42
- fn div ( self ) -> T { self } // no error, different #arguments
43
- fn rem ( self , other : T ) { } // no error, wrong return type
52
+ // no error, self is a ref
53
+ fn sub ( & self , other : T ) -> & T {
54
+ self
55
+ }
56
+
57
+ // no error, different #arguments
58
+ fn div ( self ) -> T {
59
+ self
60
+ }
61
+
62
+ fn rem ( self , other : T ) { } // no error, wrong return type
63
+
64
+ // fine
65
+ fn into_u32 ( self ) -> u32 {
66
+ 0
67
+ }
44
68
45
- fn into_u32 ( self ) -> u32 { 0 } // fine
46
- fn into_u16 ( & self ) -> u16 { 0 }
69
+ fn into_u16 ( & self ) -> u16 {
70
+ 0
71
+ }
47
72
48
- fn to_something ( self ) -> u32 { 0 }
73
+ fn to_something ( self ) -> u32 {
74
+ 0
75
+ }
49
76
50
- fn new ( self ) -> Self { unimplemented ! ( ) ; }
77
+ fn new ( self ) -> Self {
78
+ unimplemented ! ( ) ;
79
+ }
51
80
}
52
81
53
82
struct Lt < ' a > {
@@ -57,7 +86,9 @@ struct Lt<'a> {
57
86
impl < ' a > Lt < ' a > {
58
87
// The lifetime is different, but that’s irrelevant, see #734
59
88
#[ allow( clippy:: needless_lifetimes) ]
60
- pub fn new < ' b > ( s : & ' b str ) -> Lt < ' b > { unimplemented ! ( ) }
89
+ pub fn new < ' b > ( s : & ' b str ) -> Lt < ' b > {
90
+ unimplemented ! ( )
91
+ }
61
92
}
62
93
63
94
struct Lt2 < ' a > {
@@ -66,7 +97,9 @@ struct Lt2<'a> {
66
97
67
98
impl < ' a > Lt2 < ' a > {
68
99
// The lifetime is different, but that’s irrelevant, see #734
69
- pub fn new ( s : & str ) -> Lt2 { unimplemented ! ( ) }
100
+ pub fn new ( s : & str ) -> Lt2 {
101
+ unimplemented ! ( )
102
+ }
70
103
}
71
104
72
105
struct Lt3 < ' a > {
@@ -75,34 +108,47 @@ struct Lt3<'a> {
75
108
76
109
impl < ' a > Lt3 < ' a > {
77
110
// The lifetime is different, but that’s irrelevant, see #734
78
- pub fn new ( ) -> Lt3 < ' static > { unimplemented ! ( ) }
111
+ pub fn new ( ) -> Lt3 < ' static > {
112
+ unimplemented ! ( )
113
+ }
79
114
}
80
115
81
- #[ derive( Clone , Copy ) ]
116
+ #[ derive( Clone , Copy ) ]
82
117
struct U ;
83
118
84
119
impl U {
85
- fn new ( ) -> Self { U }
86
- fn to_something ( self ) -> u32 { 0 } // ok because U is Copy
120
+ fn new ( ) -> Self {
121
+ U
122
+ }
123
+ // ok because U is Copy
124
+ fn to_something ( self ) -> u32 {
125
+ 0
126
+ }
87
127
}
88
128
89
129
struct V < T > {
90
- _dummy : T
130
+ _dummy : T ,
91
131
}
92
132
93
133
impl < T > V < T > {
94
- fn new ( ) -> Option < V < T > > { None }
134
+ fn new ( ) -> Option < V < T > > {
135
+ None
136
+ }
95
137
}
96
138
97
139
impl Mul < T > for T {
98
140
type Output = T ;
99
- fn mul ( self , other : T ) -> T { self } // no error, obviously
141
+ // no error, obviously
142
+ fn mul ( self , other : T ) -> T {
143
+ self
144
+ }
100
145
}
101
146
102
147
/// Checks implementation of the following lints:
103
148
/// * `OPTION_MAP_UNWRAP_OR`
104
149
/// * `OPTION_MAP_UNWRAP_OR_ELSE`
105
150
/// * `OPTION_MAP_OR_NONE`
151
+ #[ rustfmt:: skip]
106
152
fn option_methods ( ) {
107
153
let opt = Some ( 1 ) ;
108
154
@@ -175,6 +221,7 @@ impl HasIter {
175
221
}
176
222
177
223
/// Checks implementation of `FILTER_NEXT` lint
224
+ #[ rustfmt:: skip]
178
225
fn filter_next ( ) {
179
226
let v = vec ! [ 3 , 2 , 1 , 0 , -1 , -2 , -3 ] ;
180
227
@@ -193,6 +240,7 @@ fn filter_next() {
193
240
}
194
241
195
242
/// Checks implementation of `SEARCH_IS_SOME` lint
243
+ #[ rustfmt:: skip]
196
244
fn search_is_some ( ) {
197
245
let v = vec ! [ 3 , 2 , 1 , 0 , -1 , -2 , -3 ] ;
198
246
@@ -235,16 +283,18 @@ fn or_fun_call() {
235
283
struct Foo ;
236
284
237
285
impl Foo {
238
- fn new ( ) -> Foo { Foo }
286
+ fn new ( ) -> Foo {
287
+ Foo
288
+ }
239
289
}
240
290
241
291
enum Enum {
242
292
A ( i32 ) ,
243
293
}
244
294
245
-
246
-
247
- fn make < T > ( ) -> T { unimplemented ! ( ) ; }
295
+ fn make < T > ( ) -> T {
296
+ unimplemented ! ( ) ;
297
+ }
248
298
249
299
let with_enum = Some ( Enum :: A ( 1 ) ) ;
250
300
with_enum. unwrap_or ( Enum :: A ( 5 ) ) ;
@@ -261,10 +311,10 @@ fn or_fun_call() {
261
311
let with_const_args = Some ( vec ! [ 1 ] ) ;
262
312
with_const_args. unwrap_or ( Vec :: with_capacity ( 12 ) ) ;
263
313
264
- let with_err : Result < _ , ( ) > = Ok ( vec ! [ 1 ] ) ;
314
+ let with_err: Result < _ , ( ) > = Ok ( vec ! [ 1 ] ) ;
265
315
with_err. unwrap_or ( make ( ) ) ;
266
316
267
- let with_err_args : Result < _ , ( ) > = Ok ( vec ! [ 1 ] ) ;
317
+ let with_err_args: Result < _ , ( ) > = Ok ( vec ! [ 1 ] ) ;
268
318
with_err_args. unwrap_or ( Vec :: with_capacity ( 12 ) ) ;
269
319
270
320
let with_default_trait = Some ( 1 ) ;
0 commit comments