File tree 2 files changed +67
-1
lines changed
2 files changed +67
-1
lines changed Original file line number Diff line number Diff line change @@ -350,3 +350,53 @@ impl RetOtherSelf<T> {
350
350
RetOtherSelf ( RetOtherSelfWrapper ( t) )
351
351
}
352
352
}
353
+
354
+ mod issue7344 {
355
+ struct RetImplTraitSelf < T > ( T ) ;
356
+
357
+ impl < T > RetImplTraitSelf < T > {
358
+ // should not trigger lint
359
+ fn new ( t : T ) -> impl Into < Self > {
360
+ Self ( t)
361
+ }
362
+ }
363
+
364
+ struct RetImplTraitNoSelf < T > ( T ) ;
365
+
366
+ impl < T > RetImplTraitNoSelf < T > {
367
+ // should trigger lint
368
+ fn new ( t : T ) -> impl Into < i32 > {
369
+ 1
370
+ }
371
+ }
372
+
373
+ trait Trait2 < T , U > { }
374
+ impl < T , U > Trait2 < T , U > for ( ) { }
375
+
376
+ struct RetImplTraitSelf2 < T > ( T ) ;
377
+
378
+ impl < T > RetImplTraitSelf2 < T > {
379
+ // should not trigger lint
380
+ fn new ( t : T ) -> impl Trait2 < ( ) , Self > {
381
+ unimplemented ! ( )
382
+ }
383
+ }
384
+
385
+ struct RetImplTraitNoSelf2 < T > ( T ) ;
386
+
387
+ impl < T > RetImplTraitNoSelf2 < T > {
388
+ // should trigger lint
389
+ fn new ( t : T ) -> impl Trait2 < ( ) , i32 > {
390
+ unimplemented ! ( )
391
+ }
392
+ }
393
+
394
+ struct RetImplTraitSelfAdt < ' a > ( & ' a str ) ;
395
+
396
+ impl < ' a > RetImplTraitSelfAdt < ' a > {
397
+ // should not trigger lint
398
+ fn new < ' b : ' a > ( s : & ' b str ) -> impl Into < RetImplTraitSelfAdt < ' b > > {
399
+ RetImplTraitSelfAdt ( s)
400
+ }
401
+ }
402
+ }
Original file line number Diff line number Diff line change @@ -76,5 +76,21 @@ LL | | unimplemented!();
76
76
LL | | }
77
77
| |_________^
78
78
79
- error: aborting due to 10 previous errors
79
+ error: methods called `new` usually return `Self`
80
+ --> $DIR/new_ret_no_self.rs:368:9
81
+ |
82
+ LL | / fn new(t: T) -> impl Into<i32> {
83
+ LL | | 1
84
+ LL | | }
85
+ | |_________^
86
+
87
+ error: methods called `new` usually return `Self`
88
+ --> $DIR/new_ret_no_self.rs:389:9
89
+ |
90
+ LL | / fn new(t: T) -> impl Trait2<(), i32> {
91
+ LL | | unimplemented!()
92
+ LL | | }
93
+ | |_________^
94
+
95
+ error: aborting due to 12 previous errors
80
96
You can’t perform that action at this time.
0 commit comments