@@ -97,6 +97,7 @@ pub enum FlycheckConfig {
9797 verus_args : Vec < String > ,
9898 cargo_verus_enable : bool ,
9999 cargo_options : CargoOptions ,
100+ report_all_errors : bool ,
100101 } ,
101102}
102103
@@ -107,8 +108,8 @@ impl fmt::Display for FlycheckConfig {
107108 FlycheckConfig :: CustomCommand { command, args, .. } => {
108109 write ! ( f, "{command} {}" , args. join( " " ) )
109110 }
110- FlycheckConfig :: VerusCommand { verus_args, cargo_verus_enable, cargo_options } => {
111- write ! ( f, "verus {} (cargo_verus enabled: {}, cargo_verus options {:?})" , verus_args. join( " " ) , cargo_verus_enable, cargo_options)
111+ FlycheckConfig :: VerusCommand { verus_args, cargo_verus_enable, cargo_options, report_all_errors } => {
112+ write ! ( f, "verus {} (cargo_verus enabled: {}, cargo_verus options {:?}, report all errors: {} )" , verus_args. join( " " ) , cargo_verus_enable, cargo_options, report_all_errors )
112113 }
113114 }
114115 }
@@ -546,7 +547,7 @@ impl FlycheckActor {
546547 }
547548
548549 // copied from above check_command
549- fn run_cargo_verus ( & self , file : String , verus_args : & Vec < String > , cargo_options : & CargoOptions ) -> Command {
550+ fn run_cargo_verus ( & self , file : String , verus_args : & Vec < String > , cargo_options : & CargoOptions , report_all_errors : bool ) -> Command {
550551 // Find the `cargo-verus` binary
551552 let verus_binary_str = match std:: env:: var ( "VERUS_BINARY_PATH" ) {
552553 Ok ( path) => path,
@@ -627,21 +628,27 @@ impl FlycheckActor {
627628 module_args. push ( "--verify-root" . to_string ( ) ) ;
628629 }
629630
631+ // Cargo command
630632 cmd. arg ( "verify" . to_string ( ) ) ;
633+ // Provide the cargo arguments
631634 cmd. arg ( "--message-format=json" . to_string ( ) ) ;
632635 cargo_options. apply_on_command ( & mut cmd) ;
636+ cmd. args ( & cargo_options. extra_args ) ;
637+ // Provide the Verus arguments
633638 cmd. arg ( "--" . to_string ( ) ) ;
634639 cmd. args ( verus_args) ;
635640 cmd. args ( extra_args_from_toml) ;
636- cmd. args ( module_args) ;
641+ if !report_all_errors {
642+ cmd. args ( module_args) ;
643+ }
637644
638645 cmd. current_dir ( & self . root ) ;
639646 dbg ! ( & self . root) ;
640647 cmd
641648 }
642649
643650 // copied from above check_command
644- fn run_verus_direct ( & self , file : String , verus_args : & Vec < String > ) -> Command {
651+ fn run_verus_direct ( & self , file : String , verus_args : & Vec < String > , report_all_errors : bool ) -> Command {
645652 let verus_binary_str = match std:: env:: var ( "VERUS_BINARY_PATH" ) {
646653 Ok ( path) => path,
647654 Err ( _) => {
@@ -696,15 +703,16 @@ impl FlycheckActor {
696703 }
697704 }
698705
699- // We may need to add additional arguments
700- let mut args = verus_args. to_vec ( ) ;
706+ // We may need to add additional configuration arguments
707+ let mut config_args = vec ! [ ] ; // File name and crate type
708+ let mut module_args = vec ! [ ] ; // Arguments to restrict verification to the file currently being edited
701709 match toml_dir {
702710 None => {
703711 // This file doesn't appear to be part of a larger project
704712 // Try to invoke Verus on it directly, but try to avoid
705713 // complaints about missing `fn main()`
706- args . push ( "--crate-type" . to_string ( ) ) ;
707- args . push ( "lib" . to_string ( ) ) ;
714+ config_args . push ( "--crate-type" . to_string ( ) ) ;
715+ config_args . push ( "lib" . to_string ( ) ) ;
708716 }
709717 Some ( toml_dir) => {
710718 // This file appears to be part of a Rust project.
@@ -713,8 +721,8 @@ impl FlycheckActor {
713721 let root_file = if toml_dir. join ( "src" ) . join ( "main.rs" ) . exists ( ) {
714722 Some ( toml_dir. join ( "src" ) . join ( "main.rs" ) )
715723 } else if toml_dir. join ( "src" ) . join ( "lib.rs" ) . exists ( ) {
716- args . push ( "--crate-type" . to_string ( ) ) ;
717- args . push ( "lib" . to_string ( ) ) ;
724+ config_args . push ( "--crate-type" . to_string ( ) ) ;
725+ config_args . push ( "lib" . to_string ( ) ) ;
718726 Some ( toml_dir. join ( "src" ) . join ( "lib.rs" ) )
719727 } else {
720728 None
@@ -735,32 +743,39 @@ impl FlycheckActor {
735743 . trim_end_matches ( "::mod" )
736744 . to_string ( ) ;
737745
738- args . insert ( 0 , root_file. to_str ( ) . unwrap ( ) . to_string ( ) ) ;
746+ config_args . insert ( 0 , root_file. to_str ( ) . unwrap ( ) . to_string ( ) ) ;
739747 if file == root_file {
740748 tracing:: info!( "file == root_file" ) ;
741749 } else {
742750 tracing:: info!( ?root_file, "root_file" ) ;
743- args . insert ( 1 , "--verify-module" . to_string ( ) ) ;
744- args . insert ( 2 , file_as_module) ;
751+ module_args . push ( "--verify-module" . to_string ( ) ) ;
752+ module_args . push ( file_as_module) ;
745753 }
746754 }
747755 None => {
748756 // Puzzling -- we found a Cargo.toml but no root file.
749757 // Do our best by trying to run directly on the file supplied
750- args . insert ( 0 , file. to_str ( ) . unwrap ( ) . to_string ( ) ) ;
751- args . push ( "--crate-type" . to_string ( ) ) ;
752- args . push ( "lib" . to_string ( ) ) ;
758+ config_args . insert ( 0 , file. to_str ( ) . unwrap ( ) . to_string ( ) ) ;
759+ config_args . push ( "--crate-type" . to_string ( ) ) ;
760+ config_args . push ( "lib" . to_string ( ) ) ;
753761 }
754762 }
755763 }
756764 }
765+
766+ // Apply all of the argument collections
767+ cmd. args ( verus_args) ;
768+ cmd. args ( config_args) ;
769+ cmd. args ( extra_args_from_toml) ;
770+ if !report_all_errors {
771+ cmd. args ( module_args) ;
772+ }
757773
758- args . append ( & mut extra_args_from_toml ) ;
759- args . push ( "--" . to_string ( ) ) ;
760- args . push ( "--error-format=json" . to_string ( ) ) ;
774+ // Apply arguments that go to rustc instead of Verus
775+ cmd . arg ( "--" . to_string ( ) ) ;
776+ cmd . arg ( "--error-format=json" . to_string ( ) ) ;
761777
762778 cmd. current_dir ( & self . root ) ;
763- cmd. args ( args) ;
764779 cmd
765780 }
766781
@@ -772,11 +787,11 @@ impl FlycheckActor {
772787 FlycheckConfig :: CustomCommand { .. } => {
773788 panic ! ( "verus analyzer does not yet support custom commands" )
774789 }
775- FlycheckConfig :: VerusCommand { verus_args, cargo_verus_enable, cargo_options } => {
790+ FlycheckConfig :: VerusCommand { verus_args, cargo_verus_enable, cargo_options, report_all_errors } => {
776791 if * cargo_verus_enable {
777- self . run_cargo_verus ( file, verus_args, cargo_options)
792+ self . run_cargo_verus ( file, verus_args, cargo_options, * report_all_errors )
778793 } else {
779- self . run_verus_direct ( file, verus_args)
794+ self . run_verus_direct ( file, verus_args, * report_all_errors )
780795 }
781796 }
782797 } ;
0 commit comments