File tree Expand file tree Collapse file tree 3 files changed +19
-6
lines changed Expand file tree Collapse file tree 3 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -404,7 +404,11 @@ impl Shell {
404404 }
405405
406406 /// Prints the passed in [`Report`] to stderr
407- pub fn print_report ( & mut self , report : Report < ' _ > ) -> CargoResult < ( ) > {
407+ pub fn print_report ( & mut self , report : Report < ' _ > , force : bool ) -> CargoResult < ( ) > {
408+ if !force && matches ! ( self . verbosity, Verbosity :: Quiet ) {
409+ return Ok ( ( ) ) ;
410+ }
411+
408412 if self . needs_clear {
409413 self . err_erase_line ( ) ;
410414 }
Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ fn verify_feature_enabled(
171171 }
172172
173173 * error_count += 1 ;
174- gctx. shell ( ) . print_report ( & report) ?;
174+ gctx. shell ( ) . print_report ( & report, true ) ?;
175175 }
176176 Ok ( ( ) )
177177}
@@ -339,6 +339,15 @@ impl LintLevel {
339339 LintLevel :: Forbid => Level :: ERROR ,
340340 }
341341 }
342+
343+ fn force ( self ) -> bool {
344+ match self {
345+ Self :: Allow => false ,
346+ Self :: Warn => true ,
347+ Self :: Deny => true ,
348+ Self :: Forbid => true ,
349+ }
350+ }
342351}
343352
344353impl From < TomlLintLevel > for LintLevel {
@@ -459,7 +468,7 @@ pub fn check_im_a_teapot(
459468 )
460469 . element ( Level :: NOTE . message ( & emitted_reason) ) ] ;
461470
462- gctx. shell ( ) . print_report ( report) ?;
471+ gctx. shell ( ) . print_report ( report, lint_level . force ( ) ) ?;
463472 }
464473 Ok ( ( ) )
465474}
@@ -568,7 +577,7 @@ fn output_unknown_lints(
568577 ) ;
569578 }
570579
571- gctx. shell ( ) . print_report ( & report) ?;
580+ gctx. shell ( ) . print_report ( & report, lint_level . force ( ) ) ?;
572581 }
573582
574583 Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -1932,7 +1932,7 @@ fn missing_dep_diagnostic(
19321932 group. element ( snippet)
19331933 } ;
19341934
1935- if let Err ( err) = gctx. shell ( ) . print_report ( & [ group] ) {
1935+ if let Err ( err) = gctx. shell ( ) . print_report ( & [ group] , true ) {
19361936 return Err ( err. into ( ) ) ;
19371937 }
19381938 Err ( AlreadyPrintedError :: new ( anyhow ! ( "" ) . into ( ) ) . into ( ) )
@@ -2800,7 +2800,7 @@ fn emit_diagnostic(
28002800 . annotation ( AnnotationKind :: Primary . span ( span) ) ,
28012801 ) ;
28022802
2803- if let Err ( err) = gctx. shell ( ) . print_report ( & [ group] ) {
2803+ if let Err ( err) = gctx. shell ( ) . print_report ( & [ group] , true ) {
28042804 return err. into ( ) ;
28052805 }
28062806 return AlreadyPrintedError :: new ( e. into ( ) ) . into ( ) ;
You can’t perform that action at this time.
0 commit comments