@@ -289,7 +289,7 @@ pub fn compile_program(
289289) -> CompileResult<CodeObject> {
290290 let symbol_table = SymbolTable::scan_program(ast, source_file.clone())
291291 .map_err(|e| e.into_codegen_error(source_file.name().to_owned()))?;
292- let mut compiler = Compiler::new(opts, source_file, "<module>".to_owned() );
292+ let mut compiler = Compiler::new(opts, source_file, "<module>");
293293 compiler.compile_program(ast, symbol_table)?;
294294 let code = compiler.exit_scope();
295295 trace!("Compilation completed: {code:?}");
@@ -304,7 +304,7 @@ pub fn compile_program_single(
304304) -> CompileResult<CodeObject> {
305305 let symbol_table = SymbolTable::scan_program(ast, source_file.clone())
306306 .map_err(|e| e.into_codegen_error(source_file.name().to_owned()))?;
307- let mut compiler = Compiler::new(opts, source_file, "<module>".to_owned() );
307+ let mut compiler = Compiler::new(opts, source_file, "<module>");
308308 compiler.compile_program_single(&ast.body, symbol_table)?;
309309 let code = compiler.exit_scope();
310310 trace!("Compilation completed: {code:?}");
@@ -318,7 +318,7 @@ pub fn compile_block_expression(
318318) -> CompileResult<CodeObject> {
319319 let symbol_table = SymbolTable::scan_program(ast, source_file.clone())
320320 .map_err(|e| e.into_codegen_error(source_file.name().to_owned()))?;
321- let mut compiler = Compiler::new(opts, source_file, "<module>".to_owned() );
321+ let mut compiler = Compiler::new(opts, source_file, "<module>");
322322 compiler.compile_block_expr(&ast.body, symbol_table)?;
323323 let code = compiler.exit_scope();
324324 trace!("Compilation completed: {code:?}");
@@ -332,7 +332,7 @@ pub fn compile_expression(
332332) -> CompileResult<CodeObject> {
333333 let symbol_table = SymbolTable::scan_expr(ast, source_file.clone())
334334 .map_err(|e| e.into_codegen_error(source_file.name().to_owned()))?;
335- let mut compiler = Compiler::new(opts, source_file, "<module>".to_owned() );
335+ let mut compiler = Compiler::new(opts, source_file, "<module>");
336336 compiler.compile_eval(ast, symbol_table)?;
337337 let code = compiler.exit_scope();
338338 Ok(code)
@@ -447,13 +447,14 @@ impl PatternContext {
447447 }
448448}
449449
450+ #[derive(Clone, Copy, Eq, PartialEq)]
450451enum JumpOp {
451452 Jump,
452453 PopJumpIfFalse,
453454}
454455
455456/// Type of collection to build in starunpack_helper
456- #[derive(Debug, Clone, Copy, PartialEq)]
457+ #[derive(Clone, Copy, Debug, Eq , PartialEq)]
457458enum CollectionType {
458459 Tuple,
459460 List,
@@ -541,7 +542,7 @@ impl Compiler {
541542 }
542543 }
543544
544- fn new(opts: CompileOpts, source_file: SourceFile, code_name: String ) -> Self {
545+ fn new(opts: CompileOpts, source_file: SourceFile, code_name: &str ) -> Self {
545546 let module_code = ir::CodeInfo {
546547 // CPython convention: top-level module / interactive /
547548 // expression code does not carry CO_NEWLOCALS or CO_OPTIMIZED.
@@ -558,8 +559,8 @@ impl Compiler {
558559 current_block: BlockIdx::new(0),
559560 annotations_blocks: None,
560561 metadata: ir::CodeUnitMetadata {
561- name: code_name.clone (),
562- qualname: Some(code_name),
562+ name: code_name.to_string (),
563+ qualname: Some(code_name.to_string() ),
563564 consts: IndexSet::default(),
564565 names: IndexSet::default(),
565566 varnames: IndexSet::default(),
@@ -1828,7 +1829,7 @@ impl Compiler {
18281829 posonlyarg_count: u32,
18291830 arg_count: u32,
18301831 kwonlyarg_count: u32,
1831- obj_name: String ,
1832+ obj_name: &str ,
18321833 ) -> CompileResult<()> {
18331834 // First push the symbol table
18341835 let table = self.push_symbol_table()?;
@@ -1841,7 +1842,7 @@ impl Compiler {
18411842 let lineno = self.get_source_line_number().get();
18421843
18431844 // Call enter_scope which does most of the work
1844- self.enter_scope(& obj_name, scope_type, key, lineno.to_u32())?;
1845+ self.enter_scope(obj_name, scope_type, key, lineno.to_u32())?;
18451846
18461847 // Override the values that push_output sets explicitly
18471848 // enter_scope sets default values based on scope_type, but push_output
@@ -3399,7 +3400,7 @@ impl Compiler {
33993400 parameters.posonlyargs.len().to_u32(),
34003401 (parameters.posonlyargs.len() + parameters.args.len()).to_u32(),
34013402 parameters.kwonlyargs.len().to_u32(),
3402- name.to_owned() ,
3403+ name,
34033404 )?;
34043405
34053406 let args_iter = core::iter::empty()
@@ -5257,7 +5258,7 @@ impl Compiler {
52575258 0,
52585259 num_typeparam_args as u32,
52595260 0,
5260- type_params_name,
5261+ & type_params_name,
52615262 )?;
52625263
52635264 // TypeParams scope is function-like
@@ -5819,7 +5820,7 @@ impl Compiler {
58195820 0,
58205821 0,
58215822 0,
5822- type_params_name,
5823+ & type_params_name,
58235824 )?;
58245825
58255826 // Set private name for name mangling
@@ -9712,14 +9713,14 @@ impl Compiler {
97129713 posonlyarg_count: u32,
97139714 arg_count: u32,
97149715 kwonlyarg_count: u32,
9715- obj_name: String ,
9716+ obj_name: &str ,
97169717 ) -> CompileResult<()> {
97179718 let scope_type = table.typ;
97189719 self.symbol_table_stack.push(table);
97199720
97209721 let key = self.symbol_table_stack.len() - 1;
97219722 let lineno = self.get_source_line_number().get();
9722- self.enter_scope(& obj_name, scope_type, key, lineno.to_u32())?;
9723+ self.enter_scope(obj_name, scope_type, key, lineno.to_u32())?;
97239724
97249725 if let Some(info) = self.code_stack.last_mut() {
97259726 info.flags = flags | (info.flags & bytecode::CodeFlags::NESTED);
@@ -9783,7 +9784,7 @@ impl Compiler {
97839784 // and relies on the inlined path itself to handle GET_AITER /
97849785 // async-comprehension cleanup.
97859786 return self.compile_inlined_comprehension(
9786- comp_table,
9787+ & comp_table,
97879788 init_collection,
97889789 generators,
97899790 compile_element,
@@ -9818,7 +9819,7 @@ impl Compiler {
98189819 // scope itself. Peek past those nested scopes so we can enter the
98199820 // correct comprehension table here, then let the real outermost
98209821 // iterator compile consume its nested scopes later in parent scope.
9821- self.push_output_with_symbol_table(comp_table, flags, 1, 1, 0, name.to_owned() )?;
9822+ self.push_output_with_symbol_table(comp_table, flags, 1, 1, 0, name)?;
98229823
98239824 // Set qualname for comprehension
98249825 self.set_qualname();
@@ -10025,7 +10026,7 @@ impl Compiler {
1002510026 /// This generates bytecode inline without creating a new code object
1002610027 fn compile_inlined_comprehension(
1002710028 &mut self,
10028- comp_table: SymbolTable,
10029+ comp_table: & SymbolTable,
1002910030 init_collection: Option<AnyInstruction>,
1003010031 generators: &[ast::Comprehension],
1003110032 compile_element: &dyn Fn(&mut Self, usize) -> CompileResult<()>,
@@ -12377,7 +12378,7 @@ mod tests {
1237712378 let symbol_table = SymbolTable::scan_program(&ast, source_file.clone())
1237812379 .map_err(|e| e.into_codegen_error(source_file.name().to_owned()))
1237912380 .unwrap();
12380- let mut compiler = Compiler::new(opts, source_file, "<module>".to_owned() );
12381+ let mut compiler = Compiler::new(opts, source_file, "<module>");
1238112382 compiler.compile_program(&ast, symbol_table).unwrap();
1238212383 compiler.exit_scope()
1238312384 }
@@ -12415,7 +12416,7 @@ mod tests {
1241512416 let symbol_table = SymbolTable::scan_program(&ast, source_file.clone())
1241612417 .map_err(|e| e.into_codegen_error(source_file.name().to_owned()))
1241712418 .unwrap();
12418- let mut compiler = Compiler::new(opts, source_file, "<module>".to_owned() );
12419+ let mut compiler = Compiler::new(opts, source_file, "<module>");
1241912420 compiler.compile_program(&ast, symbol_table).unwrap();
1242012421 let _table = compiler.pop_symbol_table();
1242112422 let stack_top = compiler.code_stack.pop().unwrap();
@@ -12456,7 +12457,7 @@ mod tests {
1245612457 let is_async = function.is_async;
1245712458 let range = function.range();
1245812459
12459- let mut compiler = Compiler::new(opts, source_file, "<module>".to_owned() );
12460+ let mut compiler = Compiler::new(opts, source_file, "<module>");
1246012461 compiler.future_annotations = symbol_table.future_annotations;
1246112462 compiler.symbol_table_stack.push(symbol_table);
1246212463 compiler.set_source_range(range);
0 commit comments