Fix unnessessary borrow

This commit is contained in:
Jeong YunWon 2021-07-30 02:30:59 +09:00
parent 5d639cc8de
commit 9b0a82aed3
2 changed files with 6 additions and 6 deletions

View file

@ -348,7 +348,7 @@ impl Compiler {
self.emit(Instruction::PrintExpr); self.emit(Instruction::PrintExpr);
} }
} else { } else {
self.compile_statement(&statement)?; self.compile_statement(statement)?;
} }
} }
@ -470,7 +470,7 @@ impl Compiler {
// we do this here because `from __future__` still executes that `from` statement at runtime, // we do this here because `from __future__` still executes that `from` statement at runtime,
// we still need to compile the ImportFrom down below // we still need to compile the ImportFrom down below
ImportFrom { module, names, .. } if module.as_deref() == Some("__future__") => { ImportFrom { module, names, .. } if module.as_deref() == Some("__future__") => {
self.compile_future_features(&names)? self.compile_future_features(names)?
} }
// if we find any other statement, stop accepting future statements // if we find any other statement, stop accepting future statements
_ => self.done_with_future_stmts = true, _ => self.done_with_future_stmts = true,
@ -1068,7 +1068,7 @@ impl Compiler {
self.emit_constant(ConstantData::Str { self.emit_constant(ConstantData::Str {
value: self.mangle(&arg.node.arg).into_owned(), value: self.mangle(&arg.node.arg).into_owned(),
}); });
self.compile_expression(&annotation)?; self.compile_expression(annotation)?;
num_annotations += 1; num_annotations += 1;
} }
} }
@ -1159,7 +1159,7 @@ impl Compiler {
orelse, orelse,
finalbody, finalbody,
.. ..
} => self.find_ann(&body) || self.find_ann(orelse) || self.find_ann(finalbody), } => self.find_ann(body) || self.find_ann(orelse) || self.find_ann(finalbody),
_ => false, _ => false,
}; };
if res { if res {

View file

@ -617,7 +617,7 @@ impl SymbolTableBuilder {
fn scan_parameter_annotation(&mut self, parameter: &ast::Arg) -> SymbolTableResult { fn scan_parameter_annotation(&mut self, parameter: &ast::Arg) -> SymbolTableResult {
if let Some(annotation) = &parameter.node.annotation { if let Some(annotation) = &parameter.node.annotation {
self.scan_expression(&annotation, ExpressionContext::Load)?; self.scan_expression(annotation, ExpressionContext::Load)?;
} }
Ok(()) Ok(())
} }
@ -1075,7 +1075,7 @@ impl SymbolTableBuilder {
// Evaluate eventual default parameters: // Evaluate eventual default parameters:
self.scan_expressions(&args.defaults, ExpressionContext::Load)?; self.scan_expressions(&args.defaults, ExpressionContext::Load)?;
for expression in args.kw_defaults.iter().flatten() { for expression in args.kw_defaults.iter().flatten() {
self.scan_expression(&expression, ExpressionContext::Load)?; self.scan_expression(expression, ExpressionContext::Load)?;
} }
// Annotations are scanned in outer scope: // Annotations are scanned in outer scope: