diff options
| author | bors <bors@rust-lang.org> | 2022-04-28 04:17:52 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-04-28 04:17:52 +0000 |
| commit | 0e7915d11f6888f005e78c2358fcdc48ff655753 (patch) | |
| tree | b5df5a22a17acee9c13ce2a0e469704539dd0850 /compiler/rustc_errors/src | |
| parent | 81799cd8fd841e23b52876ae5e22faeb3ad04eb5 (diff) | |
| parent | c6bafa7322943643f37f8818bcb16dad28f53d26 (diff) | |
| download | rust-0e7915d11f6888f005e78c2358fcdc48ff655753.tar.gz rust-0e7915d11f6888f005e78c2358fcdc48ff655753.zip | |
Auto merge of #96085 - jsgf:deny-unused-deps, r=compiler-errors
Make sure `-Dunused-crate-dependencies --json unused-externs` makes rustc exit with error status This PR: - fixes compiletest to understand unused extern notifications - adds tests for `--json unused-externs` - makes sure that deny-level unused externs notifications are treated as compile errors - refactors the `emit_unused_externs` callstack to plumb through the level as an enum as a string, and adds `Level::is_error` Update: adds `--json unused-externs-silent` with the original behaviour since Cargo needs it. Should address `@est31's` concerns. Fixes: https://github.com/rust-lang/rust/issues/96068
Diffstat (limited to 'compiler/rustc_errors/src')
| -rw-r--r-- | compiler/rustc_errors/src/emitter.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/json.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/lib.rs | 17 |
3 files changed, 22 insertions, 5 deletions
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 47cdf39cd52..5dd743e8d00 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -212,7 +212,12 @@ pub trait Emitter { fn emit_future_breakage_report(&mut self, _diags: Vec<Diagnostic>) {} /// Emit list of unused externs - fn emit_unused_externs(&mut self, _lint_level: &str, _unused_externs: &[&str]) {} + fn emit_unused_externs( + &mut self, + _lint_level: rustc_lint_defs::Level, + _unused_externs: &[&str], + ) { + } /// Checks if should show explanations about "rustc --explain" fn should_show_explain(&self) -> bool { diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs index d680e7fab70..6ff52182d6b 100644 --- a/compiler/rustc_errors/src/json.rs +++ b/compiler/rustc_errors/src/json.rs @@ -171,7 +171,8 @@ impl Emitter for JsonEmitter { } } - fn emit_unused_externs(&mut self, lint_level: &str, unused_externs: &[&str]) { + fn emit_unused_externs(&mut self, lint_level: rustc_lint_defs::Level, unused_externs: &[&str]) { + let lint_level = lint_level.as_str(); let data = UnusedExterns { lint_level, unused_extern_names: unused_externs }; let result = if self.pretty { writeln!(&mut self.dst, "{}", as_pretty_json(&data)) diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 4e6ab0edf66..a64133bb7f4 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -969,8 +969,19 @@ impl Handler { self.inner.borrow_mut().emitter.emit_future_breakage_report(diags) } - pub fn emit_unused_externs(&self, lint_level: &str, unused_externs: &[&str]) { - self.inner.borrow_mut().emit_unused_externs(lint_level, unused_externs) + pub fn emit_unused_externs( + &self, + lint_level: rustc_lint_defs::Level, + loud: bool, + unused_externs: &[&str], + ) { + let mut inner = self.inner.borrow_mut(); + + if loud && lint_level.is_error() { + inner.bump_err_count(); + } + + inner.emit_unused_externs(lint_level, unused_externs) } pub fn update_unstable_expectation_id( @@ -1141,7 +1152,7 @@ impl HandlerInner { self.emitter.emit_artifact_notification(path, artifact_type); } - fn emit_unused_externs(&mut self, lint_level: &str, unused_externs: &[&str]) { + fn emit_unused_externs(&mut self, lint_level: rustc_lint_defs::Level, unused_externs: &[&str]) { self.emitter.emit_unused_externs(lint_level, unused_externs); } |
