File tree 1 file changed +16
-8
lines changed
1 file changed +16
-8
lines changed Original file line number Diff line number Diff line change 1
1
// run-rustfix
2
2
3
- #![ allow( clippy:: needless_borrowed_reference) ]
4
-
5
- fn x ( y : & i32 ) -> i32 {
6
- * y
7
- }
8
-
9
3
#[ warn( clippy:: all, clippy:: needless_borrow) ]
10
4
#[ allow( unused_variables) ]
11
5
fn main ( ) {
12
6
let a = 5 ;
13
- let b = x ( & a) ;
14
- let c = x ( & & a) ;
7
+ let _ = x ( & a) ; // no warning
8
+ let _ = x ( & & a) ; // warn
9
+
10
+ let mut b = 5 ;
11
+ mut_ref ( & mut b) ; // no warning
12
+ mut_ref ( & mut & mut b) ; // warn
13
+
15
14
let s = & String :: from ( "hi" ) ;
16
15
let s_ident = f ( & s) ; // should not error, because `&String` implements Copy, but `String` does not
17
16
let g_val = g ( & Vec :: new ( ) ) ; // should not error, because `&Vec<T>` derefs to `&[T]`
@@ -29,6 +28,15 @@ fn main() {
29
28
} ;
30
29
}
31
30
31
+ #[ allow( clippy:: needless_borrowed_reference) ]
32
+ fn x ( y : & i32 ) -> i32 {
33
+ * y
34
+ }
35
+
36
+ fn mut_ref ( y : & mut i32 ) {
37
+ * y = 5 ;
38
+ }
39
+
32
40
fn f < T : Copy > ( y : & T ) -> T {
33
41
* y
34
42
}
You can’t perform that action at this time.
0 commit comments