Skip to content

Commit 42a31bc

Browse files
committed
fix more clippy warnings
1 parent 3de13c5 commit 42a31bc

File tree

7 files changed

+38
-40
lines changed

7 files changed

+38
-40
lines changed

lain/src/dangerous_numbers.rs

+28-28
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,61 @@ use crate::rand::Rng;
22
use crate::traits::*;
33

44
static DANGEROUS_NUMBERS_U8: &[u8] = &[
5-
std::u8::MIN, // 0x00
6-
std::u8::MAX, // 0xff
7-
std::i8::MAX as u8, // 0x7f
8-
(std::i8::MAX as u8) + 1, // 0x80
5+
u8::MIN, // 0x00
6+
u8::MAX, // 0xff
7+
i8::MAX as u8, // 0x7f
8+
(i8::MAX as u8) + 1, // 0x80
99
];
1010

1111
static DANGEROUS_NUMBERS_U16: &[u16] = &[
1212
// big-endian variants
13-
std::u16::MIN, // 0x0000
14-
std::u16::MAX, // 0xffff
15-
std::i16::MAX as u16, // 0x7fff
16-
(std::i16::MAX as u16) + 1, // 0x8000
13+
u16::MIN, // 0x0000
14+
u16::MAX, // 0xffff
15+
i16::MAX as u16, // 0x7fff
16+
(i16::MAX as u16) + 1, // 0x8000
1717
// little-endian variants
1818
0xff7f,
1919
0x0080,
2020
];
2121

2222
static DANGEROUS_NUMBERS_U32: &[u32] = &[
2323
// big-endian variants
24-
std::u32::MIN,
25-
std::u32::MAX,
26-
std::i32::MAX as u32,
27-
(std::i32::MAX as u32) + 1,
24+
u32::MIN,
25+
u32::MAX,
26+
i32::MAX as u32,
27+
(i32::MAX as u32) + 1,
2828
// little-endian variants
2929
0xffff_ff7f,
3030
0x0000_0080,
3131
];
3232

3333
static DANGEROUS_NUMBERS_U64: &[u64] = &[
3434
// big-endian variants
35-
std::u64::MIN,
36-
std::u64::MAX,
37-
std::i64::MAX as u64,
38-
(std::i64::MAX as u64) + 1,
35+
u64::MIN,
36+
u64::MAX,
37+
i64::MAX as u64,
38+
(i64::MAX as u64) + 1,
3939
// little-endian variants
4040
0xffff_ffff_ffff_ff7f,
4141
0x0000_0000_0000_0080,
4242
];
4343

4444
static DANGEROUS_NUMBERS_F32: &[f32] = &[
45-
std::f32::INFINITY,
46-
std::f32::MAX,
47-
std::f32::MIN,
48-
std::f32::MIN_POSITIVE,
49-
std::f32::NAN,
50-
std::f32::NEG_INFINITY,
45+
f32::INFINITY,
46+
f32::MAX,
47+
f32::MIN,
48+
f32::MIN_POSITIVE,
49+
f32::NAN,
50+
f32::NEG_INFINITY,
5151
];
5252

5353
static DANGEROUS_NUMBERS_F64: &[f64] = &[
54-
std::f64::INFINITY,
55-
std::f64::MAX,
56-
std::f64::MIN,
57-
std::f64::MIN_POSITIVE,
58-
std::f64::NAN,
59-
std::f64::NEG_INFINITY,
54+
f64::INFINITY,
55+
f64::MAX,
56+
f64::MIN,
57+
f64::MIN_POSITIVE,
58+
f64::NAN,
59+
f64::NEG_INFINITY,
6060
];
6161

6262
macro_rules! dangerous_number {

lain/src/driver.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ pub fn start_fuzzer<F: 'static, C: 'static, T: 'static + Send + Sync>(
243243

244244
mutator.random_flags();
245245

246-
if (callback)(&mut mutator, &mut context, thread_driver.global_context()).is_err()
246+
if (callback)(&mut mutator, &mut context, thread_driver.global_context())
247+
.is_err()
247248
{
248249
thread_driver
249250
.num_failed_iterations

lain/src/mutator.rs

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ pub struct CorpusFuzzingState {
4343
fields_fuzzed: usize,
4444
}
4545

46-
4746
impl CorpusFuzzingState {
4847
pub fn reset(&mut self) {
4948
self.fields_fuzzed = 0;

lain/src/new_fuzzed.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -704,13 +704,13 @@ macro_rules! impl_new_fuzzed {
704704

705705
min = if let Some(ref min) = constraints.min {
706706
if mutator.gen_chance(crate::mutator::CHANCE_TO_IGNORE_MIN_MAX) {
707-
$name::min_value()
707+
$name::MIN
708708
} else {
709709
ignore_min = false;
710710
*min
711711
}
712712
} else {
713-
$name::min_value()
713+
$name::MIN
714714
};
715715

716716
max = if let Some(ref max) = constraints.max {

lain/src/types.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,10 @@ impl<T: Bounded + Debug> Constraints<T> {
179179
}
180180

181181
/// Which direction to weigh ranges towards (min bound, upper bound, or none).
182-
#[derive(Debug, PartialEq, Clone, Copy)]
183-
#[derive(Default)]
182+
#[derive(Debug, PartialEq, Clone, Copy, Default)]
184183
pub enum Weighted {
185184
#[default]
186185
None,
187186
Min,
188187
Max,
189188
}
190-

lain_derive/src/lib.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,10 @@ pub fn fuzzer_object(input: proc_macro::TokenStream) -> proc_macro::TokenStream
253253

254254
let input = parse_macro_input!(input as DeriveInput);
255255
base_token_stream.extend::<TokenStream>(
256-
mutations::expand_new_fuzzed(&input)
257-
.unwrap_or_else(to_compile_errors),
256+
mutations::expand_new_fuzzed(&input).unwrap_or_else(to_compile_errors),
258257
);
259258
base_token_stream.extend::<TokenStream>(
260-
mutations::expand_mutatable(&input)
261-
.unwrap_or_else(to_compile_errors),
259+
mutations::expand_mutatable(&input).unwrap_or_else(to_compile_errors),
262260
);
263261
base_token_stream.extend::<TokenStream>(variable_size_object_helper(&input));
264262

lain_derive/src/mutations.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,9 @@ fn new_fuzzed_struct_visitor(fields: &[Field], cont_ident: &syn::Ident) -> Vec<T
477477

478478
fn struct_field_constraints(field: &Field, for_mutation: bool) -> TokenStream {
479479
let attrs = &field.attrs;
480-
if !for_mutation && (attrs.ignore() || (attrs.initializer().is_some() && attrs.ignore_chance().is_none())) {
480+
if !for_mutation
481+
&& (attrs.ignore() || (attrs.initializer().is_some() && attrs.ignore_chance().is_none()))
482+
{
481483
return TokenStream::new();
482484
}
483485

0 commit comments

Comments
 (0)