]> git.lizzy.rs Git - rust.git/blob - tests/ui/disallowed_method.rs
a54a04b4d2c664f37f170055d7bb34d6ba0a461e
[rust.git] / tests / ui / disallowed_method.rs
1 #![warn(clippy::disallowed_method)]
2 #![allow(clippy::no_effect, clippy::many_single_char_names)]
3
4 struct ImplStruct;
5
6 trait Baz {
7     fn bad_method(self);
8 }
9
10 impl Baz for ImplStruct {
11     fn bad_method(self) {}
12 }
13
14 struct Foo;
15
16 impl Foo {
17     fn bad_method(self) {}
18 }
19
20 struct StaticStruct;
21
22 trait Quux {
23     fn bad_method();
24 }
25
26 impl Quux for StaticStruct {
27     fn bad_method() {}
28 }
29
30 struct NormalStruct;
31
32 impl NormalStruct {
33     fn bad_method(self) {}
34 }
35
36 struct AttrStruct {
37     bad_method: i32,
38 }
39
40 fn main() {
41     let b = ImplStruct;
42     let f = Foo;
43     let c = ImplStruct;
44     let n = NormalStruct;
45     let a = AttrStruct{ bad_method: 5 };
46
47     // lint these
48     b.bad_method();
49     c.bad_method();
50     f.bad_method();
51     // these are good
52     // good because not a method call (ExprKind => Call)
53     StaticStruct::bad_method();
54     n.bad_method();
55     a.bad_method;
56 }