Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8ad6a44

Browse files
committedApr 4, 2021
Auto merge of #83855 - Dylan-DPC:rollup-oww62sh, r=Dylan-DPC
Rollup of 8 pull requests Successful merges: - #73945 (Add an unstable --json=unused-externs flag to print unused externs) - #81619 (Implement `SourceIterator` and `InPlaceIterable` for `ResultShunt`) - #82726 (BTree: move blocks around in node.rs) - #83521 (2229: Fix diagnostic issue when using FakeReads in closures) - #83532 (Fix compiletest on FreeBSD) - #83793 (rustdoc: highlight macros more efficiently) - #83809 (Remove unneeded INITIAL_IDS const) - #83827 (cleanup leak after test to make miri happy) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5b0ab79 + b943ea8 commit 8ad6a44

File tree

59 files changed

+577
-312
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+577
-312
lines changed
 

‎compiler/rustc_errors/src/emitter.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ pub trait Emitter {
195195

196196
fn emit_future_breakage_report(&mut self, _diags: Vec<(FutureBreakage, Diagnostic)>) {}
197197

198+
/// Emit list of unused externs
199+
fn emit_unused_externs(&mut self, _lint_level: &str, _unused_externs: &[&str]) {}
200+
198201
/// Checks if should show explanations about "rustc --explain"
199202
fn should_show_explain(&self) -> bool {
200203
true

‎compiler/rustc_errors/src/json.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,19 @@ impl Emitter for JsonEmitter {
159159
}
160160
}
161161

162+
fn emit_unused_externs(&mut self, lint_level: &str, unused_externs: &[&str]) {
163+
let data = UnusedExterns { lint_level, unused_extern_names: unused_externs };
164+
let result = if self.pretty {
165+
writeln!(&mut self.dst, "{}", as_pretty_json(&data))
166+
} else {
167+
writeln!(&mut self.dst, "{}", as_json(&data))
168+
}
169+
.and_then(|_| self.dst.flush());
170+
if let Err(e) = result {
171+
panic!("failed to print unused externs: {:?}", e);
172+
}
173+
}
174+
162175
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
163176
Some(&self.sm)
164177
}
@@ -322,6 +335,18 @@ struct FutureIncompatReport {
322335
future_incompat_report: Vec<FutureBreakageItem>,
323336
}
324337

338+
// NOTE: Keep this in sync with the equivalent structs in rustdoc's
339+
// doctest component (as well as cargo).
340+
// We could unify this struct the one in rustdoc but they have different
341+
// ownership semantics, so doing so would create wasteful allocations.
342+
#[derive(Encodable)]
343+
struct UnusedExterns<'a, 'b, 'c> {
344+
/// The severity level of the unused dependencies lint
345+
lint_level: &'a str,
346+
/// List of unused externs by their names.
347+
unused_extern_names: &'b [&'c str],
348+
}
349+
325350
impl Diagnostic {
326351
fn from_errors_diagnostic(diag: &crate::Diagnostic, je: &JsonEmitter) -> Diagnostic {
327352
let sugg = diag.suggestions.iter().map(|sugg| Diagnostic {

0 commit comments

Comments
 (0)
Please sign in to comment.