@@ -115,6 +115,7 @@ This would avoid the complex interleaving above and avoid needing to use lifetim
115115for all functions (it would only be needed for functions with tracked data in proof code).
116116*/
117117struct CompilerCallbacksEraseMacro {
118+ pub do_compile : bool ,
118119 pub override_stability : bool ,
119120}
120121
@@ -136,6 +137,18 @@ impl rustc_driver::Callbacks for CompilerCallbacksEraseMacro {
136137 } ) ;
137138 }
138139 }
140+
141+ fn after_analysis < ' tcx > (
142+ & mut self ,
143+ _compiler : & rustc_interface:: interface:: Compiler ,
144+ _tcx : TyCtxt < ' tcx > ,
145+ ) -> rustc_driver:: Compilation {
146+ if self . do_compile {
147+ rustc_driver:: Compilation :: Continue
148+ } else {
149+ rustc_driver:: Compilation :: Stop
150+ }
151+ }
139152}
140153
141154/// Captures the verification and compilation time
@@ -153,9 +166,11 @@ pub struct Stats {
153166
154167pub ( crate ) fn run_with_erase_macro_compile (
155168 mut rustc_args : Vec < String > ,
169+ do_compile : bool ,
156170 vstd : Vstd ,
157171) -> Result < ( ) , ( ) > {
158172 let mut callbacks = CompilerCallbacksEraseMacro {
173+ do_compile,
159174 override_stability : matches ! ( vstd, Vstd :: IsCore | Vstd :: ImportedViaCore ) ,
160175 } ;
161176 rustc_args. extend ( [ "--cfg" , "verus_only" , "--cfg" , "verus_keep_ghost" ] . map ( |s| s. to_string ( ) ) ) ;
@@ -320,7 +335,8 @@ pub fn run(
320335 if !verifier. compile && ( verifier. args . no_erasure_check || verifier. args . no_lifetime ) {
321336 Ok ( ( ) )
322337 } else {
323- run_with_erase_macro_compile ( rustc_args, verifier. args . vstd )
338+ let do_compile = verifier. compile || verifier. via_cargo_args . is_some ( ) ;
339+ run_with_erase_macro_compile ( rustc_args, do_compile, verifier. args . vstd )
324340 } ;
325341
326342 let time2 = Instant :: now ( ) ;
0 commit comments