@@ -105,17 +105,20 @@ pub fn abort_on_err<T>(result: Result<T, ErrorReported>, sess: &Session) -> T {
105
105
pub trait Callbacks {
106
106
/// Called before creating the compiler instance
107
107
fn config ( & mut self , _config : & mut interface:: Config ) { }
108
- /// Called after parsing and returns true to continue execution
109
- fn after_parsing ( & mut self , _compiler : & interface:: Compiler ) -> bool {
110
- true
108
+ /// Called after parsing. Return value instructs the compiler whether to
109
+ /// continue the compilation afterwards (defaults to `Compilation::Continue`)
110
+ fn after_parsing ( & mut self , _compiler : & interface:: Compiler ) -> Compilation {
111
+ Compilation :: Continue
111
112
}
112
- /// Called after expansion and returns true to continue execution
113
- fn after_expansion ( & mut self , _compiler : & interface:: Compiler ) -> bool {
114
- true
113
+ /// Called after expansion. Return value instructs the compiler whether to
114
+ /// continue the compilation afterwards (defaults to `Compilation::Continue`)
115
+ fn after_expansion ( & mut self , _compiler : & interface:: Compiler ) -> Compilation {
116
+ Compilation :: Continue
115
117
}
116
- /// Called after analysis and returns true to continue execution
117
- fn after_analysis ( & mut self , _compiler : & interface:: Compiler ) -> bool {
118
- true
118
+ /// Called after analysis. Return value instructs the compiler whether to
119
+ /// continue the compilation afterwards (defaults to `Compilation::Continue`)
120
+ fn after_analysis ( & mut self , _compiler : & interface:: Compiler ) -> Compilation {
121
+ Compilation :: Continue
119
122
}
120
123
}
121
124
@@ -298,7 +301,7 @@ pub fn run_compiler(
298
301
}
299
302
}
300
303
301
- if ! callbacks. after_parsing ( compiler) {
304
+ if callbacks. after_parsing ( compiler) == Compilation :: Stop {
302
305
return sess. compile_status ( ) ;
303
306
}
304
307
@@ -317,7 +320,7 @@ pub fn run_compiler(
317
320
}
318
321
319
322
compiler. expansion ( ) ?;
320
- if ! callbacks. after_expansion ( compiler) {
323
+ if callbacks. after_expansion ( compiler) == Compilation :: Stop {
321
324
return sess. compile_status ( ) ;
322
325
}
323
326
@@ -364,7 +367,7 @@ pub fn run_compiler(
364
367
365
368
compiler. global_ctxt ( ) ?. peek_mut ( ) . enter ( |tcx| tcx. analysis ( LOCAL_CRATE ) ) ?;
366
369
367
- if ! callbacks. after_analysis ( compiler) {
370
+ if callbacks. after_analysis ( compiler) == Compilation :: Stop {
368
371
return sess. compile_status ( ) ;
369
372
}
370
373
0 commit comments