Skip to content

Commit e21270f

Browse files
committed
if clippy was so cool, where is clippy commit2?
1 parent 790b10c commit e21270f

File tree

3 files changed

+16
-33
lines changed

3 files changed

+16
-33
lines changed

tooling/ssa_fuzzer/fuzzer/fuzz_targets/field.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl FuzzerContext {
182182

183183
/// Gets an element from an array at the given index
184184
fn insert_array_get(&mut self, array_idx: u32, index: u32) {
185-
if self.acir_arrays.len() <= 0 {
185+
if self.acir_arrays.is_empty() {
186186
// no arrays created
187187
return;
188188
}
@@ -204,7 +204,7 @@ impl FuzzerContext {
204204

205205
/// Sets an element in an array at the given index
206206
fn insert_array_set(&mut self, array_idx: u32, index: u32, value: u32) {
207-
if self.acir_arrays.len() <= 0 {
207+
if self.acir_arrays.is_empty() {
208208
// no arrays created
209209
return;
210210
}
@@ -329,8 +329,7 @@ impl FuzzerContext {
329329
self.acir_ids.push(id_to_int(acir_result));
330330
self.brillig_ids.push(id_to_int(brillig_result));
331331
}
332-
_ => {
333-
}
332+
_ => {}
334333
}
335334
}
336335

tooling/ssa_fuzzer/fuzzer/fuzz_targets/uint.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,7 @@ impl FuzzerContext {
328328
self.acir_ids.push(id_to_int(acir_result));
329329
self.brillig_ids.push(id_to_int(brillig_result));
330330
}
331-
_ => {
332-
}
331+
_ => {}
333332
}
334333
}
335334

tooling/ssa_fuzzer/src/builder.rs

+12-27
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ impl FuzzerBuilder {
7474

7575
/// Inserts an add instruction between two values
7676
pub fn insert_add_instruction_checked(&mut self, lhs: Id<Value>, rhs: Id<Value>) -> Id<Value> {
77-
7877
self.builder.insert_binary(lhs, BinaryOp::Add { unchecked: false }, rhs)
7978
}
8079

@@ -83,13 +82,11 @@ impl FuzzerBuilder {
8382
lhs: Id<Value>,
8483
rhs: Id<Value>,
8584
) -> Id<Value> {
86-
8785
self.builder.insert_binary(lhs, BinaryOp::Add { unchecked: true }, rhs)
8886
}
8987

9088
/// Inserts a subtract instruction between two values
9189
pub fn insert_sub_instruction_checked(&mut self, lhs: Id<Value>, rhs: Id<Value>) -> Id<Value> {
92-
9390
self.builder.insert_binary(lhs, BinaryOp::Sub { unchecked: false }, rhs)
9491
}
9592

@@ -98,13 +95,11 @@ impl FuzzerBuilder {
9895
lhs: Id<Value>,
9996
rhs: Id<Value>,
10097
) -> Id<Value> {
101-
10298
self.builder.insert_binary(lhs, BinaryOp::Sub { unchecked: true }, rhs)
10399
}
104100

105101
/// Inserts a multiply instruction between two values
106102
pub fn insert_mul_instruction_checked(&mut self, lhs: Id<Value>, rhs: Id<Value>) -> Id<Value> {
107-
108103
self.builder.insert_binary(lhs, BinaryOp::Mul { unchecked: false }, rhs)
109104
}
110105

@@ -113,31 +108,26 @@ impl FuzzerBuilder {
113108
lhs: Id<Value>,
114109
rhs: Id<Value>,
115110
) -> Id<Value> {
116-
117111
self.builder.insert_binary(lhs, BinaryOp::Mul { unchecked: true }, rhs)
118112
}
119113

120114
/// Inserts a divide instruction between two values
121115
pub fn insert_div_instruction(&mut self, lhs: Id<Value>, rhs: Id<Value>) -> Id<Value> {
122-
123116
self.builder.insert_binary(lhs, BinaryOp::Div, rhs)
124117
}
125118

126119
/// Inserts a modulo instruction between two values
127120
pub fn insert_mod_instruction(&mut self, lhs: Id<Value>, rhs: Id<Value>) -> Id<Value> {
128-
129121
self.builder.insert_binary(lhs, BinaryOp::Mod, rhs)
130122
}
131123

132124
/// Inserts a not instruction for the given value
133125
pub fn insert_not_instruction(&mut self, lhs: Id<Value>) -> Id<Value> {
134-
135126
self.builder.insert_not(lhs)
136127
}
137128

138129
/// Inserts a cast instruction to the current numeric type
139130
pub fn insert_simple_cast(&mut self, value: Id<Value>) -> Id<Value> {
140-
141131
self.builder.insert_cast(value, self.numeric_type)
142132
}
143133

@@ -151,50 +141,45 @@ impl FuzzerBuilder {
151141
match self.numeric_type {
152142
NumericType::Signed { bit_size: _ } => {
153143
let res1 = self.builder.insert_cast(value, NumericType::Signed { bit_size: size });
154-
144+
155145
self.insert_simple_cast(res1)
156146
}
157147
NumericType::Unsigned { bit_size: _ } => {
158148
let res1 =
159149
self.builder.insert_cast(value, NumericType::Unsigned { bit_size: size });
160-
150+
161151
self.insert_simple_cast(res1)
162152
}
163-
NumericType::NativeField => {
164-
value
165-
}
153+
NumericType::NativeField => value,
166154
}
167155
}
168156

169157
/// Inserts an equals comparison instruction between two values
170158
pub fn insert_eq_instruction(&mut self, lhs: Id<Value>, rhs: Id<Value>) -> Id<Value> {
171159
let res1 = self.builder.insert_binary(lhs, BinaryOp::Eq, rhs);
172-
160+
173161
self.insert_simple_cast(res1)
174162
}
175163

176164
/// Inserts a less than comparison instruction between two values
177165
pub fn insert_lt_instruction(&mut self, lhs: Id<Value>, rhs: Id<Value>) -> Id<Value> {
178166
let res1 = self.builder.insert_binary(lhs, BinaryOp::Lt, rhs);
179-
167+
180168
self.insert_simple_cast(res1)
181169
}
182170

183171
/// Inserts a bitwise AND instruction between two values
184172
pub fn insert_and_instruction(&mut self, lhs: Id<Value>, rhs: Id<Value>) -> Id<Value> {
185-
186173
self.builder.insert_binary(lhs, BinaryOp::And, rhs)
187174
}
188175

189176
/// Inserts a bitwise OR instruction between two values
190177
pub fn insert_or_instruction(&mut self, lhs: Id<Value>, rhs: Id<Value>) -> Id<Value> {
191-
192178
self.builder.insert_binary(lhs, BinaryOp::Or, rhs)
193179
}
194180

195181
/// Inserts a bitwise XOR instruction between two values
196182
pub fn insert_xor_instruction(&mut self, lhs: Id<Value>, rhs: Id<Value>) -> Id<Value> {
197-
198183
self.builder.insert_binary(lhs, BinaryOp::Xor, rhs)
199184
}
200185

@@ -205,13 +190,13 @@ impl FuzzerBuilder {
205190
match self.numeric_type {
206191
NumericType::Signed { bit_size: _ } => {
207192
let rhs_value = self.builder.insert_cast(rhs, NumericType::Signed { bit_size: 8 });
208-
193+
209194
self.builder.insert_binary(lhs, BinaryOp::Shl, rhs_value)
210195
}
211196
NumericType::Unsigned { bit_size: _ } => {
212197
let rhs_value =
213198
self.builder.insert_cast(rhs, NumericType::Unsigned { bit_size: 8 });
214-
199+
215200
self.builder.insert_binary(lhs, BinaryOp::Shl, rhs_value)
216201
}
217202
_ => {
@@ -228,13 +213,13 @@ impl FuzzerBuilder {
228213
NumericType::Signed { bit_size: _ } => {
229214
let rhs_value =
230215
self.builder.insert_cast(rhs, NumericType::Unsigned { bit_size: 8 });
231-
216+
232217
self.builder.insert_binary(lhs, BinaryOp::Shr, rhs_value)
233218
}
234219
NumericType::Unsigned { bit_size: _ } => {
235220
let rhs_value =
236221
self.builder.insert_cast(rhs, NumericType::Unsigned { bit_size: 8 });
237-
222+
238223
self.builder.insert_binary(lhs, BinaryOp::Shr, rhs_value)
239224
}
240225
_ => {
@@ -251,7 +236,7 @@ impl FuzzerBuilder {
251236
elems.push(helpers::u32_to_id_value(elem));
252237
}
253238
let types = vec![self.type_.clone(); elements.len()];
254-
239+
255240
self.builder.insert_make_array(
256241
im::Vector::from(elems),
257242
Type::Array(Arc::new(types), elements.len() as u32),
@@ -262,7 +247,7 @@ impl FuzzerBuilder {
262247
pub fn insert_array_get(&mut self, array: Id<Value>, index: u32) -> Id<Value> {
263248
let index_var =
264249
self.builder.numeric_constant(index, NumericType::Unsigned { bit_size: 32 });
265-
250+
266251
self.builder.insert_array_get(array, index_var, self.type_.clone())
267252
}
268253

@@ -275,7 +260,7 @@ impl FuzzerBuilder {
275260
) -> Id<Value> {
276261
let index_var =
277262
self.builder.numeric_constant(index, NumericType::Unsigned { bit_size: 32 });
278-
263+
279264
self.builder.insert_array_set(array, index_var, value)
280265
}
281266

0 commit comments

Comments
 (0)