Skip to content

Commit 99ce36a

Browse files
BoshenCopilot
authored andcommitted
fix(rust): fix clippy issues (#13540)
1 parent d376a11 commit 99ce36a

File tree

25 files changed

+108
-99
lines changed

25 files changed

+108
-99
lines changed

.claude/settings.local.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(find:*)",
5+
"Bash(cargo check:*)",
6+
"Bash(cargo clippy:*)"
7+
],
8+
"deny": [],
9+
"ask": []
10+
}
11+
}

Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,10 @@ unused_peekable = "warn"
9696
too_long_first_doc_paragraph = "warn"
9797
suspicious_operation_groupings = "warn"
9898
redundant_clone = "warn"
99-
zero_sized_map_values = "allow" # FIXME https://github.com/rust-lang/rust-clippy/issues/15429
99+
zero_sized_map_values = "allow" # FIXME https://github.com/rust-lang/rust-clippy/issues/15429 - False positive with serde skip_serializing
100100
# cargo
101101
cargo = { level = "warn", priority = -1 }
102102
multiple_crate_versions = "allow"
103-
cargo_common_metadata = "allow" # FIXME
104-
doc_lazy_continuation = "allow" # FIXME
105-
ignore_without_reason = "allow" # FIXME
106103

107104
[workspace.dependencies]
108105
# publish = true

crates/oxc_codegen/tests/integration/esbuild.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ fn test_function() {
522522
}
523523

524524
#[test]
525-
#[ignore]
525+
#[ignore = "TODO: Comments and parentheses handling not yet implemented"]
526526
fn test_comments_and_parentheses() {
527527
test("(/* foo */ { x() { foo() } }.x());", "/* foo */\n({ x() {\n foo();\n} }).x();\n");
528528
test(
@@ -829,7 +829,7 @@ fn test_whitespace() {
829829
}
830830

831831
#[test]
832-
#[ignore]
832+
#[ignore = "TODO: Minification functionality not yet implemented"]
833833
fn minify() {
834834
test_minify("0.1", ".1;");
835835
test_minify("1.2", "1.2;");

crates/oxc_data_structures/src/code_buffer.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,9 @@ impl CodeBuffer {
490490
/// but only advance `len` by the actual number of bytes. This avoids a `memset` function call.
491491
///
492492
/// Take alternative slow path if either:
493-
/// 1. Total characters to print > 32.
494-
/// 2. Less than 32 bytes spare capacity in buffer (needs to grow).
493+
/// 1. Total characters to print > 32.
494+
/// 2. Less than 32 bytes spare capacity in buffer (needs to grow).
495+
///
495496
/// Both of these cases should be rare.
496497
///
497498
/// We write 32 bytes because both tabs and spaces are supported.

crates/oxc_linter/src/loader/partial_loader/svelte.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl<'a> SveltePartialLoader<'a> {
2222
/// Each *.svelte file can contain at most
2323
/// * one `<script>` block
2424
/// * one `<script context="module">` or `<script module>` block
25-
/// <https://github.com/sveltejs/svelte.dev/blob/ba7ad256f786aa5bc67eac3a58608f3f50b59e91/apps/svelte.dev/content/tutorial/02-advanced-svelte/08-script-module/02-module-exports/index.md>
25+
/// <https://github.com/sveltejs/svelte.dev/blob/ba7ad256f786aa5bc67eac3a58608f3f50b59e91/apps/svelte.dev/content/tutorial/02-advanced-svelte/08-script-module/02-module-exports/index.md>
2626
fn parse_scripts(&self) -> Vec<JavaScriptSource<'a>> {
2727
let mut pointer = 0;
2828
let Some(result1) = self.parse_script(&mut pointer) else {

crates/oxc_linter/src/loader/partial_loader/vue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl<'a> VuePartialLoader<'a> {
2222
/// Each *.vue file can contain at most
2323
/// * one `<script>` block (excluding `<script setup>`).
2424
/// * one `<script setup>` block (excluding normal `<script>`).
25-
/// <https://vuejs.org/api/sfc-spec.html#script>
25+
/// <https://vuejs.org/api/sfc-spec.html#script>
2626
fn parse_scripts(&self) -> Vec<JavaScriptSource<'a>> {
2727
let mut pointer = 0;
2828
let Some(result1) = self.parse_script(&mut pointer) else {

crates/oxc_linter/src/rules/eslint/no_unused_vars/usage.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,11 @@ impl<'a> Symbol<'_, 'a> {
371371
/// for code like `let a = 0; a`, but bans code like `let a = 0; a++`;
372372
///
373373
/// - We encounter a node proving that the reference is absolutely used by
374-
/// another variable, we return `false` immediately.
374+
/// another variable, we return `false` immediately.
375375
/// - When we encounter an AST node that updates the value of the symbol this
376-
/// reference is for, such as an [`AssignmentExpression`] with the symbol on
377-
/// the LHS or a mutating [`UnaryExpression`], we mark the reference as not
378-
/// being used by others.
376+
/// reference is for, such as an [`AssignmentExpression`] with the symbol on
377+
/// the LHS or a mutating [`UnaryExpression`], we mark the reference as not
378+
/// being used by others.
379379
/// - When we encounter a node where we are sure the value produced by an
380380
/// expression will no longer be used, such as an [`ExpressionStatement`],
381381
/// we end our search. This is because expression statements produce a

crates/oxc_minifier/src/peephole/minimize_conditions.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ mod test {
414414

415415
/** Try to minimize assignments */
416416
#[test]
417-
#[ignore]
417+
#[ignore = "TODO: Assignment folding optimization not yet implemented"]
418418
fn test_fold_assignments() {
419419
test("function f(){if(x)y=3;else y=4;}", "function f(){y=x?3:4}");
420420
test("function f(){if(x)y=1+a;else y=2+a;}", "function f(){y=x?1+a:2+a}");
@@ -436,7 +436,7 @@ mod test {
436436
}
437437

438438
#[test]
439-
#[ignore]
439+
#[ignore = "TODO: Duplicate statement removal not yet implemented"]
440440
fn test_remove_duplicate_statements() {
441441
test("if (a) { x = 1; x++ } else { x = 2; x++ }", "x=(a) ? 1 : 2; x++");
442442
test(
@@ -505,7 +505,7 @@ mod test {
505505
}
506506

507507
#[test]
508-
#[ignore]
508+
#[ignore = "TODO: Parentheses counting optimization not yet implemented"]
509509
fn test_and_parentheses_count() {
510510
test("function f(){if(x||y)a.foo()}", "function f(){(x||y)&&a.foo()}");
511511
test("function f(){if(x.a)x.a=0}", "function f(){x.a&&(x.a=0)}");
@@ -567,47 +567,47 @@ mod test {
567567
}
568568

569569
#[test]
570-
#[ignore]
570+
#[ignore = "TODO: De Morgan's law optimization not yet implemented"]
571571
fn test_minimize_demorgan_remove_leading_not() {
572572
test("if(!(!a||!b)&&c) foo()", "((a&&b)&&c)&&foo()");
573573
test("if(!(x&&y)) foo()", "x&&y||foo()");
574574
test("if(!(x||y)) foo()", "(x||y)||foo()");
575575
}
576576

577577
#[test]
578-
#[ignore]
578+
#[ignore = "TODO: De Morgan's law optimization not yet implemented"]
579579
fn test_minimize_demorgan1() {
580580
test("if(!a&&!b)foo()", "(a||b)||foo()");
581581
}
582582

583583
#[test]
584-
#[ignore]
584+
#[ignore = "TODO: De Morgan's law optimization not yet implemented"]
585585
fn test_minimize_demorgan2() {
586586
// Make sure trees with cloned functions are marked as changed
587587
test("(!(a&&!((function(){})())))||foo()", "!a||(function(){})()||foo()");
588588
}
589589

590590
#[test]
591-
#[ignore]
591+
#[ignore = "TODO: De Morgan's law optimization not yet implemented"]
592592
fn test_minimize_demorgan2b() {
593593
// Make sure unchanged trees with functions are not marked as changed
594594
test_same("!a||(function(){})()||foo()");
595595
}
596596

597597
#[test]
598-
#[ignore]
598+
#[ignore = "TODO: De Morgan's law optimization not yet implemented"]
599599
fn test_minimize_demorgan3() {
600600
test("if((!a||!b)&&(c||d)) foo()", "(a&&b||!c&&!d)||foo()");
601601
}
602602

603603
#[test]
604-
#[ignore]
604+
#[ignore = "TODO: De Morgan's law optimization not yet implemented"]
605605
fn test_minimize_demorgan5() {
606606
test("if((!a||!b)&&c) foo()", "(a&&b||!c)||foo()");
607607
}
608608

609609
#[test]
610-
#[ignore]
610+
#[ignore = "TODO: De Morgan's law optimization not yet implemented"]
611611
fn test_minimize_demorgan11() {
612612
test(
613613
"if (x && (y===2 || !f()) && (y===3 || !h())) foo()",
@@ -616,7 +616,7 @@ mod test {
616616
}
617617

618618
#[test]
619-
#[ignore]
619+
#[ignore = "TODO: De Morgan's law optimization not yet implemented"]
620620
fn test_minimize_demorgan20a() {
621621
test(
622622
"if (0===c && (2===a || 1===a)) f(); else g()",
@@ -625,7 +625,7 @@ mod test {
625625
}
626626

627627
#[test]
628-
#[ignore]
628+
#[ignore = "TODO: De Morgan's law optimization not yet implemented"]
629629
fn test_minimize_demorgan20b() {
630630
test("if (0!==c || 2!==a && 1!==a) g(); else f()", "(0!==c || 2!==a && 1!==a) ? g() : f()");
631631
}
@@ -676,7 +676,7 @@ mod test {
676676
}
677677

678678
#[test]
679-
#[ignore]
679+
#[ignore = "TODO: Expression result minimization not yet implemented"]
680680
fn test_minimize_expr_result() {
681681
test("!x||!y", "x&&y");
682682
test("if(!(x&&!y)) foo()", "(!x||y)&&foo()");
@@ -685,13 +685,13 @@ mod test {
685685
}
686686

687687
#[test]
688-
#[ignore]
688+
#[ignore = "TODO: De Morgan's law optimization not yet implemented"]
689689
fn test_minimize_demorgan21() {
690690
test("if (0===c && (2===a || 1===a)) f()", "(0!==c || 2!==a && 1!==a) || f()");
691691
}
692692

693693
#[test]
694-
#[ignore]
694+
#[ignore = "TODO: AND/OR minimization not yet implemented"]
695695
fn test_minimize_and_or1() {
696696
test("if ((!a || !b) && (d || e)) f()", "(a&&b || !d&&!e) || f()");
697697
}
@@ -741,7 +741,7 @@ mod test {
741741
}
742742

743743
#[test]
744-
#[ignore]
744+
#[ignore = "TODO: Conditional variable declaration folding not yet implemented"]
745745
fn test_fold_conditional_var_declaration() {
746746
test("if(x) var y=1;else y=2", "var y=x?1:2");
747747
test("if(x) y=1;else var y=2", "var y=x?1:2");
@@ -764,7 +764,7 @@ mod test {
764764
}
765765

766766
#[test]
767-
#[ignore]
767+
#[ignore = "TODO: Return statement substitution not yet implemented"]
768768
fn test_substitute_return() {
769769
test("function f() { while(x) { return }}", "function f() { while(x) { break }}");
770770

@@ -861,7 +861,7 @@ mod test {
861861
}
862862

863863
#[test]
864-
#[ignore]
864+
#[ignore = "TODO: Break/throw substitution not yet implemented"]
865865
fn test_substitute_break_for_throw() {
866866
test_same("function f() { while(x) { throw Error }}");
867867

crates/oxc_minifier/src/peephole/replace_known_methods.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -666,20 +666,20 @@ mod test {
666666
}
667667

668668
#[test]
669-
#[ignore]
669+
#[ignore = "TODO: Array.join optimization with sparse arrays not yet implemented"]
670670
fn test_string_join_add_sparse() {
671671
test("x = [,,'a'].join(',')", "x = ',,a'");
672672
}
673673

674674
#[test]
675-
#[ignore]
675+
#[ignore = "TODO: Array.join optimization edge cases not yet implemented"]
676676
fn test_no_string_join() {
677677
test_same("x = [].join(',',2)");
678678
test_same("x = [].join(f)");
679679
}
680680

681681
#[test]
682-
#[ignore]
682+
#[ignore = "TODO: Array.join to string concatenation optimization not yet implemented"]
683683
fn test_string_join_add() {
684684
test("x = ['a', 'b', 'c'].join('')", "x = \"abc\"");
685685
test("x = [].join(',')", "x = \"\"");
@@ -739,7 +739,7 @@ mod test {
739739
}
740740

741741
#[test]
742-
#[ignore]
742+
#[ignore = "TODO: Array.join single element optimization not yet implemented"]
743743
fn test_string_join_add_b1992789() {
744744
test("x = ['a'].join('')", "x = \"a\"");
745745
test_same("x = [foo()].join('')");
@@ -890,7 +890,7 @@ mod test {
890890
}
891891

892892
#[test]
893-
#[ignore]
893+
#[ignore = "TODO: String.split optimization not yet implemented"]
894894
fn test_fold_string_split() {
895895
// late = false;
896896
test("x = 'abcde'.split('foo')", "x = ['abcde']");
@@ -928,7 +928,7 @@ mod test {
928928
}
929929

930930
#[test]
931-
#[ignore]
931+
#[ignore = "TODO: Array.join edge case optimization not yet implemented"]
932932
fn test_join_bug() {
933933
test("var x = [].join();", "var x = '';");
934934
test_same("var x = [x].join();");
@@ -948,7 +948,7 @@ mod test {
948948
}
949949

950950
#[test]
951-
#[ignore]
951+
#[ignore = "TODO: Array.join with spread syntax optimization not yet implemented"]
952952
fn test_join_spread1() {
953953
test_same("var x = [...foo].join('');");
954954
test_same("var x = [...someMap.keys()].join('');");
@@ -960,7 +960,7 @@ mod test {
960960
}
961961

962962
#[test]
963-
#[ignore]
963+
#[ignore = "TODO: Array.join with spread syntax optimization not yet implemented"]
964964
fn test_join_spread2() {
965965
test("var x = [...foo].join(',');", "var x = [...foo].join();");
966966
test("var x = [...someMap.keys()].join(',');", "var x = [...someMap.keys()].join();");
@@ -1219,7 +1219,7 @@ mod test {
12191219
}
12201220

12211221
#[test]
1222-
#[ignore]
1222+
#[ignore = "TODO: Math.pow optimization not yet implemented"]
12231223
fn test_fold_math_functions_pow() {
12241224
test("Math.pow(1, 2)", "1");
12251225
test("Math.pow(2, 0)", "1");
@@ -1346,7 +1346,7 @@ mod test {
13461346
}
13471347

13481348
#[test]
1349-
#[ignore]
1349+
#[ignore = "TODO: String charAt replacement optimization not yet implemented"]
13501350
fn test_replace_with_char_at() {
13511351
// enableTypeCheck();
13521352
// replaceTypesWithColors();

crates/oxc_minifier/src/peephole/substitute_alternate_syntax.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1824,7 +1824,7 @@ mod test {
18241824
}
18251825

18261826
#[test]
1827-
#[ignore]
1827+
#[ignore = "TODO: Function.bind to Function.call optimization not yet implemented"]
18281828
fn test_bind_to_call() {
18291829
test("((function(){}).bind())()", "((function(){}))()");
18301830
test("((function(){}).bind(a))()", "((function(){})).call(a)");

0 commit comments

Comments
 (0)