Add missing WRONG_PUB_SELF_CONVENTION in lint_array! and corresponding test

This commit is contained in:
mcarton 2016-01-03 14:22:27 +01:00
parent e3ab0fb6e7
commit 52fbf1989d
2 changed files with 47 additions and 2 deletions

View file

@ -173,8 +173,8 @@ declare_lint!(pub SEARCH_IS_SOME, Warn,
impl LintPass for MethodsPass { impl LintPass for MethodsPass {
fn get_lints(&self) -> LintArray { fn get_lints(&self) -> LintArray {
lint_array!(OPTION_UNWRAP_USED, RESULT_UNWRAP_USED, STR_TO_STRING, STRING_TO_STRING, lint_array!(OPTION_UNWRAP_USED, RESULT_UNWRAP_USED, STR_TO_STRING, STRING_TO_STRING,
SHOULD_IMPLEMENT_TRAIT, WRONG_SELF_CONVENTION, OK_EXPECT, OPTION_MAP_UNWRAP_OR, SHOULD_IMPLEMENT_TRAIT, WRONG_SELF_CONVENTION, WRONG_PUB_SELF_CONVENTION,
OPTION_MAP_UNWRAP_OR_ELSE) OK_EXPECT, OPTION_MAP_UNWRAP_OR, OPTION_MAP_UNWRAP_OR_ELSE)
} }
} }

View file

@ -0,0 +1,45 @@
#![feature(plugin)]
#![plugin(clippy)]
#![deny(wrong_self_convention)]
#![deny(wrong_pub_self_convention)]
#![allow(dead_code)]
fn main() {}
#[derive(Clone, Copy)]
struct Foo;
impl Foo {
fn as_i32(self) {}
fn into_i32(self) {}
fn is_i32(self) {}
fn to_i32(self) {}
fn from_i32(self) {} //~ERROR: methods called `from_*` usually take no self
pub fn as_i64(self) {}
pub fn into_i64(self) {}
pub fn is_i64(self) {}
pub fn to_i64(self) {}
pub fn from_i64(self) {} //~ERROR: methods called `from_*` usually take no self
}
struct Bar;
impl Bar {
fn as_i32(self) {} //~ERROR: methods called `as_*` usually take self by reference
fn into_i32(&self) {} //~ERROR: methods called `into_*` usually take self by value
fn is_i32(self) {} //~ERROR: methods called `is_*` usually take self by reference
fn to_i32(self) {} //~ERROR: methods called `to_*` usually take self by reference
fn from_i32(self) {} //~ERROR: methods called `from_*` usually take no self
pub fn as_i64(self) {} //~ERROR: methods called `as_*` usually take self by reference
pub fn into_i64(&self) {} //~ERROR: methods called `into_*` usually take self by value
pub fn is_i64(self) {} //~ERROR: methods called `is_*` usually take self by reference
pub fn to_i64(self) {} //~ERROR: methods called `to_*` usually take self by reference
pub fn from_i64(self) {} //~ERROR: methods called `from_*` usually take no self
}