File tree Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -1920,7 +1920,6 @@ enum ImplicitHasherType<'tcx> {
19201920
19211921impl < ' tcx > ImplicitHasherType < ' tcx > {
19221922 /// Checks that `ty` is a target type without a BuildHasher.
1923- #[ allow( clippy:: new_ret_no_self) ]
19241923 fn new < ' a > ( cx : & LateContext < ' a , ' tcx > , hir_ty : & hir:: Ty ) -> Option < Self > {
19251924 if let TyKind :: Path ( QPath :: Resolved ( None , ref path) ) = hir_ty. node {
19261925 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 {
140140 // should trigger lint
141141 pub fn new ( ) -> * mut V { unimplemented ! ( ) ; }
142142}
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`
3636141 | pub fn new() -> *mut V { unimplemented!(); }
3737 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3838
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
4046
You can’t perform that action at this time.
0 commit comments