]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_metadata/src/creader.rs
Add --json unused-externs-silent with original behaviour
[rust.git] / compiler / rustc_metadata / src / creader.rs
index e8cdae7fd25ceb742492882fac8360b08774931a..3c545e6a0d2404f040c0f405bdc05b265a731f07 100644 (file)
@@ -195,10 +195,12 @@ fn crate_dependencies_in_reverse_postorder(&self, cnum: CrateNum) -> Vec<CrateNu
     }
 
     pub fn report_unused_deps(&self, tcx: TyCtxt<'_>) {
+        let json_unused_externs = tcx.sess.opts.json_unused_externs;
+
         // We put the check for the option before the lint_level_at_node call
         // because the call mutates internal state and introducing it
         // leads to some ui tests failing.
-        if !tcx.sess.opts.json_unused_externs {
+        if !json_unused_externs.is_enabled() {
             return;
         }
         let level = tcx
@@ -208,10 +210,11 @@ pub fn report_unused_deps(&self, tcx: TyCtxt<'_>) {
             let unused_externs =
                 self.unused_externs.iter().map(|ident| ident.to_ident_string()).collect::<Vec<_>>();
             let unused_externs = unused_externs.iter().map(String::as_str).collect::<Vec<&str>>();
-            tcx.sess
-                .parse_sess
-                .span_diagnostic
-                .emit_unused_externs(level.as_str(), &unused_externs);
+            tcx.sess.parse_sess.span_diagnostic.emit_unused_externs(
+                level,
+                json_unused_externs.is_loud(),
+                &unused_externs,
+            );
         }
     }
 }
@@ -917,7 +920,7 @@ fn report_unused_deps(&mut self, krate: &ast::Crate) {
             }
 
             // Got a real unused --extern
-            if self.sess.opts.json_unused_externs {
+            if self.sess.opts.json_unused_externs.is_enabled() {
                 self.cstore.unused_externs.push(name_interned);
                 continue;
             }