Skip to content

Commit dd2bf4c

Browse files
committed
fix clippy
1 parent a3df216 commit dd2bf4c

File tree

9 files changed

+50
-62
lines changed

9 files changed

+50
-62
lines changed

common/src/float_ops.rs

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -478,40 +478,32 @@ fn test_to_hex() {
478478

479479
#[test]
480480
fn test_remove_trailing_zeros() {
481-
assert!(remove_trailing_zeros(String::from("100")) == String::from("1"));
482-
assert!(remove_trailing_zeros(String::from("100.00")) == String::from("100."));
481+
assert!(remove_trailing_zeros(String::from("100")) == *"1");
482+
assert!(remove_trailing_zeros(String::from("100.00")) == *"100.");
483483

484484
// leave leading zeros untouched
485-
assert!(remove_trailing_zeros(String::from("001")) == String::from("001"));
485+
assert!(remove_trailing_zeros(String::from("001")) == *"001");
486486

487487
// leave strings untouched if they don't end with 0
488-
assert!(remove_trailing_zeros(String::from("101")) == String::from("101"));
488+
assert!(remove_trailing_zeros(String::from("101")) == *"101");
489489
}
490490

491491
#[test]
492492
fn test_remove_trailing_decimal_point() {
493-
assert!(remove_trailing_decimal_point(String::from("100.")) == String::from("100"));
494-
assert!(remove_trailing_decimal_point(String::from("1.")) == String::from("1"));
493+
assert!(remove_trailing_decimal_point(String::from("100.")) == *"100");
494+
assert!(remove_trailing_decimal_point(String::from("1.")) == *"1");
495495

496496
// leave leading decimal points untouched
497-
assert!(remove_trailing_decimal_point(String::from(".5")) == String::from(".5"));
497+
assert!(remove_trailing_decimal_point(String::from(".5")) == *".5");
498498
}
499499

500500
#[test]
501501
fn test_maybe_remove_trailing_redundant_chars() {
502-
assert!(
503-
maybe_remove_trailing_redundant_chars(String::from("100."), true) == String::from("100.")
504-
);
505-
assert!(
506-
maybe_remove_trailing_redundant_chars(String::from("100."), false) == String::from("100")
507-
);
508-
assert!(maybe_remove_trailing_redundant_chars(String::from("1."), false) == String::from("1"));
509-
assert!(
510-
maybe_remove_trailing_redundant_chars(String::from("10.0"), false) == String::from("10")
511-
);
502+
assert!(maybe_remove_trailing_redundant_chars(String::from("100."), true) == *"100.");
503+
assert!(maybe_remove_trailing_redundant_chars(String::from("100."), false) == *"100");
504+
assert!(maybe_remove_trailing_redundant_chars(String::from("1."), false) == *"1");
505+
assert!(maybe_remove_trailing_redundant_chars(String::from("10.0"), false) == *"10");
512506

513507
// don't truncate integers
514-
assert!(
515-
maybe_remove_trailing_redundant_chars(String::from("1000"), false) == String::from("1000")
516-
);
508+
assert!(maybe_remove_trailing_redundant_chars(String::from("1000"), false) == *"1000");
517509
}

jit/tests/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl StackMachine {
141141
instruction
142142
),
143143
}
144-
return false;
144+
false
145145
}
146146

147147
pub fn get_function(&self, name: &str) -> Function {

parser/src/fstring.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -306,23 +306,23 @@ mod tests {
306306
#[test]
307307
fn test_parse_fstring() {
308308
let source = "{a}{ b }{{foo}}";
309-
let parse_ast = parse_fstring(&source).unwrap();
309+
let parse_ast = parse_fstring(source).unwrap();
310310

311311
insta::assert_debug_snapshot!(parse_ast);
312312
}
313313

314314
#[test]
315315
fn test_parse_fstring_nested_spec() {
316316
let source = "{foo:{spec}}";
317-
let parse_ast = parse_fstring(&source).unwrap();
317+
let parse_ast = parse_fstring(source).unwrap();
318318

319319
insta::assert_debug_snapshot!(parse_ast);
320320
}
321321

322322
#[test]
323323
fn test_parse_fstring_not_nested_spec() {
324324
let source = "{foo:spec}";
325-
let parse_ast = parse_fstring(&source).unwrap();
325+
let parse_ast = parse_fstring(source).unwrap();
326326

327327
insta::assert_debug_snapshot!(parse_ast);
328328
}
@@ -335,23 +335,23 @@ mod tests {
335335
#[test]
336336
fn test_fstring_parse_selfdocumenting_base() {
337337
let src = "{user=}";
338-
let parse_ast = parse_fstring(&src).unwrap();
338+
let parse_ast = parse_fstring(src).unwrap();
339339

340340
insta::assert_debug_snapshot!(parse_ast);
341341
}
342342

343343
#[test]
344344
fn test_fstring_parse_selfdocumenting_base_more() {
345345
let src = "mix {user=} with text and {second=}";
346-
let parse_ast = parse_fstring(&src).unwrap();
346+
let parse_ast = parse_fstring(src).unwrap();
347347

348348
insta::assert_debug_snapshot!(parse_ast);
349349
}
350350

351351
#[test]
352352
fn test_fstring_parse_selfdocumenting_format() {
353353
let src = "{user=:>10}";
354-
let parse_ast = parse_fstring(&src).unwrap();
354+
let parse_ast = parse_fstring(src).unwrap();
355355

356356
insta::assert_debug_snapshot!(parse_ast);
357357
}
@@ -384,35 +384,35 @@ mod tests {
384384
#[test]
385385
fn test_parse_fstring_not_equals() {
386386
let source = "{1 != 2}";
387-
let parse_ast = parse_fstring(&source).unwrap();
387+
let parse_ast = parse_fstring(source).unwrap();
388388
insta::assert_debug_snapshot!(parse_ast);
389389
}
390390

391391
#[test]
392392
fn test_parse_fstring_equals() {
393393
let source = "{42 == 42}";
394-
let parse_ast = parse_fstring(&source).unwrap();
394+
let parse_ast = parse_fstring(source).unwrap();
395395
insta::assert_debug_snapshot!(parse_ast);
396396
}
397397

398398
#[test]
399399
fn test_parse_fstring_selfdoc_prec_space() {
400400
let source = "{x =}";
401-
let parse_ast = parse_fstring(&source).unwrap();
401+
let parse_ast = parse_fstring(source).unwrap();
402402
insta::assert_debug_snapshot!(parse_ast);
403403
}
404404

405405
#[test]
406406
fn test_parse_fstring_selfdoc_trailing_space() {
407407
let source = "{x= }";
408-
let parse_ast = parse_fstring(&source).unwrap();
408+
let parse_ast = parse_fstring(source).unwrap();
409409
insta::assert_debug_snapshot!(parse_ast);
410410
}
411411

412412
#[test]
413413
fn test_parse_fstring_yield_expr() {
414414
let source = "{yield}";
415-
let parse_ast = parse_fstring(&source).unwrap();
415+
let parse_ast = parse_fstring(source).unwrap();
416416
insta::assert_debug_snapshot!(parse_ast);
417417
}
418418
}

parser/src/parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,15 @@ mod tests {
122122
#[test]
123123
fn test_parse_lambda() {
124124
let source = "lambda x, y: x * y"; // lambda(x, y): x * y";
125-
let parse_ast = parse_program(&source).unwrap();
125+
let parse_ast = parse_program(source).unwrap();
126126
insta::assert_debug_snapshot!(parse_ast);
127127
}
128128

129129
#[test]
130130
fn test_parse_tuples() {
131131
let source = "a, b = 4, 5";
132132

133-
insta::assert_debug_snapshot!(parse_program(&source).unwrap());
133+
insta::assert_debug_snapshot!(parse_program(source).unwrap());
134134
}
135135

136136
#[test]
@@ -141,7 +141,7 @@ class Foo(A, B):
141141
pass
142142
def method_with_default(self, arg='default'):
143143
pass";
144-
insta::assert_debug_snapshot!(parse_program(&source).unwrap());
144+
insta::assert_debug_snapshot!(parse_program(source).unwrap());
145145
}
146146

147147
#[test]

vm/src/builtins/str.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,23 +1592,19 @@ mod tests {
15921592
Interpreter::without_stdlib(Default::default()).enter(|vm| {
15931593
let table = vm.ctx.new_dict();
15941594
table
1595-
.set_item("a", vm.ctx.new_str("🎅").into(), &vm)
1595+
.set_item("a", vm.ctx.new_str("🎅").into(), vm)
15961596
.unwrap();
1597-
table.set_item("b", vm.ctx.none(), &vm).unwrap();
1597+
table.set_item("b", vm.ctx.none(), vm).unwrap();
15981598
table
1599-
.set_item("c", vm.ctx.new_str(ascii!("xda")).into(), &vm)
1599+
.set_item("c", vm.ctx.new_str(ascii!("xda")).into(), vm)
16001600
.unwrap();
1601-
let translated = PyStr::maketrans(
1602-
table.into(),
1603-
OptionalArg::Missing,
1604-
OptionalArg::Missing,
1605-
&vm,
1606-
)
1607-
.unwrap();
1601+
let translated =
1602+
PyStr::maketrans(table.into(), OptionalArg::Missing, OptionalArg::Missing, vm)
1603+
.unwrap();
16081604
let text = PyStr::from("abc");
1609-
let translated = text.translate(translated, &vm).unwrap();
1605+
let translated = text.translate(translated, vm).unwrap();
16101606
assert_eq!(translated, "🎅xda".to_owned());
1611-
let translated = text.translate(vm.ctx.new_int(3).into(), &vm);
1607+
let translated = text.translate(vm.ctx.new_int(3).into(), vm);
16121608
assert_eq!(
16131609
translated.unwrap_err().class().name().deref(),
16141610
"TypeError".to_owned()

vm/src/builtins/type.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ mod tests {
990990
vec![object.clone()],
991991
PyAttributes::default(),
992992
Default::default(),
993-
type_type.clone(),
993+
type_type,
994994
)
995995
.unwrap();
996996

@@ -1006,7 +1006,7 @@ mod tests {
10061006
vec![a.clone(), object.clone()],
10071007
vec![b.clone(), object.clone()],
10081008
])),
1009-
map_ids(Ok(vec![a.clone(), b.clone(), object.clone()]))
1009+
map_ids(Ok(vec![a, b, object]))
10101010
);
10111011
}
10121012
}

vm/src/dictdatatype.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -922,27 +922,27 @@ mod tests {
922922

923923
let key1 = vm.new_pyobj(true);
924924
let value1 = vm.new_pyobj(ascii!("abc"));
925-
dict.insert(&vm, &*key1, value1.clone()).unwrap();
925+
dict.insert(vm, &*key1, value1).unwrap();
926926
assert_eq!(1, dict.len());
927927

928928
let key2 = vm.new_pyobj(ascii!("x"));
929929
let value2 = vm.new_pyobj(ascii!("def"));
930-
dict.insert(&vm, &*key2, value2.clone()).unwrap();
930+
dict.insert(vm, &*key2, value2.clone()).unwrap();
931931
assert_eq!(2, dict.len());
932932

933-
dict.insert(&vm, &*key1, value2.clone()).unwrap();
933+
dict.insert(vm, &*key1, value2.clone()).unwrap();
934934
assert_eq!(2, dict.len());
935935

936-
dict.delete(&vm, &*key1).unwrap();
936+
dict.delete(vm, &*key1).unwrap();
937937
assert_eq!(1, dict.len());
938938

939-
dict.insert(&vm, &*key1, value2.clone()).unwrap();
939+
dict.insert(vm, &*key1, value2.clone()).unwrap();
940940
assert_eq!(2, dict.len());
941941

942-
assert_eq!(true, dict.contains(&vm, &*key1).unwrap());
943-
assert_eq!(true, dict.contains(&vm, "x").unwrap());
942+
assert_eq!(true, dict.contains(vm, &*key1).unwrap());
943+
assert_eq!(true, dict.contains(vm, "x").unwrap());
944944

945-
let val = dict.get(&vm, "x").unwrap().unwrap();
945+
let val = dict.get(vm, "x").unwrap().unwrap();
946946
vm.bool_eq(&val, &value2)
947947
.expect("retrieved value must be equal to inserted value.");
948948
})
@@ -969,8 +969,8 @@ mod tests {
969969
let value1 = text;
970970
let value2 = vm.new_pyobj(value1.to_owned());
971971

972-
let hash1 = value1.key_hash(&vm).expect("Hash should not fail.");
973-
let hash2 = value2.key_hash(&vm).expect("Hash should not fail.");
972+
let hash1 = value1.key_hash(vm).expect("Hash should not fail.");
973+
let hash2 = value2.key_hash(vm).expect("Hash should not fail.");
974974
assert_eq!(hash1, hash2);
975975
})
976976
}

vm/src/eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ mod tests {
2323
Interpreter::without_stdlib(Default::default()).enter(|vm| {
2424
let source = String::from("print('Hello world')");
2525
let vars = vm.new_scope_with_builtins();
26-
let result = eval(&vm, &source, vars, "<unittest>").expect("this should pass");
26+
let result = eval(vm, &source, vars, "<unittest>").expect("this should pass");
2727
assert!(vm.is_none(&result));
2828
})
2929
}

vm/src/vm/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,8 +760,8 @@ fn test_nested_frozen() {
760760
.map_err(|err| vm.new_syntax_error(&err))
761761
.unwrap();
762762

763-
if let Err(e) = vm.run_code_obj(code_obj, scope.clone()) {
764-
vm.print_exception(e.clone());
763+
if let Err(e) = vm.run_code_obj(code_obj, scope) {
764+
vm.print_exception(e);
765765
assert!(false);
766766
}
767767
})

0 commit comments

Comments
 (0)