@@ -88,7 +88,7 @@ fn with_compiler(
88
88
) -> Result < CodeObject , CompileError > {
89
89
let mut compiler = Compiler :: new ( optimize) ;
90
90
compiler. source_path = Some ( source_path) ;
91
- compiler. push_new_code_object ( "<module>" . to_string ( ) ) ;
91
+ compiler. push_new_code_object ( "<module>" . to_owned ( ) ) ;
92
92
f ( & mut compiler) ?;
93
93
let code = compiler. pop_code_object ( ) ;
94
94
trace ! ( "Compilation completed: {:?}" , code) ;
@@ -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
@@ -897,7 +897,7 @@ impl<O: OutputStream> Compiler<O> {
897
897
// key:
898
898
self . emit ( Instruction :: LoadConst {
899
899
value : bytecode:: Constant :: String {
900
- value : "return" . to_string ( ) ,
900
+ value : "return" . to_owned ( ) ,
901
901
} ,
902
902
} ) ;
903
903
// value:
@@ -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,18 +982,18 @@ 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
989
989
let ( new_body, doc_str) = get_doc ( body) ;
990
990
991
991
self . emit ( Instruction :: LoadName {
992
- name : "__name__" . to_string ( ) ,
992
+ name : "__name__" . to_owned ( ) ,
993
993
scope : bytecode:: NameScope :: Global ,
994
994
} ) ;
995
995
self . emit ( Instruction :: StoreName {
996
- name : "__module__" . to_string ( ) ,
996
+ name : "__module__" . to_owned ( ) ,
997
997
scope : bytecode:: NameScope :: Free ,
998
998
} ) ;
999
999
self . emit ( Instruction :: LoadConst {
@@ -1002,7 +1002,7 @@ impl<O: OutputStream> Compiler<O> {
1002
1002
} ,
1003
1003
} ) ;
1004
1004
self . emit ( Instruction :: StoreName {
1005
- name : "__qualname__" . to_string ( ) ,
1005
+ name : "__qualname__" . to_owned ( ) ,
1006
1006
scope : bytecode:: NameScope :: Free ,
1007
1007
} ) ;
1008
1008
self . compile_statements ( new_body) ?;
@@ -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!
@@ -1090,7 +1090,7 @@ impl<O: OutputStream> Compiler<O> {
1090
1090
1091
1091
self . emit ( Instruction :: Rotate { amount : 2 } ) ;
1092
1092
self . emit ( Instruction :: StoreAttr {
1093
- name : "__doc__" . to_string ( ) ,
1093
+ name : "__doc__" . to_owned ( ) ,
1094
1094
} ) ;
1095
1095
}
1096
1096
@@ -1171,7 +1171,7 @@ impl<O: OutputStream> Compiler<O> {
1171
1171
self . set_label ( check_asynciter_label) ;
1172
1172
self . emit ( Instruction :: Duplicate ) ;
1173
1173
self . emit ( Instruction :: LoadName {
1174
- name : "StopAsyncIteration" . to_string ( ) ,
1174
+ name : "StopAsyncIteration" . to_owned ( ) ,
1175
1175
scope : bytecode:: NameScope :: Global ,
1176
1176
} ) ;
1177
1177
self . emit ( Instruction :: CompareOperation {
@@ -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 } => {
@@ -1732,7 +1732,7 @@ impl<O: OutputStream> Compiler<O> {
1732
1732
func : FunctionContext :: Function ,
1733
1733
} ;
1734
1734
1735
- let name = "<lambda>" . to_string ( ) ;
1735
+ let name = "<lambda>" . to_owned ( ) ;
1736
1736
self . enter_function ( & name, args) ?;
1737
1737
self . compile_expression ( body) ?;
1738
1738
self . emit ( Instruction :: ReturnValue ) ;
@@ -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,13 +1927,13 @@ 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>:
1934
1934
self . push_output ( CodeObject :: new (
1935
1935
Default :: default ( ) ,
1936
- vec ! [ ".0" . to_string ( ) ] ,
1936
+ vec ! [ ".0" . to_owned ( ) ] ,
1937
1937
Varargs :: None ,
1938
1938
vec ! [ ] ,
1939
1939
Varargs :: None ,
@@ -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
}
@@ -2264,9 +2264,9 @@ mod tests {
2264
2264
2265
2265
fn compile_exec ( source : & str ) -> CodeObject {
2266
2266
let mut compiler: Compiler = Default :: default ( ) ;
2267
- compiler. source_path = Some ( "source_path" . to_string ( ) ) ;
2268
- compiler. push_new_code_object ( "<module>" . to_string ( ) ) ;
2269
- let ast = parser:: parse_program ( & source. to_string ( ) ) . unwrap ( ) ;
2267
+ compiler. source_path = Some ( "source_path" . to_owned ( ) ) ;
2268
+ compiler. push_new_code_object ( "<module>" . to_owned ( ) ) ;
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