Skip to content

Commit

Permalink
Simplify future breakage control flow.
Browse files Browse the repository at this point in the history
`emit_future_breakage` calls
`self.dcx().take_future_breakage_diagnostics()` and then passes the
result to `self.dcx().emit_future_breakage_report(diags)`. This commit
removes the first of these and lets `emit_future_breakage_report` do the
taking.

It also inlines and removes what is left of `emit_future_breakage`,
which has a single call site.
  • Loading branch information
nnethercote committed Feb 2, 2024
1 parent 1558852 commit 6d31ac2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
12 changes: 6 additions & 6 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,10 +1038,6 @@ impl DiagCtxt {
}
}

pub fn take_future_breakage_diagnostics(&self) -> Vec<Diagnostic> {
std::mem::take(&mut self.inner.borrow_mut().future_breakage_diagnostics)
}

pub fn abort_if_errors(&self) {
let mut inner = self.inner.borrow_mut();
inner.emit_stashed_diagnostics();
Expand Down Expand Up @@ -1149,8 +1145,12 @@ impl DiagCtxt {
self.inner.borrow_mut().emitter.emit_artifact_notification(path, artifact_type);
}

pub fn emit_future_breakage_report(&self, diags: Vec<Diagnostic>) {
self.inner.borrow_mut().emitter.emit_future_breakage_report(diags)
pub fn emit_future_breakage_report(&self) {
let mut inner = self.inner.borrow_mut();
let diags = std::mem::take(&mut inner.future_breakage_diagnostics);
if !diags.is_empty() {
inner.emitter.emit_future_breakage_report(diags);
}
}

pub fn emit_unused_externs(
Expand Down
14 changes: 2 additions & 12 deletions compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,19 +288,9 @@ impl Session {
pub fn finish_diagnostics(&self, registry: &Registry) {
self.check_miri_unleashed_features();
self.dcx().print_error_count(registry);
self.emit_future_breakage();
}

fn emit_future_breakage(&self) {
if !self.opts.json_future_incompat {
return;
}

let diags = self.dcx().take_future_breakage_diagnostics();
if diags.is_empty() {
return;
if self.opts.json_future_incompat {
self.dcx().emit_future_breakage_report();
}
self.dcx().emit_future_breakage_report(diags);
}

/// Returns true if the crate is a testing one.
Expand Down

0 comments on commit 6d31ac2

Please sign in to comment.