Skip to content

Commit 596bbcb

Browse files
committed
Fixup clippy tests
- Don't depend on the fact that `!` falls back to `()` and so panic-ish things can be used in `-> impl ImplementedForUnit` functions - Remove `;` after `unimplemented!()` calls (not necessarily an issue, but there are plans to restrict this in future editions)
1 parent 092e74d commit 596bbcb

File tree

2 files changed

+37
-41
lines changed

2 files changed

+37
-41
lines changed

src/tools/clippy/tests/ui/new_ret_no_self.rs

+29-32
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ struct T;
7373
impl T {
7474
// should not trigger lint
7575
pub fn new() -> Self {
76-
unimplemented!();
76+
unimplemented!()
7777
}
7878
}
7979

@@ -83,7 +83,7 @@ impl U {
8383
// should trigger lint
8484
pub fn new() -> u32 {
8585
//~^ ERROR: methods called `new` usually return `Self`
86-
unimplemented!();
86+
unimplemented!()
8787
}
8888
}
8989

@@ -93,7 +93,7 @@ impl V {
9393
// should trigger lint
9494
pub fn new(_: String) -> u32 {
9595
//~^ ERROR: methods called `new` usually return `Self`
96-
unimplemented!();
96+
unimplemented!()
9797
}
9898
}
9999

@@ -102,7 +102,7 @@ struct TupleReturnerOk;
102102
impl TupleReturnerOk {
103103
// should not trigger lint
104104
pub fn new() -> (Self, u32) {
105-
unimplemented!();
105+
unimplemented!()
106106
}
107107
}
108108

@@ -111,7 +111,7 @@ struct TupleReturnerOk2;
111111
impl TupleReturnerOk2 {
112112
// should not trigger lint (it doesn't matter which element in the tuple is Self)
113113
pub fn new() -> (u32, Self) {
114-
unimplemented!();
114+
unimplemented!()
115115
}
116116
}
117117

@@ -120,7 +120,7 @@ struct TupleReturnerOk3;
120120
impl TupleReturnerOk3 {
121121
// should not trigger lint (tuple can contain multiple Self)
122122
pub fn new() -> (Self, Self) {
123-
unimplemented!();
123+
unimplemented!()
124124
}
125125
}
126126

@@ -130,7 +130,7 @@ impl TupleReturnerBad {
130130
// should trigger lint
131131
pub fn new() -> (u32, u32) {
132132
//~^ ERROR: methods called `new` usually return `Self`
133-
unimplemented!();
133+
unimplemented!()
134134
}
135135
}
136136

@@ -139,7 +139,7 @@ struct MutPointerReturnerOk;
139139
impl MutPointerReturnerOk {
140140
// should not trigger lint
141141
pub fn new() -> *mut Self {
142-
unimplemented!();
142+
unimplemented!()
143143
}
144144
}
145145

@@ -148,7 +148,7 @@ struct ConstPointerReturnerOk2;
148148
impl ConstPointerReturnerOk2 {
149149
// should not trigger lint
150150
pub fn new() -> *const Self {
151-
unimplemented!();
151+
unimplemented!()
152152
}
153153
}
154154

@@ -158,7 +158,7 @@ impl MutPointerReturnerBad {
158158
// should trigger lint
159159
pub fn new() -> *mut V {
160160
//~^ ERROR: methods called `new` usually return `Self`
161-
unimplemented!();
161+
unimplemented!()
162162
}
163163
}
164164

@@ -167,7 +167,7 @@ struct GenericReturnerOk;
167167
impl GenericReturnerOk {
168168
// should not trigger lint
169169
pub fn new() -> Option<Self> {
170-
unimplemented!();
170+
unimplemented!()
171171
}
172172
}
173173

@@ -177,7 +177,7 @@ impl GenericReturnerBad {
177177
// should trigger lint
178178
pub fn new() -> Option<u32> {
179179
//~^ ERROR: methods called `new` usually return `Self`
180-
unimplemented!();
180+
unimplemented!()
181181
}
182182
}
183183

@@ -186,7 +186,7 @@ struct NestedReturnerOk;
186186
impl NestedReturnerOk {
187187
// should not trigger lint
188188
pub fn new() -> (Option<Self>, u32) {
189-
unimplemented!();
189+
unimplemented!()
190190
}
191191
}
192192

@@ -195,7 +195,7 @@ struct NestedReturnerOk2;
195195
impl NestedReturnerOk2 {
196196
// should not trigger lint
197197
pub fn new() -> ((Self, u32), u32) {
198-
unimplemented!();
198+
unimplemented!()
199199
}
200200
}
201201

@@ -204,7 +204,7 @@ struct NestedReturnerOk3;
204204
impl NestedReturnerOk3 {
205205
// should not trigger lint
206206
pub fn new() -> Option<(Self, u32)> {
207-
unimplemented!();
207+
unimplemented!()
208208
}
209209
}
210210

@@ -215,7 +215,7 @@ struct WithLifetime<'a> {
215215
impl<'a> WithLifetime<'a> {
216216
// should not trigger the lint, because the lifetimes are different
217217
pub fn new<'b: 'a>(s: &'b str) -> WithLifetime<'b> {
218-
unimplemented!();
218+
unimplemented!()
219219
}
220220
}
221221

@@ -236,7 +236,7 @@ mod issue5435 {
236236
impl TraitRet for StructRet {
237237
// should not trigger lint as we are in the impl block
238238
fn new() -> String {
239-
unimplemented!();
239+
unimplemented!()
240240
}
241241
}
242242

@@ -252,7 +252,7 @@ mod issue5435 {
252252
where
253253
Self: Sized,
254254
{
255-
unimplemented!();
255+
unimplemented!()
256256
}
257257
}
258258

@@ -262,7 +262,7 @@ mod issue5435 {
262262
where
263263
Self: Sized,
264264
{
265-
unimplemented!();
265+
unimplemented!()
266266
}
267267
}
268268

@@ -272,15 +272,15 @@ mod issue5435 {
272272
where
273273
Self: Sized,
274274
{
275-
unimplemented!();
275+
unimplemented!()
276276
}
277277
}
278278

279279
trait TupleReturnerBad {
280280
// should trigger lint
281281
fn new() -> (u32, u32) {
282282
//~^ ERROR: methods called `new` usually return `Self`
283-
unimplemented!();
283+
unimplemented!()
284284
}
285285
}
286286

@@ -290,7 +290,7 @@ mod issue5435 {
290290
where
291291
Self: Sized,
292292
{
293-
unimplemented!();
293+
unimplemented!()
294294
}
295295
}
296296

@@ -300,15 +300,15 @@ mod issue5435 {
300300
where
301301
Self: Sized,
302302
{
303-
unimplemented!();
303+
unimplemented!()
304304
}
305305
}
306306

307307
trait MutPointerReturnerBad {
308308
// should trigger lint
309309
fn new() -> *mut V {
310310
//~^ ERROR: methods called `new` usually return `Self`
311-
unimplemented!();
311+
unimplemented!()
312312
}
313313
}
314314

@@ -318,7 +318,7 @@ mod issue5435 {
318318
where
319319
Self: Sized,
320320
{
321-
unimplemented!();
321+
unimplemented!()
322322
}
323323
}
324324

@@ -328,7 +328,7 @@ mod issue5435 {
328328
where
329329
Self: Sized,
330330
{
331-
unimplemented!();
331+
unimplemented!()
332332
}
333333
}
334334

@@ -338,7 +338,7 @@ mod issue5435 {
338338
where
339339
Self: Sized,
340340
{
341-
unimplemented!();
341+
unimplemented!()
342342
}
343343
}
344344

@@ -348,7 +348,7 @@ mod issue5435 {
348348
where
349349
Self: Sized,
350350
{
351-
unimplemented!();
351+
unimplemented!()
352352
}
353353
}
354354
}
@@ -390,9 +390,7 @@ mod issue7344 {
390390

391391
impl<T> RetImplTraitSelf2<T> {
392392
// should not trigger lint
393-
fn new(t: T) -> impl Trait2<(), Self> {
394-
unimplemented!()
395-
}
393+
fn new(t: T) -> impl Trait2<(), Self> {}
396394
}
397395

398396
struct RetImplTraitNoSelf2<T>(T);
@@ -401,7 +399,6 @@ mod issue7344 {
401399
// should trigger lint
402400
fn new(t: T) -> impl Trait2<(), i32> {
403401
//~^ ERROR: methods called `new` usually return `Self`
404-
unimplemented!()
405402
}
406403
}
407404

src/tools/clippy/tests/ui/new_ret_no_self.stderr

+8-9
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ error: methods called `new` usually return `Self`
1616
|
1717
LL | / pub fn new() -> u32 {
1818
LL | |
19-
LL | | unimplemented!();
19+
LL | | unimplemented!()
2020
LL | | }
2121
| |_____^
2222

@@ -25,7 +25,7 @@ error: methods called `new` usually return `Self`
2525
|
2626
LL | / pub fn new(_: String) -> u32 {
2727
LL | |
28-
LL | | unimplemented!();
28+
LL | | unimplemented!()
2929
LL | | }
3030
| |_____^
3131

@@ -34,7 +34,7 @@ error: methods called `new` usually return `Self`
3434
|
3535
LL | / pub fn new() -> (u32, u32) {
3636
LL | |
37-
LL | | unimplemented!();
37+
LL | | unimplemented!()
3838
LL | | }
3939
| |_____^
4040

@@ -43,7 +43,7 @@ error: methods called `new` usually return `Self`
4343
|
4444
LL | / pub fn new() -> *mut V {
4545
LL | |
46-
LL | | unimplemented!();
46+
LL | | unimplemented!()
4747
LL | | }
4848
| |_____^
4949

@@ -52,7 +52,7 @@ error: methods called `new` usually return `Self`
5252
|
5353
LL | / pub fn new() -> Option<u32> {
5454
LL | |
55-
LL | | unimplemented!();
55+
LL | | unimplemented!()
5656
LL | | }
5757
| |_____^
5858

@@ -73,7 +73,7 @@ error: methods called `new` usually return `Self`
7373
|
7474
LL | / fn new() -> (u32, u32) {
7575
LL | |
76-
LL | | unimplemented!();
76+
LL | | unimplemented!()
7777
LL | | }
7878
| |_________^
7979

@@ -82,7 +82,7 @@ error: methods called `new` usually return `Self`
8282
|
8383
LL | / fn new() -> *mut V {
8484
LL | |
85-
LL | | unimplemented!();
85+
LL | | unimplemented!()
8686
LL | | }
8787
| |_________^
8888

@@ -96,11 +96,10 @@ LL | | }
9696
| |_________^
9797

9898
error: methods called `new` usually return `Self`
99-
--> tests/ui/new_ret_no_self.rs:402:9
99+
--> tests/ui/new_ret_no_self.rs:400:9
100100
|
101101
LL | / fn new(t: T) -> impl Trait2<(), i32> {
102102
LL | |
103-
LL | | unimplemented!()
104103
LL | | }
105104
| |_________^
106105

0 commit comments

Comments
 (0)