Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix clippy warnings and cargo fmt
  • Loading branch information
youknowone committed Mar 25, 2026
commit a23315a04c379c56aa05e4aef477663ef09016ac
45 changes: 24 additions & 21 deletions crates/codegen/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,25 +565,28 @@ impl Compiler {
};

// Fold all-constant collections (>= 3 elements) regardless of size
if !seen_star && pushed == 0 && n >= 3 && elts.iter().all(|e| e.is_constant()) {
if let Some(folded) = self.try_fold_constant_collection(elts)? {
match collection_type {
CollectionType::Tuple => {
self.emit_load_const(folded);
}
CollectionType::List => {
emit!(self, Instruction::BuildList { count: 0 });
self.emit_load_const(folded);
emit!(self, Instruction::ListExtend { i: 1 });
}
CollectionType::Set => {
emit!(self, Instruction::BuildSet { count: 0 });
self.emit_load_const(folded);
emit!(self, Instruction::SetUpdate { i: 1 });
}
if !seen_star
&& pushed == 0
&& n >= 3
&& elts.iter().all(|e| e.is_constant())
&& let Some(folded) = self.try_fold_constant_collection(elts)?
{
match collection_type {
CollectionType::Tuple => {
self.emit_load_const(folded);
}
CollectionType::List => {
emit!(self, Instruction::BuildList { count: 0 });
self.emit_load_const(folded);
emit!(self, Instruction::ListExtend { i: 1 });
}
CollectionType::Set => {
emit!(self, Instruction::BuildSet { count: 0 });
self.emit_load_const(folded);
emit!(self, Instruction::SetUpdate { i: 1 });
}
return Ok(());
}
return Ok(());
}

// If no stars and not too big, compile all elements and build once
Expand Down Expand Up @@ -4582,10 +4585,10 @@ impl Compiler {
fn scan_target_for_attrs(target: &ast::Expr, name: &str, attrs: &mut IndexSet<String>) {
match target {
ast::Expr::Attribute(ast::ExprAttribute { value, attr, .. }) => {
if let ast::Expr::Name(n) = value.as_ref() {
if n.id.as_str() == name {
attrs.insert(attr.to_string());
}
if let ast::Expr::Name(n) = value.as_ref()
&& n.id.as_str() == name
{
attrs.insert(attr.to_string());
}
}
ast::Expr::Tuple(t) => {
Expand Down