Skip to content

Commit 8a20279

Browse files
committed
Update tests for debug_assert_with_mut_call
In keeping with the preferred assertion style expected by the lint `bool_assert_inverted`, only compare such conditions to a boolean literal.
1 parent 3fc487b commit 8a20279

File tree

2 files changed

+64
-42
lines changed

2 files changed

+64
-42
lines changed

tests/ui/debug_assert_with_mut_call.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ fn u32_mut(_: &mut u32) -> u32 { 0 }
2929

3030
fn func_non_mutable() {
3131
debug_assert!(bool_ref(&3));
32-
debug_assert!(!bool_ref(&3));
32+
debug_assert_eq!(false, !bool_ref(&3));
33+
debug_assert_eq!(!bool_ref(&3), false);
3334

3435
debug_assert_eq!(0, u32_ref(&3));
3536
debug_assert_eq!(u32_ref(&3), 0);
@@ -40,7 +41,8 @@ fn func_non_mutable() {
4041

4142
fn func_mutable() {
4243
debug_assert!(bool_mut(&mut 3));
43-
debug_assert!(!bool_mut(&mut 3));
44+
debug_assert_eq!(false, !bool_mut(&mut 3));
45+
debug_assert_eq!(!bool_mut(&mut 3), false);
4446

4547
debug_assert_eq!(0, u32_mut(&mut 3));
4648
debug_assert_eq!(u32_mut(&mut 3), 0);
@@ -62,7 +64,8 @@ fn method_non_mutable() {
6264

6365
fn method_mutable() {
6466
debug_assert!(S.bool_self_mut());
65-
debug_assert!(!S.bool_self_mut());
67+
debug_assert_eq!(false, !S.bool_self_mut());
68+
debug_assert_eq!(!S.bool_self_mut(), false);
6669
debug_assert!(S.bool_self_ref_arg_mut(&mut 3));
6770
debug_assert!(S.bool_self_mut_arg_ref(&3));
6871
debug_assert!(S.bool_self_mut_arg_mut(&mut 3));
@@ -90,7 +93,8 @@ fn misc() {
9093
debug_assert!(bool_mut(a));
9194

9295
// nested
93-
debug_assert!(!(bool_ref(&u32_mut(&mut 3))));
96+
debug_assert_eq!(false, !(bool_ref(&u32_mut(&mut 3))));
97+
debug_assert_eq!(!(bool_ref(&u32_mut(&mut 3))), false);
9498

9599
// chained
96100
debug_assert_eq!(v.pop().unwrap(), 3);
Lines changed: 56 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,172 +1,190 @@
11
error: do not call a function with mutable arguments inside of `debug_assert!`
2-
--> $DIR/debug_assert_with_mut_call.rs:42:19
2+
--> $DIR/debug_assert_with_mut_call.rs:43:19
33
|
44
LL | debug_assert!(bool_mut(&mut 3));
55
| ^^^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::debug-assert-with-mut-call` implied by `-D warnings`
88

9-
error: do not call a function with mutable arguments inside of `debug_assert!`
10-
--> $DIR/debug_assert_with_mut_call.rs:43:20
9+
error: do not call a function with mutable arguments inside of `debug_assert_eq!`
10+
--> $DIR/debug_assert_with_mut_call.rs:44:30
1111
|
12-
LL | debug_assert!(!bool_mut(&mut 3));
13-
| ^^^^^^^^^^^^^^^^
12+
LL | debug_assert_eq!(false, !bool_mut(&mut 3));
13+
| ^^^^^^^^^^^^^^^^
1414

1515
error: do not call a function with mutable arguments inside of `debug_assert_eq!`
16-
--> $DIR/debug_assert_with_mut_call.rs:45:25
16+
--> $DIR/debug_assert_with_mut_call.rs:45:23
17+
|
18+
LL | debug_assert_eq!(!bool_mut(&mut 3), false);
19+
| ^^^^^^^^^^^^^^^^
20+
21+
error: do not call a function with mutable arguments inside of `debug_assert_eq!`
22+
--> $DIR/debug_assert_with_mut_call.rs:47:25
1723
|
1824
LL | debug_assert_eq!(0, u32_mut(&mut 3));
1925
| ^^^^^^^^^^^^^^^
2026

2127
error: do not call a function with mutable arguments inside of `debug_assert_eq!`
22-
--> $DIR/debug_assert_with_mut_call.rs:46:22
28+
--> $DIR/debug_assert_with_mut_call.rs:48:22
2329
|
2430
LL | debug_assert_eq!(u32_mut(&mut 3), 0);
2531
| ^^^^^^^^^^^^^^^
2632

2733
error: do not call a function with mutable arguments inside of `debug_assert_ne!`
28-
--> $DIR/debug_assert_with_mut_call.rs:48:25
34+
--> $DIR/debug_assert_with_mut_call.rs:50:25
2935
|
3036
LL | debug_assert_ne!(1, u32_mut(&mut 3));
3137
| ^^^^^^^^^^^^^^^
3238

3339
error: do not call a function with mutable arguments inside of `debug_assert_ne!`
34-
--> $DIR/debug_assert_with_mut_call.rs:49:22
40+
--> $DIR/debug_assert_with_mut_call.rs:51:22
3541
|
3642
LL | debug_assert_ne!(u32_mut(&mut 3), 1);
3743
| ^^^^^^^^^^^^^^^
3844

3945
error: do not call a function with mutable arguments inside of `debug_assert!`
40-
--> $DIR/debug_assert_with_mut_call.rs:64:19
46+
--> $DIR/debug_assert_with_mut_call.rs:66:19
4147
|
4248
LL | debug_assert!(S.bool_self_mut());
4349
| ^^^^^^^^^^^^^^^^^
4450

45-
error: do not call a function with mutable arguments inside of `debug_assert!`
46-
--> $DIR/debug_assert_with_mut_call.rs:65:20
51+
error: do not call a function with mutable arguments inside of `debug_assert_eq!`
52+
--> $DIR/debug_assert_with_mut_call.rs:67:30
53+
|
54+
LL | debug_assert_eq!(false, !S.bool_self_mut());
55+
| ^^^^^^^^^^^^^^^^^
56+
57+
error: do not call a function with mutable arguments inside of `debug_assert_eq!`
58+
--> $DIR/debug_assert_with_mut_call.rs:68:23
4759
|
48-
LL | debug_assert!(!S.bool_self_mut());
49-
| ^^^^^^^^^^^^^^^^^
60+
LL | debug_assert_eq!(!S.bool_self_mut(), false);
61+
| ^^^^^^^^^^^^^^^^^
5062

5163
error: do not call a function with mutable arguments inside of `debug_assert!`
52-
--> $DIR/debug_assert_with_mut_call.rs:66:19
64+
--> $DIR/debug_assert_with_mut_call.rs:69:19
5365
|
5466
LL | debug_assert!(S.bool_self_ref_arg_mut(&mut 3));
5567
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5668

5769
error: do not call a function with mutable arguments inside of `debug_assert!`
58-
--> $DIR/debug_assert_with_mut_call.rs:67:19
70+
--> $DIR/debug_assert_with_mut_call.rs:70:19
5971
|
6072
LL | debug_assert!(S.bool_self_mut_arg_ref(&3));
6173
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6274

6375
error: do not call a function with mutable arguments inside of `debug_assert!`
64-
--> $DIR/debug_assert_with_mut_call.rs:68:19
76+
--> $DIR/debug_assert_with_mut_call.rs:71:19
6577
|
6678
LL | debug_assert!(S.bool_self_mut_arg_mut(&mut 3));
6779
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6880

6981
error: do not call a function with mutable arguments inside of `debug_assert_eq!`
70-
--> $DIR/debug_assert_with_mut_call.rs:70:22
82+
--> $DIR/debug_assert_with_mut_call.rs:73:22
7183
|
7284
LL | debug_assert_eq!(S.u32_self_mut(), 0);
7385
| ^^^^^^^^^^^^^^^^
7486

7587
error: do not call a function with mutable arguments inside of `debug_assert_eq!`
76-
--> $DIR/debug_assert_with_mut_call.rs:71:22
88+
--> $DIR/debug_assert_with_mut_call.rs:74:22
7789
|
7890
LL | debug_assert_eq!(S.u32_self_mut_arg_ref(&3), 0);
7991
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
8092

8193
error: do not call a function with mutable arguments inside of `debug_assert_eq!`
82-
--> $DIR/debug_assert_with_mut_call.rs:72:22
94+
--> $DIR/debug_assert_with_mut_call.rs:75:22
8395
|
8496
LL | debug_assert_eq!(S.u32_self_ref_arg_mut(&mut 3), 0);
8597
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8698

8799
error: do not call a function with mutable arguments inside of `debug_assert_eq!`
88-
--> $DIR/debug_assert_with_mut_call.rs:73:22
100+
--> $DIR/debug_assert_with_mut_call.rs:76:22
89101
|
90102
LL | debug_assert_eq!(S.u32_self_mut_arg_mut(&mut 3), 0);
91103
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
92104

93105
error: do not call a function with mutable arguments inside of `debug_assert_ne!`
94-
--> $DIR/debug_assert_with_mut_call.rs:75:22
106+
--> $DIR/debug_assert_with_mut_call.rs:78:22
95107
|
96108
LL | debug_assert_ne!(S.u32_self_mut(), 1);
97109
| ^^^^^^^^^^^^^^^^
98110

99111
error: do not call a function with mutable arguments inside of `debug_assert_ne!`
100-
--> $DIR/debug_assert_with_mut_call.rs:76:22
112+
--> $DIR/debug_assert_with_mut_call.rs:79:22
101113
|
102114
LL | debug_assert_ne!(S.u32_self_mut_arg_ref(&3), 1);
103115
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
104116

105117
error: do not call a function with mutable arguments inside of `debug_assert_ne!`
106-
--> $DIR/debug_assert_with_mut_call.rs:77:22
118+
--> $DIR/debug_assert_with_mut_call.rs:80:22
107119
|
108120
LL | debug_assert_ne!(S.u32_self_ref_arg_mut(&mut 3), 1);
109121
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
110122

111123
error: do not call a function with mutable arguments inside of `debug_assert_ne!`
112-
--> $DIR/debug_assert_with_mut_call.rs:78:22
124+
--> $DIR/debug_assert_with_mut_call.rs:81:22
113125
|
114126
LL | debug_assert_ne!(S.u32_self_mut_arg_mut(&mut 3), 1);
115127
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
116128

117129
error: do not call a function with mutable arguments inside of `debug_assert_eq!`
118-
--> $DIR/debug_assert_with_mut_call.rs:86:22
130+
--> $DIR/debug_assert_with_mut_call.rs:89:22
119131
|
120132
LL | debug_assert_eq!(v.pop(), Some(1));
121133
| ^^^^^^^
122134

123135
error: do not call a function with mutable arguments inside of `debug_assert_ne!`
124-
--> $DIR/debug_assert_with_mut_call.rs:87:31
136+
--> $DIR/debug_assert_with_mut_call.rs:90:31
125137
|
126138
LL | debug_assert_ne!(Some(3), v.pop());
127139
| ^^^^^^^
128140

129141
error: do not call a function with mutable arguments inside of `debug_assert!`
130-
--> $DIR/debug_assert_with_mut_call.rs:90:19
142+
--> $DIR/debug_assert_with_mut_call.rs:93:19
131143
|
132144
LL | debug_assert!(bool_mut(a));
133145
| ^^^^^^^^^^^
134146

135-
error: do not call a function with mutable arguments inside of `debug_assert!`
136-
--> $DIR/debug_assert_with_mut_call.rs:93:31
147+
error: do not call a function with mutable arguments inside of `debug_assert_eq!`
148+
--> $DIR/debug_assert_with_mut_call.rs:96:41
149+
|
150+
LL | debug_assert_eq!(false, !(bool_ref(&u32_mut(&mut 3))));
151+
| ^^^^^^^^^^^^^^^
152+
153+
error: do not call a function with mutable arguments inside of `debug_assert_eq!`
154+
--> $DIR/debug_assert_with_mut_call.rs:97:34
137155
|
138-
LL | debug_assert!(!(bool_ref(&u32_mut(&mut 3))));
139-
| ^^^^^^^^^^^^^^^
156+
LL | debug_assert_eq!(!(bool_ref(&u32_mut(&mut 3))), false);
157+
| ^^^^^^^^^^^^^^^
140158

141159
error: do not call a function with mutable arguments inside of `debug_assert_eq!`
142-
--> $DIR/debug_assert_with_mut_call.rs:96:22
160+
--> $DIR/debug_assert_with_mut_call.rs:100:22
143161
|
144162
LL | debug_assert_eq!(v.pop().unwrap(), 3);
145163
| ^^^^^^^
146164

147165
error: do not call a function with mutable arguments inside of `debug_assert!`
148-
--> $DIR/debug_assert_with_mut_call.rs:100:19
166+
--> $DIR/debug_assert_with_mut_call.rs:104:19
149167
|
150168
LL | debug_assert!(bool_mut(&mut 3), "w/o format");
151169
| ^^^^^^^^^^^^^^^^
152170

153171
error: do not call a function with mutable arguments inside of `debug_assert!`
154-
--> $DIR/debug_assert_with_mut_call.rs:102:19
172+
--> $DIR/debug_assert_with_mut_call.rs:106:19
155173
|
156174
LL | debug_assert!(bool_mut(&mut 3), "{} format", "w/");
157175
| ^^^^^^^^^^^^^^^^
158176

159177
error: do not call a function with mutable arguments inside of `debug_assert!`
160-
--> $DIR/debug_assert_with_mut_call.rs:107:9
178+
--> $DIR/debug_assert_with_mut_call.rs:111:9
161179
|
162180
LL | bool_mut(&mut x);
163181
| ^^^^^^^^^^^^^^^^
164182

165183
error: do not call a function with mutable arguments inside of `debug_assert!`
166-
--> $DIR/debug_assert_with_mut_call.rs:114:9
184+
--> $DIR/debug_assert_with_mut_call.rs:118:9
167185
|
168186
LL | bool_mut(&mut x);
169187
| ^^^^^^^^^^^^^^^^
170188

171-
error: aborting due to 28 previous errors
189+
error: aborting due to 31 previous errors
172190

0 commit comments

Comments
 (0)