Skip to content

Commit

Permalink
Rollup merge of rust-lang#104498 - pierwill:stash-diag-docs, r=compil…
Browse files Browse the repository at this point in the history
…er-errors

Edit docs for `rustc_errors::Handler::stash_diagnostic`

Clarify that the diagnostic can be retrieved with `steal_diagnostic`.

r? ``@compiler-errors``
  • Loading branch information
matthiaskrgr authored Nov 17, 2022
2 parents 940a441 + 4edbaef commit 2440c02
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,13 +644,14 @@ impl Handler {
inner.stashed_diagnostics = Default::default();
}

/// Stash a given diagnostic with the given `Span` and `StashKey` as the key for later stealing.
/// Stash a given diagnostic with the given `Span` and [`StashKey`] as the key.
/// Retrieve a stashed diagnostic with [`steal_diagnostic`].
pub fn stash_diagnostic(&self, span: Span, key: StashKey, diag: Diagnostic) {
let mut inner = self.inner.borrow_mut();
inner.stash((span, key), diag);
}

/// Steal a previously stashed diagnostic with the given `Span` and `StashKey` as the key.
/// Steal a previously stashed diagnostic with the given `Span` and [`StashKey`] as the key.
pub fn steal_diagnostic(&self, span: Span, key: StashKey) -> Option<DiagnosticBuilder<'_, ()>> {
let mut inner = self.inner.borrow_mut();
inner.steal((span, key)).map(|diag| DiagnosticBuilder::new_diagnostic(self, diag))
Expand Down

0 comments on commit 2440c02

Please sign in to comment.