Skip to content

Commit bc875d6

Browse files
committed
fix new clippy warnings
1 parent cda2d21 commit bc875d6

File tree

15 files changed

+114
-120
lines changed

15 files changed

+114
-120
lines changed

clippy.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[[disallowed-methods]]
2-
path = "dash_vm::Vm::register"
3-
reason = "use LocalScope::register instead"

crates/dash_compiler/src/lib.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -644,12 +644,11 @@ impl Visitor<Result<(), Error>> for FunctionCompiler<'_> {
644644
// Typeof operator evaluates its operand differently if it's an identifier and there is no such local variable, so special case it here
645645
// `typeof x` does not throw an error if the variable does not exist,
646646
// `typeof x.a` does throw an error
647-
if let TokenType::Typeof = operator {
648-
if let ExprKind::Literal(LiteralExpr::Identifier(ident)) = expr.kind {
649-
if ib.find_local(ident).is_none() {
650-
return ib.build_typeof_global_ident(span, ident);
651-
}
652-
}
647+
if let TokenType::Typeof = operator
648+
&& let ExprKind::Literal(LiteralExpr::Identifier(ident)) = expr.kind
649+
&& ib.find_local(ident).is_none()
650+
{
651+
return ib.build_typeof_global_ident(span, ident);
653652
}
654653

655654
// Delete operator works different from other unary operators
@@ -1586,12 +1585,12 @@ impl Visitor<Result<(), Error>> for FunctionCompiler<'_> {
15861585

15871586
// Insert initializers
15881587
// FIXME: they need to be inserted after every super() call not at the start of the constructor.
1589-
if let Some(members) = constructor_initializers {
1590-
if !members.is_empty() {
1591-
let members = compile_class_members(ib, span, members)?;
1592-
ib.build_this();
1593-
ib.build_object_member_like_instruction(span, members, Instruction::AssignProperties)?;
1594-
}
1588+
if let Some(members) = constructor_initializers
1589+
&& !members.is_empty()
1590+
{
1591+
let members = compile_class_members(ib, span, members)?;
1592+
ib.build_this();
1593+
ib.build_object_member_like_instruction(span, members, Instruction::AssignProperties)?;
15951594
}
15961595

15971596
let res = statements.into_iter().try_for_each(|stmt| ib.accept(stmt));
@@ -2468,7 +2467,6 @@ fn compile_destructuring_pattern(
24682467
.try_into()
24692468
.map_err(|_| Error::DestructureLimitExceeded(at))?;
24702469

2471-
#[expect(clippy::manual_flatten, reason = "pattern contains an inner Some()")]
24722470
for field in fields.iter().rev() {
24732471
if let Some((_, Some(default))) = field {
24742472
ib.accept_expr(default.clone())?;

crates/dash_lexer/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -358,14 +358,14 @@ impl<'a, 'interner> Lexer<'a, 'interner> {
358358
continue;
359359
}
360360

361-
if cur == b'$' {
362-
if let Some(b'{') = self.peek() {
363-
// String interpolation
364-
found_end = true;
365-
is_interpolated = true;
366-
self.template_literal_depths_stack.push(0);
367-
break;
368-
}
361+
if cur == b'$'
362+
&& let Some(b'{') = self.peek()
363+
{
364+
// String interpolation
365+
found_end = true;
366+
is_interpolated = true;
367+
self.template_literal_depths_stack.push(0);
368+
break;
369369
}
370370

371371
if cur == b'\n' {

crates/dash_middle/src/lexer/token.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ impl TokenType {
486486
TokenType::DUMMY_IDENTIFIER => write!(f, "<identifier>"),
487487
TokenType::DUMMY_TEMPLATE_LITERAL => write!(f, "<template literal>"),
488488
TokenType::DUMMY_STRING => write!(f, "<string>"),
489-
other => write!(f, "{}", other),
489+
other => write!(f, "{other}"),
490490
}
491491
}
492492
}

crates/dash_node_impl/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub fn run_with_nodejs_mnemnoics(path: &str, opt: OptLevel, initial_gc_threshold
4343

4444
tokio_rt.block_on(async move {
4545
if let Err(err) = run_inner_fallible(path, opt, initial_gc_threshold).await {
46-
eprintln!("{}", err);
46+
eprintln!("{err}");
4747
}
4848
});
4949

crates/dash_optimizer/src/consteval.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -538,10 +538,10 @@ fn expr_has_side_effects(expr: &Expr) -> bool {
538538
ExprKind::Literal(LiteralExpr::Regex(..)) => false,
539539
ExprKind::Literal(LiteralExpr::String(..)) => false,
540540
ExprKind::Object(ObjectLiteral(object)) => object.iter().any(|(kind, expr)| {
541-
if let ObjectMemberKind::Dynamic(dynamic) = kind {
542-
if expr_has_side_effects(dynamic) {
543-
return true;
544-
}
541+
if let ObjectMemberKind::Dynamic(dynamic) = kind
542+
&& expr_has_side_effects(dynamic)
543+
{
544+
return true;
545545
};
546546
expr_has_side_effects(expr)
547547
}),

crates/dash_optimizer/src/type_infer.rs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -528,37 +528,37 @@ impl<'s> TypeInferCtx<'s> {
528528
let right_type = self.visit(right);
529529

530530
// Also propagate assignment to target
531-
if let ExprKind::Literal(LiteralExpr::Identifier(ident)) = &left.kind {
532-
if let Some(local) = self.find_local(*ident) {
533-
let left_type = local.inferred_type();
534-
let left_type_ref = left_type.borrow();
535-
536-
if left_type_ref.as_ref() == right_type.as_ref() {
537-
// Assign value is the same, no change.
538-
} else {
539-
debug!(
540-
"variable {} changed type {:?} -> {:?}",
541-
ident, left_type_ref, right_type
542-
);
543-
544-
match (left_type_ref.as_ref(), right_type.as_ref()) {
545-
(Some(left), Some(right)) => {
546-
let left = left.clone();
547-
let right = right.clone();
548-
drop(left_type_ref);
549-
update_ty(
550-
left_type,
551-
Some(CompileValueType::Either(Box::new(left), Box::new(right))),
552-
);
553-
}
554-
(_, Some(right)) => {
555-
drop(left_type_ref);
556-
update_ty(left_type, Some(CompileValueType::Maybe(Box::new(right.clone()))));
557-
}
558-
(_, _) => {
559-
drop(left_type_ref);
560-
update_ty(left_type, None);
561-
}
531+
if let ExprKind::Literal(LiteralExpr::Identifier(ident)) = &left.kind
532+
&& let Some(local) = self.find_local(*ident)
533+
{
534+
let left_type = local.inferred_type();
535+
let left_type_ref = left_type.borrow();
536+
537+
if left_type_ref.as_ref() == right_type.as_ref() {
538+
// Assign value is the same, no change.
539+
} else {
540+
debug!(
541+
"variable {} changed type {:?} -> {:?}",
542+
ident, left_type_ref, right_type
543+
);
544+
545+
match (left_type_ref.as_ref(), right_type.as_ref()) {
546+
(Some(left), Some(right)) => {
547+
let left = left.clone();
548+
let right = right.clone();
549+
drop(left_type_ref);
550+
update_ty(
551+
left_type,
552+
Some(CompileValueType::Either(Box::new(left), Box::new(right))),
553+
);
554+
}
555+
(_, Some(right)) => {
556+
drop(left_type_ref);
557+
update_ty(left_type, Some(CompileValueType::Maybe(Box::new(right.clone()))));
558+
}
559+
(_, _) => {
560+
drop(left_type_ref);
561+
update_ty(left_type, None);
562562
}
563563
}
564564
}

crates/dash_parser/src/stmt.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ impl Parser<'_, '_> {
4545
TokenType::Debugger => Some(StatementKind::Debugger),
4646
TokenType::Semicolon => Some(StatementKind::Empty),
4747
other => 'other: {
48-
if let TokenType::Identifier(label) = other {
49-
if self.eat(TokenType::Colon, false).is_some() {
50-
// `foo: <statement that can be broken out of>`
51-
let stmt = self.parse_statement()?;
52-
break 'other Some(StatementKind::Labelled(label, Box::new(stmt)));
53-
}
48+
if let TokenType::Identifier(label) = other
49+
&& self.eat(TokenType::Colon, false).is_some()
50+
{
51+
// `foo: <statement that can be broken out of>`
52+
let stmt = self.parse_statement()?;
53+
break 'other Some(StatementKind::Labelled(label, Box::new(stmt)));
5454
}
5555

5656
// We've skipped the current character because of the statement cases that skip the current token

crates/dash_proc_macro/src/define_symbols.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn define_symbols_impl(tt: TokenStream) -> TokenStream {
2222
let kind = match strukt.path.segments.last().unwrap().ident.to_string().as_ref() {
2323
"Keywords" => Kind::Keyword,
2424
"Symbols" => Kind::Symbol,
25-
other => panic!("unknown struct: {}", other),
25+
other => panic!("unknown struct: {other}"),
2626
};
2727

2828
for field in strukt.fields {
@@ -50,10 +50,10 @@ pub fn define_symbols_impl(tt: TokenStream) -> TokenStream {
5050
let mut js_idents = HashSet::new();
5151
for (_, rust_sym, js_sym) in &symbols {
5252
if !rust_idents.insert(rust_sym) {
53-
panic!("duplicate rust ident: {}", rust_sym);
53+
panic!("duplicate rust ident: {rust_sym}");
5454
}
5555
if !js_idents.insert(js_sym) {
56-
panic!("duplicate js ident: {}", js_sym);
56+
panic!("duplicate js ident: {js_sym}");
5757
}
5858
}
5959

crates/dash_regex/src/graph/eval.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ fn step(shared: &mut Shared<'_>, cx: Cx<'_>, node_id: NodeId, mut remaining: &[u
9292
NodeKind::RepetitionStart { min, max, inner } => 'arm: {
9393
let current_repetition_count = cx.current_repetition_count.get().unwrap();
9494

95-
if let Some(max) = max {
96-
if current_repetition_count >= max {
97-
// We've done `max` number of iterations.
98-
break 'arm true;
99-
}
95+
if let Some(max) = max
96+
&& current_repetition_count >= max
97+
{
98+
// We've done `max` number of iterations.
99+
break 'arm true;
100100
}
101101

102102
if step(shared, cx.for_node(shared, inner, node_id, remaining), inner, remaining) {

0 commit comments

Comments
 (0)