@@ -141,6 +141,7 @@ use crate::core::compiler::future_incompat::{
141
141
} ;
142
142
use crate :: core:: resolver:: ResolveBehavior ;
143
143
use crate :: core:: { PackageId , Shell , TargetKind } ;
144
+ use crate :: util:: context:: WarningHandling ;
144
145
use crate :: util:: diagnostic_server:: { self , DiagnosticPrinter } ;
145
146
use crate :: util:: errors:: AlreadyPrintedError ;
146
147
use crate :: util:: machine_message:: { self , Message as _} ;
@@ -602,6 +603,7 @@ impl<'gctx> DrainState<'gctx> {
602
603
plan : & mut BuildPlan ,
603
604
event : Message ,
604
605
) -> Result < ( ) , ErrorToHandle > {
606
+ let warning_handling = build_runner. bcx . gctx . warning_handling ( ) ?;
605
607
match event {
606
608
Message :: Run ( id, cmd) => {
607
609
build_runner
@@ -639,7 +641,9 @@ impl<'gctx> DrainState<'gctx> {
639
641
}
640
642
}
641
643
Message :: Warning { id, warning } => {
642
- build_runner. bcx . gctx . shell ( ) . warn ( warning) ?;
644
+ if warning_handling != WarningHandling :: Allow {
645
+ build_runner. bcx . gctx . shell ( ) . warn ( warning) ?;
646
+ }
643
647
self . bump_warning_count ( id, true , false ) ;
644
648
}
645
649
Message :: WarningCount {
@@ -660,7 +664,7 @@ impl<'gctx> DrainState<'gctx> {
660
664
trace ! ( "end: {:?}" , id) ;
661
665
self . finished += 1 ;
662
666
self . report_warning_count (
663
- build_runner. bcx . gctx ,
667
+ build_runner,
664
668
id,
665
669
& build_runner. bcx . rustc ( ) . workspace_wrapper ,
666
670
) ;
@@ -1024,17 +1028,19 @@ impl<'gctx> DrainState<'gctx> {
1024
1028
/// Displays a final report of the warnings emitted by a particular job.
1025
1029
fn report_warning_count (
1026
1030
& mut self ,
1027
- gctx : & GlobalContext ,
1031
+ runner : & mut BuildRunner < ' _ , ' _ > ,
1028
1032
id : JobId ,
1029
1033
rustc_workspace_wrapper : & Option < PathBuf > ,
1030
1034
) {
1031
- let count = match self . warning_count . remove ( & id) {
1035
+ let gctx = runner. bcx . gctx ;
1036
+ let count = match self . warning_count . get ( & id) {
1032
1037
// An error could add an entry for a `Unit`
1033
1038
// with 0 warnings but having fixable
1034
1039
// warnings be disallowed
1035
1040
Some ( count) if count. total > 0 => count,
1036
1041
None | Some ( _) => return ,
1037
1042
} ;
1043
+ runner. compilation . warning_count += count. total ;
1038
1044
let unit = & self . active [ & id] ;
1039
1045
let mut message = descriptive_pkg_name ( & unit. pkg . name ( ) , & unit. target , & unit. mode ) ;
1040
1046
message. push_str ( " generated " ) ;
0 commit comments