]> git.lizzy.rs Git - rust.git/blob - tests/ui/wrong_self_convention.rs
Merge remote-tracking branch 'upstream/master'
[rust.git] / tests / ui / wrong_self_convention.rs
1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10
11
12
13
14 #![warn(clippy::wrong_self_convention)]
15 #![warn(clippy::wrong_pub_self_convention)]
16 #![allow(dead_code, clippy::trivially_copy_pass_by_ref)]
17
18 fn main() {}
19
20 #[derive(Clone, Copy)]
21 struct Foo;
22
23 impl Foo {
24
25     fn as_i32(self) {}
26     fn as_u32(&self) {}
27     fn into_i32(self) {}
28     fn is_i32(self) {}
29     fn is_u32(&self) {}
30     fn to_i32(self) {}
31     fn from_i32(self) {}
32
33     pub fn as_i64(self) {}
34     pub fn into_i64(self) {}
35     pub fn is_i64(self) {}
36     pub fn to_i64(self) {}
37     pub fn from_i64(self) {}
38     // check whether the lint can be allowed at the function level
39     #[allow(clippy::wrong_self_convention)]
40     pub fn from_cake(self) {}
41
42     fn as_x<F: AsRef<Self>>(_: F) { }
43     fn as_y<F: AsRef<Foo>>(_: F) { }
44 }
45
46 struct Bar;
47
48 impl Bar {
49
50     fn as_i32(self) {}
51     fn as_u32(&self) {}
52     fn into_i32(&self) {}
53     fn into_u32(self) {}
54     fn is_i32(self) {}
55     fn is_u32(&self) {}
56     fn to_i32(self) {}
57     fn to_u32(&self) {}
58     fn from_i32(self) {}
59
60     pub fn as_i64(self) {}
61     pub fn into_i64(&self) {}
62     pub fn is_i64(self) {}
63     pub fn to_i64(self) {}
64     pub fn from_i64(self) {}
65
66     // test for false positives
67     fn as_(self) {}
68     fn into_(&self) {}
69     fn is_(self) {}
70     fn to_(self) {}
71     fn from_(self) {}
72     fn to_mut(&mut self) {}
73 }