Edit docs for rustc_errors::Handler::stash_diagnostic

Clarify that the diagnostic can be retrieved with `steal_diagnostic`.
This commit is contained in:
pierwill 2022-11-16 12:21:15 -06:00
parent 63c748ee23
commit 19b63bc791

View File

@ -644,13 +644,14 @@ impl Handler {
inner.stashed_diagnostics = Default::default(); 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) { pub fn stash_diagnostic(&self, span: Span, key: StashKey, diag: Diagnostic) {
let mut inner = self.inner.borrow_mut(); let mut inner = self.inner.borrow_mut();
inner.stash((span, key), diag); 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<'_, ()>> { pub fn steal_diagnostic(&self, span: Span, key: StashKey) -> Option<DiagnosticBuilder<'_, ()>> {
let mut inner = self.inner.borrow_mut(); let mut inner = self.inner.borrow_mut();
inner.steal((span, key)).map(|diag| DiagnosticBuilder::new_diagnostic(self, diag)) inner.steal((span, key)).map(|diag| DiagnosticBuilder::new_diagnostic(self, diag))