@@ -290,15 +290,15 @@ impl<O: OutputStream> Compiler<O> {
290
290
fn load_name ( & mut self , name : & str ) {
291
291
let scope = self . scope_for_name ( name) ;
292
292
self . emit ( Instruction :: LoadName {
293
- name : name. to_string ( ) ,
293
+ name : name. to_owned ( ) ,
294
294
scope,
295
295
} ) ;
296
296
}
297
297
298
298
fn store_name ( & mut self , name : & str ) {
299
299
let scope = self . scope_for_name ( name) ;
300
300
self . emit ( Instruction :: StoreName {
301
- name : name. to_string ( ) ,
301
+ name : name. to_owned ( ) ,
302
302
scope,
303
303
} ) ;
304
304
}
@@ -359,7 +359,7 @@ impl<O: OutputStream> Compiler<O> {
359
359
for name in names {
360
360
// import symbol from module:
361
361
self . emit ( Instruction :: ImportFrom {
362
- name : name. symbol . to_string ( ) ,
362
+ name : name. symbol . to_owned ( ) ,
363
363
} ) ;
364
364
365
365
// Store module under proper name:
@@ -619,13 +619,13 @@ impl<O: OutputStream> Compiler<O> {
619
619
match & expression. node {
620
620
ast:: ExpressionType :: Identifier { name } => {
621
621
self . emit ( Instruction :: DeleteName {
622
- name : name. to_string ( ) ,
622
+ name : name. to_owned ( ) ,
623
623
} ) ;
624
624
}
625
625
ast:: ExpressionType :: Attribute { value, name } => {
626
626
self . compile_expression ( value) ?;
627
627
self . emit ( Instruction :: DeleteAttr {
628
- name : name. to_string ( ) ,
628
+ name : name. to_owned ( ) ,
629
629
} ) ;
630
630
}
631
631
ast:: ExpressionType :: Subscript { a, b } => {
@@ -701,7 +701,7 @@ impl<O: OutputStream> Compiler<O> {
701
701
compile_varargs ( & args. kwarg ) ,
702
702
self . source_path . clone ( ) . unwrap ( ) ,
703
703
line_number,
704
- name. to_string ( ) ,
704
+ name. to_owned ( ) ,
705
705
) ) ;
706
706
self . enter_scope ( ) ;
707
707
@@ -909,7 +909,7 @@ impl<O: OutputStream> Compiler<O> {
909
909
if let Some ( annotation) = & arg. annotation {
910
910
self . emit ( Instruction :: LoadConst {
911
911
value : bytecode:: Constant :: String {
912
- value : arg. arg . to_string ( ) ,
912
+ value : arg. arg . to_owned ( ) ,
913
913
} ,
914
914
} ) ;
915
915
self . compile_expression ( & annotation) ?;
@@ -982,7 +982,7 @@ impl<O: OutputStream> Compiler<O> {
982
982
Varargs :: None ,
983
983
self . source_path . clone ( ) . unwrap ( ) ,
984
984
line_number,
985
- name. to_string ( ) ,
985
+ name. to_owned ( ) ,
986
986
) ) ;
987
987
self . enter_scope ( ) ;
988
988
@@ -1022,7 +1022,7 @@ impl<O: OutputStream> Compiler<O> {
1022
1022
} ) ;
1023
1023
self . emit ( Instruction :: LoadConst {
1024
1024
value : bytecode:: Constant :: String {
1025
- value : name. to_string ( ) ,
1025
+ value : name. to_owned ( ) ,
1026
1026
} ,
1027
1027
} ) ;
1028
1028
@@ -1044,7 +1044,7 @@ impl<O: OutputStream> Compiler<O> {
1044
1044
for keyword in keywords {
1045
1045
if let Some ( name) = & keyword. name {
1046
1046
kwarg_names. push ( bytecode:: Constant :: String {
1047
- value : name. to_string ( ) ,
1047
+ value : name. to_owned ( ) ,
1048
1048
} ) ;
1049
1049
} else {
1050
1050
// This means **kwargs!
@@ -1308,7 +1308,7 @@ impl<O: OutputStream> Compiler<O> {
1308
1308
} ) ;
1309
1309
self . emit ( Instruction :: LoadConst {
1310
1310
value : bytecode:: Constant :: String {
1311
- value : name. to_string ( ) ,
1311
+ value : name. to_owned ( ) ,
1312
1312
} ,
1313
1313
} ) ;
1314
1314
self . emit ( Instruction :: StoreSubscript ) ;
@@ -1332,7 +1332,7 @@ impl<O: OutputStream> Compiler<O> {
1332
1332
ast:: ExpressionType :: Attribute { value, name } => {
1333
1333
self . compile_expression ( value) ?;
1334
1334
self . emit ( Instruction :: StoreAttr {
1335
- name : name. to_string ( ) ,
1335
+ name : name. to_owned ( ) ,
1336
1336
} ) ;
1337
1337
}
1338
1338
ast:: ExpressionType :: List { elements } | ast:: ExpressionType :: Tuple { elements } => {
@@ -1605,7 +1605,7 @@ impl<O: OutputStream> Compiler<O> {
1605
1605
Attribute { value, name } => {
1606
1606
self . compile_expression ( value) ?;
1607
1607
self . emit ( Instruction :: LoadAttr {
1608
- name : name. to_string ( ) ,
1608
+ name : name. to_owned ( ) ,
1609
1609
} ) ;
1610
1610
}
1611
1611
Compare { vals, ops } => {
@@ -1795,7 +1795,7 @@ impl<O: OutputStream> Compiler<O> {
1795
1795
if let Some ( name) = & keyword. name {
1796
1796
self . emit ( Instruction :: LoadConst {
1797
1797
value : bytecode:: Constant :: String {
1798
- value : name. to_string ( ) ,
1798
+ value : name. to_owned ( ) ,
1799
1799
} ,
1800
1800
} ) ;
1801
1801
self . compile_expression ( & keyword. value ) ?;
@@ -1858,7 +1858,7 @@ impl<O: OutputStream> Compiler<O> {
1858
1858
for keyword in keywords {
1859
1859
if let Some ( name) = & keyword. name {
1860
1860
kwarg_names. push ( bytecode:: Constant :: String {
1861
- value : name. to_string ( ) ,
1861
+ value : name. to_owned ( ) ,
1862
1862
} ) ;
1863
1863
} else {
1864
1864
// This means **kwargs!
@@ -1927,7 +1927,7 @@ impl<O: OutputStream> Compiler<O> {
1927
1927
ast:: ComprehensionKind :: Set { .. } => "<setcomp>" ,
1928
1928
ast:: ComprehensionKind :: Dict { .. } => "<dictcomp>" ,
1929
1929
}
1930
- . to_string ( ) ;
1930
+ . to_owned ( ) ;
1931
1931
1932
1932
let line_number = self . get_source_line_number ( ) ;
1933
1933
// Create magnificent function <listcomp>:
@@ -2099,7 +2099,7 @@ impl<O: OutputStream> Compiler<O> {
2099
2099
ast:: StringGroup :: Constant { value } => {
2100
2100
self . emit ( Instruction :: LoadConst {
2101
2101
value : bytecode:: Constant :: String {
2102
- value : value. to_string ( ) ,
2102
+ value : value. to_owned ( ) ,
2103
2103
} ,
2104
2104
} ) ;
2105
2105
}
@@ -2266,7 +2266,7 @@ mod tests {
2266
2266
let mut compiler: Compiler = Default :: default ( ) ;
2267
2267
compiler. source_path = Some ( "source_path" . to_owned ( ) ) ;
2268
2268
compiler. push_new_code_object ( "<module>" . to_owned ( ) ) ;
2269
- let ast = parser:: parse_program ( & source. to_string ( ) ) . unwrap ( ) ;
2269
+ let ast = parser:: parse_program ( source) . unwrap ( ) ;
2270
2270
let symbol_scope = make_symbol_table ( & ast) . unwrap ( ) ;
2271
2271
compiler. compile_program ( & ast, symbol_scope) . unwrap ( ) ;
2272
2272
compiler. pop_code_object ( )
0 commit comments