Skip to content

Commit 890d622

Browse files
authored
fix clippy lints for Rust 1.86 (#193)
1 parent 9fb9c68 commit 890d622

File tree

9 files changed

+125
-134
lines changed

9 files changed

+125
-134
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ repos:
2121
pass_filenames: false
2222
- id: clippy
2323
name: Clippy
24-
entry: cargo clippy -F python -- -D warnings
24+
entry: cargo clippy -F python --workspace --all-targets -- -D warnings
2525
types: [rust]
2626
language: system
2727
pass_filenames: false

crates/jiter-python/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ keywords = {workspace = true}
88
categories = {workspace = true}
99
homepage = {workspace = true}
1010
repository = {workspace = true}
11+
rust-version = { workspace = true }
1112

1213
[dependencies]
1314
pyo3 = { workspace = true, features = ["num-bigint"] }

crates/jiter/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ keywords = { workspace = true }
1010
categories = { workspace = true }
1111
homepage = { workspace = true }
1212
repository = { workspace = true }
13+
rust-version = { workspace = true }
1314

1415
[dependencies]
1516
num-bigint = { version = "0.4.4", optional = true }

crates/jiter/benches/main.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn jiter_value(path: &str, bench: &mut Bencher) {
2020
bench.iter(|| {
2121
let v = JsonValue::parse(black_box(json_data), false).unwrap();
2222
black_box(v)
23-
})
23+
});
2424
}
2525

2626
fn jiter_skip(path: &str, bench: &mut Bencher) {
@@ -29,7 +29,7 @@ fn jiter_skip(path: &str, bench: &mut Bencher) {
2929
bench.iter(|| {
3030
let mut jiter = Jiter::new(json_data);
3131
jiter.next_skip().unwrap();
32-
})
32+
});
3333
}
3434

3535
fn jiter_iter_big(path: &str, bench: &mut Bencher) {
@@ -52,7 +52,7 @@ fn jiter_iter_big(path: &str, bench: &mut Bencher) {
5252
break;
5353
}
5454
}
55-
})
55+
});
5656
}
5757

5858
fn find_string(jiter: &mut Jiter) -> String {
@@ -77,7 +77,7 @@ fn jiter_iter_pass2(path: &str, bench: &mut Bencher) {
7777
let string = find_string(&mut jiter);
7878
jiter.finish().unwrap();
7979
black_box(string)
80-
})
80+
});
8181
}
8282

8383
fn jiter_iter_string_array(path: &str, bench: &mut Bencher) {
@@ -94,7 +94,7 @@ fn jiter_iter_string_array(path: &str, bench: &mut Bencher) {
9494
black_box(i.len());
9595
}
9696
jiter.finish().unwrap();
97-
})
97+
});
9898
}
9999

100100
fn jiter_iter_true_array(path: &str, bench: &mut Bencher) {
@@ -109,7 +109,7 @@ fn jiter_iter_true_array(path: &str, bench: &mut Bencher) {
109109
let i = jiter.known_bool(peek).unwrap();
110110
black_box(i);
111111
}
112-
})
112+
});
113113
}
114114

115115
fn jiter_iter_true_object(path: &str, bench: &mut Bencher) {
@@ -127,7 +127,7 @@ fn jiter_iter_true_object(path: &str, bench: &mut Bencher) {
127127
black_box((key, value));
128128
}
129129
}
130-
})
130+
});
131131
}
132132

133133
fn jiter_iter_ints_array(path: &str, bench: &mut Bencher) {
@@ -142,7 +142,7 @@ fn jiter_iter_ints_array(path: &str, bench: &mut Bencher) {
142142
let i = jiter.known_int(peek).unwrap();
143143
black_box(i);
144144
}
145-
})
145+
});
146146
}
147147

148148
fn jiter_iter_floats_array(path: &str, bench: &mut Bencher) {
@@ -157,7 +157,7 @@ fn jiter_iter_floats_array(path: &str, bench: &mut Bencher) {
157157
let i = jiter.known_float(peek).unwrap();
158158
black_box(i);
159159
}
160-
})
160+
});
161161
}
162162

163163
fn jiter_string(path: &str, bench: &mut Bencher) {
@@ -168,7 +168,7 @@ fn jiter_string(path: &str, bench: &mut Bencher) {
168168
let string = jiter.next_str().unwrap();
169169
black_box(string);
170170
jiter.finish().unwrap();
171-
})
171+
});
172172
}
173173

174174
fn serde_value(path: &str, bench: &mut Bencher) {
@@ -177,7 +177,7 @@ fn serde_value(path: &str, bench: &mut Bencher) {
177177
bench.iter(|| {
178178
let value: Value = serde_json::from_slice(json_data).unwrap();
179179
black_box(value);
180-
})
180+
});
181181
}
182182

183183
fn serde_str(path: &str, bench: &mut Bencher) {
@@ -186,7 +186,7 @@ fn serde_str(path: &str, bench: &mut Bencher) {
186186
bench.iter(|| {
187187
let value: String = serde_json::from_slice(json_data).unwrap();
188188
black_box(value);
189-
})
189+
});
190190
}
191191

192192
macro_rules! test_cases {
@@ -260,7 +260,7 @@ fn string_array_jiter_value_owned(bench: &mut Bencher) {
260260
bench.iter(|| {
261261
let v = JsonValue::parse_owned(black_box(json_data), false, PartialMode::Off).unwrap();
262262
black_box(v)
263-
})
263+
});
264264
}
265265

266266
fn medium_response_jiter_value_owned(bench: &mut Bencher) {
@@ -269,7 +269,7 @@ fn medium_response_jiter_value_owned(bench: &mut Bencher) {
269269
bench.iter(|| {
270270
let v = JsonValue::parse_owned(black_box(json_data), false, PartialMode::Off).unwrap();
271271
black_box(v)
272-
})
272+
});
273273
}
274274

275275
fn x100_serde_iter(bench: &mut Bencher) {

crates/jiter/benches/python.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn python_parse_numeric(bench: &mut Bencher) {
1818
)
1919
.unwrap()
2020
});
21-
})
21+
});
2222
}
2323

2424
fn python_parse_other(bench: &mut Bencher) {
@@ -29,10 +29,10 @@ fn python_parse_other(bench: &mut Bencher) {
2929
.python_parse(py, br#"["string", true, false, null]"#)
3030
.unwrap()
3131
});
32-
})
32+
});
3333
}
3434

35-
fn _python_parse_file(path: &str, bench: &mut Bencher, cache_mode: StringCacheMode) {
35+
fn python_parse_file(path: &str, bench: &mut Bencher, cache_mode: StringCacheMode) {
3636
let mut file = File::open(path).unwrap();
3737
let mut contents = String::new();
3838
file.read_to_string(&mut contents).unwrap();
@@ -48,56 +48,56 @@ fn _python_parse_file(path: &str, bench: &mut Bencher, cache_mode: StringCacheMo
4848
.python_parse(py, json_data)
4949
.unwrap()
5050
});
51-
})
51+
});
5252
}
5353

5454
fn python_parse_massive_ints_array(bench: &mut Bencher) {
55-
_python_parse_file("./benches/massive_ints_array.json", bench, StringCacheMode::All);
55+
python_parse_file("./benches/massive_ints_array.json", bench, StringCacheMode::All);
5656
}
5757

5858
fn python_parse_medium_response_not_cached(bench: &mut Bencher) {
59-
_python_parse_file("./benches/medium_response.json", bench, StringCacheMode::None);
59+
python_parse_file("./benches/medium_response.json", bench, StringCacheMode::None);
6060
}
6161

6262
fn python_parse_medium_response(bench: &mut Bencher) {
63-
_python_parse_file("./benches/medium_response.json", bench, StringCacheMode::All);
63+
python_parse_file("./benches/medium_response.json", bench, StringCacheMode::All);
6464
}
6565

6666
fn python_parse_true_object_not_cached(bench: &mut Bencher) {
67-
_python_parse_file("./benches/true_object.json", bench, StringCacheMode::None);
67+
python_parse_file("./benches/true_object.json", bench, StringCacheMode::None);
6868
}
6969

7070
fn python_parse_string_array_not_cached(bench: &mut Bencher) {
71-
_python_parse_file("./benches/string_array.json", bench, StringCacheMode::None);
71+
python_parse_file("./benches/string_array.json", bench, StringCacheMode::None);
7272
}
7373

7474
fn python_parse_string_array(bench: &mut Bencher) {
75-
_python_parse_file("./benches/string_array.json", bench, StringCacheMode::All);
75+
python_parse_file("./benches/string_array.json", bench, StringCacheMode::All);
7676
}
7777

7878
fn python_parse_x100_not_cached(bench: &mut Bencher) {
79-
_python_parse_file("./benches/x100.json", bench, StringCacheMode::None);
79+
python_parse_file("./benches/x100.json", bench, StringCacheMode::None);
8080
}
8181

8282
fn python_parse_x100(bench: &mut Bencher) {
83-
_python_parse_file("./benches/x100.json", bench, StringCacheMode::All);
83+
python_parse_file("./benches/x100.json", bench, StringCacheMode::All);
8484
}
8585

8686
fn python_parse_string_array_unique_not_cached(bench: &mut Bencher) {
87-
_python_parse_file("./benches/string_array_unique.json", bench, StringCacheMode::None);
87+
python_parse_file("./benches/string_array_unique.json", bench, StringCacheMode::None);
8888
}
8989

9090
fn python_parse_string_array_unique(bench: &mut Bencher) {
91-
_python_parse_file("./benches/string_array_unique.json", bench, StringCacheMode::All);
91+
python_parse_file("./benches/string_array_unique.json", bench, StringCacheMode::All);
9292
}
9393

9494
fn python_parse_true_object(bench: &mut Bencher) {
95-
_python_parse_file("./benches/true_object.json", bench, StringCacheMode::All);
95+
python_parse_file("./benches/true_object.json", bench, StringCacheMode::All);
9696
}
9797

9898
/// Note - caching strings should make no difference here
9999
fn python_parse_true_array(bench: &mut Bencher) {
100-
_python_parse_file("./benches/true_array.json", bench, StringCacheMode::All);
100+
python_parse_file("./benches/true_array.json", bench, StringCacheMode::All);
101101
}
102102

103103
benchmark_group!(

crates/jiter/src/number_decoder.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl AbstractNumberDecoder for NumberFloat {
8383
if !positive {
8484
// we started with a minus sign, so the first digit is at index + 1
8585
index += 1;
86-
};
86+
}
8787
let first2 = if positive { Some(&first) } else { data.get(index) };
8888

8989
if let Some(digit) = first2 {
@@ -210,7 +210,7 @@ impl IntParse {
210210
if !positive {
211211
// we started with a minus sign, so the first digit is at index + 1
212212
index += 1;
213-
};
213+
}
214214
let first2 = if positive { Some(&first) } else { data.get(index) };
215215
let first_value = match first2 {
216216
Some(b'0') => {
@@ -425,7 +425,7 @@ impl AbstractNumberDecoder for NumberRange {
425425
if !positive {
426426
// we started with a minus sign, so the first digit is at index + 1
427427
index += 1;
428-
};
428+
}
429429

430430
match data.get(index) {
431431
Some(b'0') => {
@@ -453,7 +453,7 @@ impl AbstractNumberDecoder for NumberRange {
453453
Some(digit) if (b'1'..=b'9').contains(digit) => (),
454454
Some(_) => return json_err!(InvalidNumber, index),
455455
None => return json_err!(EofWhileParsingValue, index),
456-
};
456+
}
457457

458458
index += 1;
459459
for _ in 0..18 {
@@ -511,13 +511,13 @@ fn consume_exponential(data: &[u8], mut index: usize) -> JsonResult<usize> {
511511
Some(v) if v.is_ascii_digit() => (),
512512
Some(_) => return json_err!(InvalidNumber, index),
513513
None => return json_err!(EofWhileParsingValue, index),
514-
};
514+
}
515515

516516
match data.get(index) {
517517
Some(v) if v.is_ascii_digit() => (),
518518
Some(_) => return json_err!(InvalidNumber, index),
519519
None => return json_err!(EofWhileParsingValue, index),
520-
};
520+
}
521521
index += 1;
522522

523523
while let Some(next) = data.get(index) {
@@ -536,7 +536,7 @@ fn consume_decimal(data: &[u8], mut index: usize) -> JsonResult<usize> {
536536
Some(v) if v.is_ascii_digit() => (),
537537
Some(_) => return json_err!(InvalidNumber, index),
538538
None => return json_err!(EofWhileParsingValue, index),
539-
};
539+
}
540540
index += 1;
541541

542542
while let Some(next) = data.get(index) {

crates/jiter/src/value.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ fn take_value_recursive<'j, 's>(
397397
}
398398
Err(e) if !(partial_active && e.allowed_if_partial()) => return Err(e),
399399
_ => (),
400-
};
400+
}
401401
Ok(JsonValue::empty_array())
402402
}
403403
Peek::Object => {
@@ -412,7 +412,7 @@ fn take_value_recursive<'j, 's>(
412412
},
413413
Err(e) if !(partial_active && e.allowed_if_partial()) => return Err(e),
414414
_ => (),
415-
};
415+
}
416416
Ok(JsonValue::empty_object())
417417
}
418418
_ => parser
@@ -444,7 +444,7 @@ fn take_value_recursive<'j, 's>(
444444
}
445445
Err(e) if !(partial_active && e.allowed_if_partial()) => return Err(e),
446446
_ => (),
447-
};
447+
}
448448

449449
let RecursedValue::Array(mut array) = current_recursion else {
450450
unreachable!("known to be in array recursion");
@@ -482,7 +482,7 @@ fn take_value_recursive<'j, 's>(
482482
}
483483
Err(e) if !(partial_active && e.allowed_if_partial()) => return Err(e),
484484
_ => (),
485-
};
485+
}
486486
Ok(JsonValue::empty_array())
487487
}
488488
Peek::Object => {
@@ -497,7 +497,7 @@ fn take_value_recursive<'j, 's>(
497497
},
498498
Err(e) if !(partial_active && e.allowed_if_partial()) => return Err(e),
499499
_ => (),
500-
};
500+
}
501501
Ok(JsonValue::empty_object())
502502
}
503503
_ => parser
@@ -534,7 +534,7 @@ fn take_value_recursive<'j, 's>(
534534
}
535535
Err(e) if !(partial_active && e.allowed_if_partial()) => return Err(e),
536536
_ => (),
537-
};
537+
}
538538
}
539539
Err(e) if !(partial_active && e.allowed_if_partial()) => return Err(e),
540540
_ => (),
@@ -712,7 +712,7 @@ fn take_value_skip_recursive(
712712
}
713713
})?;
714714
}
715-
};
715+
}
716716

717717
// now try to advance position in the current array or object
718718
peek = loop {

0 commit comments

Comments
 (0)