File tree 3 files changed +28
-2
lines changed
3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -1920,7 +1920,6 @@ enum ImplicitHasherType<'tcx> {
1920
1920
1921
1921
impl < ' tcx > ImplicitHasherType < ' tcx > {
1922
1922
/// Checks that `ty` is a target type without a BuildHasher.
1923
- #[ allow( clippy:: new_ret_no_self) ]
1924
1923
fn new < ' a > ( cx : & LateContext < ' a , ' tcx > , hir_ty : & hir:: Ty ) -> Option < Self > {
1925
1924
if let TyKind :: Path ( QPath :: Resolved ( None , ref path) ) = hir_ty. node {
1926
1925
let params: Vec < _ > = path. segments . last ( ) . as_ref ( ) ?. args . as_ref ( ) ?
Original file line number Diff line number Diff line change @@ -140,3 +140,24 @@ impl MutPointerReturnerBad {
140
140
// should trigger lint
141
141
pub fn new ( ) -> * mut V { unimplemented ! ( ) ; }
142
142
}
143
+
144
+ struct GenericReturnerOk ;
145
+
146
+ impl GenericReturnerOk {
147
+ // should not trigger lint
148
+ pub fn new ( ) -> Option < Self > { unimplemented ! ( ) ; }
149
+ }
150
+
151
+ struct GenericReturnerBad ;
152
+
153
+ impl GenericReturnerBad {
154
+ // should trigger lint
155
+ pub fn new ( ) -> Option < u32 > { unimplemented ! ( ) ; }
156
+ }
157
+
158
+ struct NestedReturnerOk ;
159
+
160
+ impl NestedReturnerOk {
161
+ // should trigger lint
162
+ pub fn new ( ) -> ( Option < Self > , u32 ) { unimplemented ! ( ) ; }
163
+ }
Original file line number Diff line number Diff line change @@ -36,5 +36,11 @@ error: methods called `new` usually return `Self`
36
36
141 | pub fn new() -> *mut V { unimplemented!(); }
37
37
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
38
38
39
- error: aborting due to 5 previous errors
39
+ error: methods called `new` usually return `Self`
40
+ --> $DIR/new_ret_no_self.rs:155:5
41
+ |
42
+ 155 | pub fn new() -> Option<u32> { unimplemented!(); }
43
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44
+
45
+ error: aborting due to 6 previous errors
40
46
You can’t perform that action at this time.
0 commit comments