]> git.lizzy.rs Git - rust.git/blob - tests/ui/wrong_self_convention2.rs
Auto merge of #7166 - TaKO8Ki:refactor_misc_early_module, r=llogiq
[rust.git] / tests / ui / wrong_self_convention2.rs
1 // edition:2018
2 #![warn(clippy::wrong_self_convention)]
3 #![warn(clippy::wrong_pub_self_convention)]
4 #![allow(dead_code)]
5
6 fn main() {}
7
8 mod issue6983 {
9     pub struct Thing;
10     pub trait Trait {
11         fn to_thing(&self) -> Thing;
12     }
13
14     impl Trait for u8 {
15         // don't trigger, e.g. `ToString` from `std` requires `&self`
16         fn to_thing(&self) -> Thing {
17             Thing
18         }
19     }
20
21     trait ToU64 {
22         fn to_u64(self) -> u64;
23     }
24
25     struct FooNoCopy;
26     // trigger lint
27     impl ToU64 for FooNoCopy {
28         fn to_u64(self) -> u64 {
29             2
30         }
31     }
32 }
33
34 mod issue7032 {
35     trait Foo {
36         fn from_usize(x: usize) -> Self;
37     }
38     // don't trigger
39     impl Foo for usize {
40         fn from_usize(x: usize) -> Self {
41             x
42         }
43     }
44 }