mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 07:04:18 +00:00
new_ret_no_self added test cases
This commit is contained in:
parent
079f9f45b5
commit
a624583557
3 changed files with 28 additions and 2 deletions
|
@ -1920,7 +1920,6 @@ enum ImplicitHasherType<'tcx> {
|
|||
|
||||
impl<'tcx> ImplicitHasherType<'tcx> {
|
||||
/// Checks that `ty` is a target type without a BuildHasher.
|
||||
#[allow(clippy::new_ret_no_self)]
|
||||
fn new<'a>(cx: &LateContext<'a, 'tcx>, hir_ty: &hir::Ty) -> Option<Self> {
|
||||
if let TyKind::Path(QPath::Resolved(None, ref path)) = hir_ty.node {
|
||||
let params: Vec<_> = path.segments.last().as_ref()?.args.as_ref()?
|
||||
|
|
|
@ -140,3 +140,24 @@ impl MutPointerReturnerBad {
|
|||
// should trigger lint
|
||||
pub fn new() -> *mut V { unimplemented!(); }
|
||||
}
|
||||
|
||||
struct GenericReturnerOk;
|
||||
|
||||
impl GenericReturnerOk {
|
||||
// should not trigger lint
|
||||
pub fn new() -> Option<Self> { unimplemented!(); }
|
||||
}
|
||||
|
||||
struct GenericReturnerBad;
|
||||
|
||||
impl GenericReturnerBad {
|
||||
// should trigger lint
|
||||
pub fn new() -> Option<u32> { unimplemented!(); }
|
||||
}
|
||||
|
||||
struct NestedReturnerOk;
|
||||
|
||||
impl NestedReturnerOk {
|
||||
// should trigger lint
|
||||
pub fn new() -> (Option<Self>, u32) { unimplemented!(); }
|
||||
}
|
||||
|
|
|
@ -36,5 +36,11 @@ error: methods called `new` usually return `Self`
|
|||
141 | pub fn new() -> *mut V { unimplemented!(); }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: methods called `new` usually return `Self`
|
||||
--> $DIR/new_ret_no_self.rs:155:5
|
||||
|
|
||||
155 | pub fn new() -> Option<u32> { unimplemented!(); }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
|
Loading…
Reference in a new issue