@@ -100,19 +100,6 @@ impl CompileContext {
100100 }
101101}
102102
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-
116103/// Compile an ast::Mod produced from rustpython_parser::parser::parse()
117104pub fn compile_top (
118105 ast : & ast:: Mod ,
@@ -127,6 +114,7 @@ pub fn compile_top(
127114 }
128115}
129116
117+ /// A helper function for the shared code of the different compile functions
130118fn compile_impl < Ast : ?Sized > (
131119 ast : & Ast ,
132120 source_path : String ,
@@ -138,9 +126,12 @@ fn compile_impl<Ast: ?Sized>(
138126 Ok ( x) => x,
139127 Err ( e) => return Err ( e. into_compile_error ( source_path) ) ,
140128 } ;
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)
144135}
145136
146137/// Compile a standard Python program to bytecode
0 commit comments