rust-clippy/tests/ui/disallowed_method.rs

57 lines
873 B
Rust
Raw Normal View History

2020-09-24 20:32:03 +00:00
#![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;
2020-09-24 21:00:46 +00:00
let a = AttrStruct { bad_method: 5 };
2020-09-24 20:32:03 +00:00
// 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;
}