@@ -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" ,
@@ -280,7 +283,7 @@ pub fn incremental_build(
280283 only_incremental : bool ,
281284 create_sourcedirs : bool ,
282285 plain_output : bool ,
283- ) -> Result < IncrementalBuildResult , IncrementalBuildError > {
286+ ) -> Result < CompilationOutcome , IncrementalBuildError > {
284287 let build_folder = build_state. root_folder . to_string_lossy ( ) . to_string ( ) ;
285288
286289 let _lock = get_lock_or_exit ( LockKind :: Build , & build_folder) ;
@@ -443,7 +446,11 @@ pub fn incremental_build(
443446 } else {
444447 let has_compile_warnings = has_output ( & compile_warnings) ;
445448 let has_config_warning_output = initial_build && has_config_warnings ( build_state) ;
446- let has_warnings = has_parse_warnings || has_compile_warnings || has_config_warning_output;
449+ let outcome = if has_parse_warnings || has_compile_warnings || has_config_warning_output {
450+ CompilationOutcome :: Warnings
451+ } else {
452+ CompilationOutcome :: Clean
453+ } ;
447454
448455 if show_progress {
449456 if plain_output {
@@ -471,7 +478,7 @@ pub fn incremental_build(
471478 write_compiler_info ( build_state) ;
472479
473480 let _lock = drop_lock ( LockKind :: Build , & build_folder) ;
474- Ok ( IncrementalBuildResult { has_warnings } )
481+ Ok ( outcome )
475482 }
476483}
477484
@@ -565,7 +572,7 @@ pub fn build(
565572 "\n {}" ,
566573 format_finished_compilation_message(
567574 None ,
568- result. has_warnings ,
575+ result,
569576 default_timing. unwrap_or( timing_total_elapsed) ,
570577 )
571578 ) ;
@@ -589,15 +596,19 @@ mod tests {
589596 #[ test]
590597 fn formats_successful_completion_message ( ) {
591598 assert_eq ! (
592- format_finished_compilation_message( None , false , Duration :: from_millis( 1500 ) ) ,
599+ format_finished_compilation_message( None , CompilationOutcome :: Clean , Duration :: from_millis( 1500 ) , ) ,
593600 format!( "{LINE_CLEAR}{}Finished compilation in 1.50s" , CHECKMARK )
594601 ) ;
595602 }
596603
597604 #[ test]
598605 fn formats_warning_completion_message ( ) {
599606 assert_eq ! (
600- format_finished_compilation_message( Some ( "incremental" ) , true , Duration :: from_millis( 1500 ) ) ,
607+ format_finished_compilation_message(
608+ Some ( "incremental" ) ,
609+ CompilationOutcome :: Warnings ,
610+ Duration :: from_millis( 1500 ) ,
611+ ) ,
601612 format!(
602613 "{LINE_CLEAR}{}Finished incremental compilation with warnings in 1.50s" ,
603614 WARNING
0 commit comments