]> git.lizzy.rs Git - rust.git/blob - tests/ui/wrong_self_convention.rs
Auto merge of #3603 - xfix:random-state-lint, r=phansch
[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 #![warn(clippy::wrong_self_convention)]
11 #![warn(clippy::wrong_pub_self_convention)]
12 #![allow(dead_code, clippy::trivially_copy_pass_by_ref)]
13
14 fn main() {}
15
16 #[derive(Clone, Copy)]
17 struct Foo;
18
19 impl Foo {
20     fn as_i32(self) {}
21     fn as_u32(&self) {}
22     fn into_i32(self) {}
23     fn is_i32(self) {}
24     fn is_u32(&self) {}
25     fn to_i32(self) {}
26     fn from_i32(self) {}
27
28     pub fn as_i64(self) {}
29     pub fn into_i64(self) {}
30     pub fn is_i64(self) {}
31     pub fn to_i64(self) {}
32     pub fn from_i64(self) {}
33     // check whether the lint can be allowed at the function level
34     #[allow(clippy::wrong_self_convention)]
35     pub fn from_cake(self) {}
36
37     fn as_x<F: AsRef<Self>>(_: F) {}
38     fn as_y<F: AsRef<Foo>>(_: F) {}
39 }
40
41 struct Bar;
42
43 impl Bar {
44     fn as_i32(self) {}
45     fn as_u32(&self) {}
46     fn into_i32(&self) {}
47     fn into_u32(self) {}
48     fn is_i32(self) {}
49     fn is_u32(&self) {}
50     fn to_i32(self) {}
51     fn to_u32(&self) {}
52     fn from_i32(self) {}
53
54     pub fn as_i64(self) {}
55     pub fn into_i64(&self) {}
56     pub fn is_i64(self) {}
57     pub fn to_i64(self) {}
58     pub fn from_i64(self) {}
59
60     // test for false positives
61     fn as_(self) {}
62     fn into_(&self) {}
63     fn is_(self) {}
64     fn to_(self) {}
65     fn from_(self) {}
66     fn to_mut(&mut self) {}
67 }