]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/impl.rs
Auto merge of #96605 - Urgau:string-retain-codegen, r=thomcc
[rust.git] / src / tools / clippy / tests / ui / impl.rs
1 #![allow(dead_code, clippy::extra_unused_lifetimes)]
2 #![warn(clippy::multiple_inherent_impl)]
3
4 struct MyStruct;
5
6 impl MyStruct {
7     fn first() {}
8 }
9
10 impl MyStruct {
11     fn second() {}
12 }
13
14 impl<'a> MyStruct {
15     fn lifetimed() {}
16 }
17
18 mod submod {
19     struct MyStruct;
20     impl MyStruct {
21         fn other() {}
22     }
23
24     impl super::MyStruct {
25         fn third() {}
26     }
27 }
28
29 use std::fmt;
30 impl fmt::Debug for MyStruct {
31     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
32         write!(f, "MyStruct {{ }}")
33     }
34 }
35
36 // issue #5772
37 struct WithArgs<T>(T);
38 impl WithArgs<u32> {
39     fn f1() {}
40 }
41 impl WithArgs<u64> {
42     fn f2() {}
43 }
44 impl WithArgs<u64> {
45     fn f3() {}
46 }
47
48 // Ok, the struct is allowed to have multiple impls.
49 #[allow(clippy::multiple_inherent_impl)]
50 struct Allowed;
51 impl Allowed {}
52 impl Allowed {}
53 impl Allowed {}
54
55 struct AllowedImpl;
56 #[allow(clippy::multiple_inherent_impl)]
57 impl AllowedImpl {}
58 // Ok, the first block is skipped by this lint.
59 impl AllowedImpl {}
60
61 struct OneAllowedImpl;
62 impl OneAllowedImpl {}
63 #[allow(clippy::multiple_inherent_impl)]
64 impl OneAllowedImpl {}
65 impl OneAllowedImpl {} // Lint, only one of the three blocks is allowed.
66
67 fn main() {}