File tree Expand file tree Collapse file tree 2 files changed +27
-7
lines changed Expand file tree Collapse file tree 2 files changed +27
-7
lines changed Original file line number Diff line number Diff line change 33
44struct Foo ( u32 ) ;
55
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+
625fn array ( ) {
726 let mut foo = [ 1 , 2 ] ;
827 let temp = foo[ 0 ] ;
@@ -32,6 +51,7 @@ fn vec() {
3251
3352#[ rustfmt:: skip]
3453fn main ( ) {
54+ field ( ) ;
3555 array ( ) ;
3656 slice ( ) ;
3757 vec ( ) ;
Original file line number Diff line number Diff line change 11error: this looks like you are swapping elements of `foo` manually
2- --> $DIR/swap.rs:8 :5
2+ --> $DIR/swap.rs:27 :5
33 |
44LL | / let temp = foo[0];
55LL | | foo[0] = foo[1];
@@ -9,23 +9,23 @@ LL | | foo[1] = temp;
99 = note: `-D clippy::manual-swap` implied by `-D warnings`
1010
1111error: this looks like you are swapping elements of `foo` manually
12- --> $DIR/swap.rs:17 :5
12+ --> $DIR/swap.rs:36 :5
1313 |
1414LL | / let temp = foo[0];
1515LL | | foo[0] = foo[1];
1616LL | | foo[1] = temp;
1717 | |_________________^ help: try: `foo.swap(0, 1)`
1818
1919error: this looks like you are swapping elements of `foo` manually
20- --> $DIR/swap.rs:26 :5
20+ --> $DIR/swap.rs:45 :5
2121 |
2222LL | / let temp = foo[0];
2323LL | | foo[0] = foo[1];
2424LL | | foo[1] = temp;
2525 | |_________________^ help: try: `foo.swap(0, 1)`
2626
2727error: this looks like you are swapping `a` and `b` manually
28- --> $DIR/swap.rs:45 :7
28+ --> $DIR/swap.rs:65 :7
2929 |
3030LL | ; let t = a;
3131 | _______^
@@ -36,7 +36,7 @@ LL | | b = t;
3636 = note: or maybe you should use `std::mem::replace`?
3737
3838error: this looks like you are swapping `c.0` and `a` manually
39- --> $DIR/swap.rs:54 :7
39+ --> $DIR/swap.rs:74 :7
4040 |
4141LL | ; let t = c.0;
4242 | _______^
@@ -47,7 +47,7 @@ LL | | a = t;
4747 = note: or maybe you should use `std::mem::replace`?
4848
4949error: this looks like you are trying to swap `a` and `b`
50- --> $DIR/swap.rs:42 :5
50+ --> $DIR/swap.rs:62 :5
5151 |
5252LL | / a = b;
5353LL | | b = a;
@@ -57,7 +57,7 @@ LL | | b = a;
5757 = note: or maybe you should use `std::mem::replace`?
5858
5959error: this looks like you are trying to swap `c.0` and `a`
60- --> $DIR/swap.rs:51 :5
60+ --> $DIR/swap.rs:71 :5
6161 |
6262LL | / c.0 = a;
6363LL | | a = c.0;
You can’t perform that action at this time.
0 commit comments