File tree 2 files changed +27
-7
lines changed
2 files changed +27
-7
lines changed Original file line number Diff line number Diff line change 3
3
4
4
struct Foo ( u32 ) ;
5
5
6
+ #[ derive( Clone ) ]
7
+ struct Bar {
8
+ a : u32 ,
9
+ b : u32 ,
10
+ }
11
+
12
+ fn field ( ) {
13
+ let mut bar = Bar { a : 1 , b : 2 } ;
14
+
15
+ let temp = bar. a ;
16
+ bar. a = bar. b ;
17
+ bar. b = temp;
18
+
19
+ let mut baz = vec ! [ bar. clone( ) , bar. clone( ) ] ;
20
+ let temp = baz[ 0 ] . a ;
21
+ baz[ 0 ] . a = baz[ 1 ] . a ;
22
+ baz[ 1 ] . a = temp;
23
+ }
24
+
6
25
fn array ( ) {
7
26
let mut foo = [ 1 , 2 ] ;
8
27
let temp = foo[ 0 ] ;
@@ -32,6 +51,7 @@ fn vec() {
32
51
33
52
#[ rustfmt:: skip]
34
53
fn main ( ) {
54
+ field ( ) ;
35
55
array ( ) ;
36
56
slice ( ) ;
37
57
vec ( ) ;
Original file line number Diff line number Diff line change 1
1
error: this looks like you are swapping elements of `foo` manually
2
- --> $DIR/swap.rs:8 :5
2
+ --> $DIR/swap.rs:27 :5
3
3
|
4
4
LL | / let temp = foo[0];
5
5
LL | | foo[0] = foo[1];
@@ -9,23 +9,23 @@ LL | | foo[1] = temp;
9
9
= note: `-D clippy::manual-swap` implied by `-D warnings`
10
10
11
11
error: this looks like you are swapping elements of `foo` manually
12
- --> $DIR/swap.rs:17 :5
12
+ --> $DIR/swap.rs:36 :5
13
13
|
14
14
LL | / let temp = foo[0];
15
15
LL | | foo[0] = foo[1];
16
16
LL | | foo[1] = temp;
17
17
| |_________________^ help: try: `foo.swap(0, 1)`
18
18
19
19
error: this looks like you are swapping elements of `foo` manually
20
- --> $DIR/swap.rs:26 :5
20
+ --> $DIR/swap.rs:45 :5
21
21
|
22
22
LL | / let temp = foo[0];
23
23
LL | | foo[0] = foo[1];
24
24
LL | | foo[1] = temp;
25
25
| |_________________^ help: try: `foo.swap(0, 1)`
26
26
27
27
error: this looks like you are swapping `a` and `b` manually
28
- --> $DIR/swap.rs:45 :7
28
+ --> $DIR/swap.rs:65 :7
29
29
|
30
30
LL | ; let t = a;
31
31
| _______^
@@ -36,7 +36,7 @@ LL | | b = t;
36
36
= note: or maybe you should use `std::mem::replace`?
37
37
38
38
error: this looks like you are swapping `c.0` and `a` manually
39
- --> $DIR/swap.rs:54 :7
39
+ --> $DIR/swap.rs:74 :7
40
40
|
41
41
LL | ; let t = c.0;
42
42
| _______^
@@ -47,7 +47,7 @@ LL | | a = t;
47
47
= note: or maybe you should use `std::mem::replace`?
48
48
49
49
error: this looks like you are trying to swap `a` and `b`
50
- --> $DIR/swap.rs:42 :5
50
+ --> $DIR/swap.rs:62 :5
51
51
|
52
52
LL | / a = b;
53
53
LL | | b = a;
@@ -57,7 +57,7 @@ LL | | b = a;
57
57
= note: or maybe you should use `std::mem::replace`?
58
58
59
59
error: this looks like you are trying to swap `c.0` and `a`
60
- --> $DIR/swap.rs:51 :5
60
+ --> $DIR/swap.rs:71 :5
61
61
|
62
62
LL | / c.0 = a;
63
63
LL | | a = c.0;
You can’t perform that action at this time.
0 commit comments