File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ feature( plugin) ]
2
+ #![ plugin( clippy) ]
3
+
4
+ fn takes_an_immutable_reference ( a : & i32 ) {
5
+ }
6
+
7
+ fn takes_a_mutable_reference ( a : & mut i32 ) {
8
+ }
9
+
10
+ struct MyStruct ;
11
+
12
+ impl MyStruct {
13
+ fn takes_an_immutable_reference ( & self , a : & i32 ) {
14
+ }
15
+
16
+ fn takes_a_mutable_reference ( & self , a : & mut i32 ) {
17
+ }
18
+ }
19
+
20
+ #[ deny( unnecessary_mut_passed) ]
21
+ fn main ( ) {
22
+ // Functions
23
+ takes_an_immutable_reference ( & mut 42 ) ; //~ERROR The function/method "takes_an_immutable_reference" doesn't need a mutable reference
24
+
25
+ // Methods
26
+ let my_struct = MyStruct ;
27
+ my_struct. takes_an_immutable_reference ( & mut 42 ) ; //~ERROR The function/method "takes_an_immutable_reference" doesn't need a mutable reference
28
+
29
+
30
+ // No error
31
+
32
+ // Functions
33
+ takes_an_immutable_reference ( & 42 ) ;
34
+ takes_a_mutable_reference ( & mut 42 ) ;
35
+ let mut a = & mut 42 ;
36
+ takes_an_immutable_reference ( a) ;
37
+
38
+ // Methods
39
+ my_struct. takes_an_immutable_reference ( & 42 ) ;
40
+ my_struct. takes_a_mutable_reference ( & mut 42 ) ;
41
+ my_struct. takes_an_immutable_reference ( a) ;
42
+
43
+ }
You can’t perform that action at this time.
0 commit comments