From edb39c0d208ef7850116bd3c931df091730c0e7f Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 11 Aug 2020 09:42:25 +0200 Subject: [PATCH] attempt to improve span_label docs --- src/librustc_errors/diagnostic.rs | 15 ++++++++------- src/librustc_errors/diagnostic_builder.rs | 14 +++++++++----- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs index acaa26c6ad2fc..d0ad5a06e982e 100644 --- a/src/librustc_errors/diagnostic.rs +++ b/src/librustc_errors/diagnostic.rs @@ -127,14 +127,15 @@ impl Diagnostic { } /// Adds a span/label to be included in the resulting snippet. - /// This label will be shown together with the original span/label used when creating the - /// diagnostic, *not* a span added by one of the `span_*` methods. /// - /// This is pushed onto the `MultiSpan` that was created when the - /// diagnostic was first built. If you don't call this function at - /// all, and you just supplied a `Span` to create the diagnostic, - /// then the snippet will just include that `Span`, which is - /// called the primary span. + /// This is pushed onto the [`MultiSpan`] that was created when the diagnostic + /// was first built. That means it will be shown together with the original + /// span/label, *not* a span added by one of the `span_{note,warn,help,suggestions}` methods. + /// + /// This span is *not* considered a ["primary span"][`MultiSpan`]; only + /// the `Span` supplied when creating the diagnostic is primary. + /// + /// [`MultiSpan`]: ../rustc_span/struct.MultiSpan.html pub fn span_label>(&mut self, span: Span, label: T) -> &mut Self { self.span.push_span_label(span, label.into()); self diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs index 22bf8fe34aa15..b8a6dd73952dc 100644 --- a/src/librustc_errors/diagnostic_builder.rs +++ b/src/librustc_errors/diagnostic_builder.rs @@ -184,11 +184,15 @@ impl<'a> DiagnosticBuilder<'a> { } /// Adds a span/label to be included in the resulting snippet. - /// This is pushed onto the `MultiSpan` that was created when the - /// diagnostic was first built. If you don't call this function at - /// all, and you just supplied a `Span` to create the diagnostic, - /// then the snippet will just include that `Span`, which is - /// called the primary span. + /// + /// This is pushed onto the [`MultiSpan`] that was created when the diagnostic + /// was first built. That means it will be shown together with the original + /// span/label, *not* a span added by one of the `span_{note,warn,help,suggestions}` methods. + /// + /// This span is *not* considered a ["primary span"][`MultiSpan`]; only + /// the `Span` supplied when creating the diagnostic is primary. + /// + /// [`MultiSpan`]: ../rustc_span/struct.MultiSpan.html pub fn span_label(&mut self, span: Span, label: impl Into) -> &mut Self { self.0.diagnostic.span_label(span, label); self