@@ -100,19 +100,6 @@ impl CompileContext {
100
100
}
101
101
}
102
102
103
- /// A helper function for the shared code of the different compile functions
104
- fn with_compiler (
105
- source_path : String ,
106
- opts : CompileOpts ,
107
- f : impl FnOnce ( & mut Compiler ) -> CompileResult < ( ) > ,
108
- ) -> CompileResult < CodeObject > {
109
- let mut compiler = Compiler :: new ( opts, source_path, "<module>" . to_owned ( ) ) ;
110
- f ( & mut compiler) ?;
111
- let code = compiler. pop_code_object ( ) ;
112
- trace ! ( "Compilation completed: {:?}" , code) ;
113
- Ok ( code)
114
- }
115
-
116
103
/// Compile an ast::Mod produced from rustpython_parser::parser::parse()
117
104
pub fn compile_top (
118
105
ast : & ast:: Mod ,
@@ -127,6 +114,7 @@ pub fn compile_top(
127
114
}
128
115
}
129
116
117
+ /// A helper function for the shared code of the different compile functions
130
118
fn compile_impl < Ast : ?Sized > (
131
119
ast : & Ast ,
132
120
source_path : String ,
@@ -138,9 +126,12 @@ fn compile_impl<Ast: ?Sized>(
138
126
Ok ( x) => x,
139
127
Err ( e) => return Err ( e. into_compile_error ( source_path) ) ,
140
128
} ;
141
- with_compiler ( source_path, opts, |compiler| {
142
- compile ( compiler, ast, symbol_table)
143
- } )
129
+
130
+ let mut compiler = Compiler :: new ( opts, source_path, "<module>" . to_owned ( ) ) ;
131
+ compile ( & mut compiler, ast, symbol_table) ?;
132
+ let code = compiler. pop_code_object ( ) ;
133
+ trace ! ( "Compilation completed: {:?}" , code) ;
134
+ Ok ( code)
144
135
}
145
136
146
137
/// Compile a standard Python program to bytecode
0 commit comments