@@ -57,8 +57,9 @@ pub struct CompilerArgs {
5757}
5858
5959#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
60- pub struct IncrementalBuildResult {
61- pub has_warnings : bool ,
60+ pub enum CompilationOutcome {
61+ Clean ,
62+ Warnings ,
6263}
6364
6465fn has_output ( output : & str ) -> bool {
@@ -75,14 +76,16 @@ fn has_config_warnings(build_state: &BuildCommandState) -> bool {
7576
7677pub fn format_finished_compilation_message (
7778 compilation_kind : Option < & str > ,
78- has_warnings : bool ,
79+ outcome : CompilationOutcome ,
7980 duration : Duration ,
8081) -> String {
8182 let compilation_kind = compilation_kind
8283 . map ( |kind| format ! ( "{kind} " ) )
8384 . unwrap_or_default ( ) ;
84- let status = if has_warnings { WARNING } else { CHECKMARK } ;
85- let warning_suffix = if has_warnings { " with warnings" } else { "" } ;
85+ let ( status, warning_suffix) = match outcome {
86+ CompilationOutcome :: Clean => ( CHECKMARK , "" ) ,
87+ CompilationOutcome :: Warnings => ( WARNING , " with warnings" ) ,
88+ } ;
8689
8790 format ! (
8891 "{LINE_CLEAR}{status}Finished {compilation_kind}compilation{warning_suffix} in {:.2}s" ,
@@ -279,7 +282,7 @@ pub fn incremental_build(
279282 only_incremental : bool ,
280283 create_sourcedirs : bool ,
281284 plain_output : bool ,
282- ) -> Result < IncrementalBuildResult , IncrementalBuildError > {
285+ ) -> Result < CompilationOutcome , IncrementalBuildError > {
283286 let build_folder = build_state. root_folder . to_string_lossy ( ) . to_string ( ) ;
284287
285288 let _lock = get_lock_or_exit ( LockKind :: Build , & build_folder) ;
@@ -442,7 +445,11 @@ pub fn incremental_build(
442445 } else {
443446 let has_compile_warnings = has_output ( & compile_warnings) ;
444447 let has_config_warning_output = initial_build && has_config_warnings ( build_state) ;
445- let has_warnings = has_parse_warnings || has_compile_warnings || has_config_warning_output;
448+ let outcome = if has_parse_warnings || has_compile_warnings || has_config_warning_output {
449+ CompilationOutcome :: Warnings
450+ } else {
451+ CompilationOutcome :: Clean
452+ } ;
446453
447454 if show_progress {
448455 if plain_output {
@@ -470,7 +477,7 @@ pub fn incremental_build(
470477 write_compiler_info ( build_state) ;
471478
472479 let _lock = drop_lock ( LockKind :: Build , & build_folder) ;
473- Ok ( IncrementalBuildResult { has_warnings } )
480+ Ok ( outcome )
474481 }
475482}
476483
@@ -564,7 +571,7 @@ pub fn build(
564571 "\n {}" ,
565572 format_finished_compilation_message(
566573 None ,
567- result. has_warnings ,
574+ result,
568575 default_timing. unwrap_or( timing_total_elapsed) ,
569576 )
570577 ) ;
@@ -588,15 +595,19 @@ mod tests {
588595 #[ test]
589596 fn formats_successful_completion_message ( ) {
590597 assert_eq ! (
591- format_finished_compilation_message( None , false , Duration :: from_millis( 1500 ) ) ,
598+ format_finished_compilation_message( None , CompilationOutcome :: Clean , Duration :: from_millis( 1500 ) , ) ,
592599 format!( "{LINE_CLEAR}{}Finished compilation in 1.50s" , CHECKMARK )
593600 ) ;
594601 }
595602
596603 #[ test]
597604 fn formats_warning_completion_message ( ) {
598605 assert_eq ! (
599- format_finished_compilation_message( Some ( "incremental" ) , true , Duration :: from_millis( 1500 ) ) ,
606+ format_finished_compilation_message(
607+ Some ( "incremental" ) ,
608+ CompilationOutcome :: Warnings ,
609+ Duration :: from_millis( 1500 ) ,
610+ ) ,
600611 format!(
601612 "{LINE_CLEAR}{}Finished incremental compilation with warnings in 1.50s" ,
602613 WARNING
0 commit comments