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 {
404
404
}
405
405
406
406
/// 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
+
408
412
if self . needs_clear {
409
413
self . err_erase_line ( ) ;
410
414
}
Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ fn verify_feature_enabled(
171
171
}
172
172
173
173
* error_count += 1 ;
174
- gctx. shell ( ) . print_report ( & report) ?;
174
+ gctx. shell ( ) . print_report ( & report, true ) ?;
175
175
}
176
176
Ok ( ( ) )
177
177
}
@@ -339,6 +339,15 @@ impl LintLevel {
339
339
LintLevel :: Forbid => Level :: ERROR ,
340
340
}
341
341
}
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
+ }
342
351
}
343
352
344
353
impl From < TomlLintLevel > for LintLevel {
@@ -459,7 +468,7 @@ pub fn check_im_a_teapot(
459
468
)
460
469
. element ( Level :: NOTE . message ( & emitted_reason) ) ] ;
461
470
462
- gctx. shell ( ) . print_report ( report) ?;
471
+ gctx. shell ( ) . print_report ( report, lint_level . force ( ) ) ?;
463
472
}
464
473
Ok ( ( ) )
465
474
}
@@ -568,7 +577,7 @@ fn output_unknown_lints(
568
577
) ;
569
578
}
570
579
571
- gctx. shell ( ) . print_report ( & report) ?;
580
+ gctx. shell ( ) . print_report ( & report, lint_level . force ( ) ) ?;
572
581
}
573
582
574
583
Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -1932,7 +1932,7 @@ fn missing_dep_diagnostic(
1932
1932
group. element ( snippet)
1933
1933
} ;
1934
1934
1935
- if let Err ( err) = gctx. shell ( ) . print_report ( & [ group] ) {
1935
+ if let Err ( err) = gctx. shell ( ) . print_report ( & [ group] , true ) {
1936
1936
return Err ( err. into ( ) ) ;
1937
1937
}
1938
1938
Err ( AlreadyPrintedError :: new ( anyhow ! ( "" ) . into ( ) ) . into ( ) )
@@ -2800,7 +2800,7 @@ fn emit_diagnostic(
2800
2800
. annotation ( AnnotationKind :: Primary . span ( span) ) ,
2801
2801
) ;
2802
2802
2803
- if let Err ( err) = gctx. shell ( ) . print_report ( & [ group] ) {
2803
+ if let Err ( err) = gctx. shell ( ) . print_report ( & [ group] , true ) {
2804
2804
return err. into ( ) ;
2805
2805
}
2806
2806
return AlreadyPrintedError :: new ( e. into ( ) ) . into ( ) ;
You can’t perform that action at this time.
0 commit comments