Skip to content

Commit 89d6818

Browse files
committed
Fix clippy warnings and cargo fmt
1 parent 1cb8325 commit 89d6818

1 file changed

Lines changed: 24 additions & 21 deletions

File tree

‎crates/codegen/src/compile.rs‎

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -565,25 +565,28 @@ impl Compiler {
565565
};
566566

567567
// Fold all-constant collections (>= 3 elements) regardless of size
568-
if !seen_star && pushed == 0 && n >= 3 && elts.iter().all(|e| e.is_constant()) {
569-
if let Some(folded) = self.try_fold_constant_collection(elts)? {
570-
match collection_type {
571-
CollectionType::Tuple => {
572-
self.emit_load_const(folded);
573-
}
574-
CollectionType::List => {
575-
emit!(self, Instruction::BuildList { count: 0 });
576-
self.emit_load_const(folded);
577-
emit!(self, Instruction::ListExtend { i: 1 });
578-
}
579-
CollectionType::Set => {
580-
emit!(self, Instruction::BuildSet { count: 0 });
581-
self.emit_load_const(folded);
582-
emit!(self, Instruction::SetUpdate { i: 1 });
583-
}
568+
if !seen_star
569+
&& pushed == 0
570+
&& n >= 3
571+
&& elts.iter().all(|e| e.is_constant())
572+
&& let Some(folded) = self.try_fold_constant_collection(elts)?
573+
{
574+
match collection_type {
575+
CollectionType::Tuple => {
576+
self.emit_load_const(folded);
577+
}
578+
CollectionType::List => {
579+
emit!(self, Instruction::BuildList { count: 0 });
580+
self.emit_load_const(folded);
581+
emit!(self, Instruction::ListExtend { i: 1 });
582+
}
583+
CollectionType::Set => {
584+
emit!(self, Instruction::BuildSet { count: 0 });
585+
self.emit_load_const(folded);
586+
emit!(self, Instruction::SetUpdate { i: 1 });
584587
}
585-
return Ok(());
586588
}
589+
return Ok(());
587590
}
588591

589592
// If no stars and not too big, compile all elements and build once
@@ -4582,10 +4585,10 @@ impl Compiler {
45824585
fn scan_target_for_attrs(target: &ast::Expr, name: &str, attrs: &mut IndexSet<String>) {
45834586
match target {
45844587
ast::Expr::Attribute(ast::ExprAttribute { value, attr, .. }) => {
4585-
if let ast::Expr::Name(n) = value.as_ref() {
4586-
if n.id.as_str() == name {
4587-
attrs.insert(attr.to_string());
4588-
}
4588+
if let ast::Expr::Name(n) = value.as_ref()
4589+
&& n.id.as_str() == name
4590+
{
4591+
attrs.insert(attr.to_string());
45894592
}
45904593
}
45914594
ast::Expr::Tuple(t) => {

0 commit comments

Comments
 (0)