remove useless test, update disallowed_method description

This commit is contained in:
Frank 2020-09-25 11:03:45 -05:00
parent f9da2946d8
commit d18653158d
4 changed files with 3 additions and 81 deletions

View file

@ -18,12 +18,12 @@ declare_clippy_lint! {
///
/// ```rust,ignore
/// // example code where clippy issues a warning
/// foo.bad_method(); // Foo is disallowed
/// foo.bad_method(); // Foo::bad_method is disallowed in the configuration
/// ```
/// Use instead:
/// ```rust,ignore
/// // example code which does not raise clippy warning
/// goodStruct.bad_method(); // not disallowed
/// goodStruct.bad_method(); // GoodStruct::bad_method is not disallowed
/// ```
pub DISALLOWED_METHOD,
nursery,

View file

@ -165,7 +165,7 @@ define_Conf! {
/// Lint: WILDCARD_IMPORTS. Whether to allow certain wildcard imports (prelude, super in tests).
(warn_on_all_wildcard_imports, "warn_on_all_wildcard_imports": bool, false),
/// Lint: DISALLOWED_METHOD. The list of blacklisted methods to lint about. NB: `bar` is not here since it has legitimate uses
(disallowed_methods, "disallowed_methods": Vec<String>, ["disallowed_method::Foo::bad_method", "disallowed_method::Baz::bad_method", "disallowed_method::Quux::bad_method"].iter().map(ToString::to_string).collect()),
(disallowed_methods, "disallowed_methods": Vec<String>, Vec::<String>::new()),
}
impl Default for Conf {

View file

@ -1,56 +0,0 @@
#![warn(clippy::disallowed_method)]
#![allow(clippy::no_effect, clippy::many_single_char_names)]
struct ImplStruct;
trait Baz {
fn bad_method(self);
}
impl Baz for ImplStruct {
fn bad_method(self) {}
}
struct Foo;
impl Foo {
fn bad_method(self) {}
}
struct StaticStruct;
trait Quux {
fn bad_method();
}
impl Quux for StaticStruct {
fn bad_method() {}
}
struct NormalStruct;
impl NormalStruct {
fn bad_method(self) {}
}
struct AttrStruct {
bad_method: i32,
}
fn main() {
let b = ImplStruct;
let f = Foo;
let c = ImplStruct;
let n = NormalStruct;
let a = AttrStruct { bad_method: 5 };
// lint these
b.bad_method();
c.bad_method();
f.bad_method();
// these are good
// good because not a method call (ExprKind => Call)
StaticStruct::bad_method();
n.bad_method();
a.bad_method;
}

View file

@ -1,22 +0,0 @@
error: use of a disallowed method `disallowed_method::Baz::bad_method`
--> $DIR/disallowed_method.rs:48:5
|
LL | b.bad_method();
| ^^^^^^^^^^^^^^
|
= note: `-D clippy::disallowed-method` implied by `-D warnings`
error: use of a disallowed method `disallowed_method::Baz::bad_method`
--> $DIR/disallowed_method.rs:49:5
|
LL | c.bad_method();
| ^^^^^^^^^^^^^^
error: use of a disallowed method `disallowed_method::Foo::bad_method`
--> $DIR/disallowed_method.rs:50:5
|
LL | f.bad_method();
| ^^^^^^^^^^^^^^
error: aborting due to 3 previous errors