Skip to content

Commit edb39c0

Browse files
committed
attempt to improve span_label docs
1 parent a9025c5 commit edb39c0

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

src/librustc_errors/diagnostic.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,15 @@ impl Diagnostic {
127127
}
128128

129129
/// Adds a span/label to be included in the resulting snippet.
130-
/// This label will be shown together with the original span/label used when creating the
131-
/// diagnostic, *not* a span added by one of the `span_*` methods.
132130
///
133-
/// This is pushed onto the `MultiSpan` that was created when the
134-
/// diagnostic was first built. If you don't call this function at
135-
/// all, and you just supplied a `Span` to create the diagnostic,
136-
/// then the snippet will just include that `Span`, which is
137-
/// called the primary span.
131+
/// This is pushed onto the [`MultiSpan`] that was created when the diagnostic
132+
/// was first built. That means it will be shown together with the original
133+
/// span/label, *not* a span added by one of the `span_{note,warn,help,suggestions}` methods.
134+
///
135+
/// This span is *not* considered a ["primary span"][`MultiSpan`]; only
136+
/// the `Span` supplied when creating the diagnostic is primary.
137+
///
138+
/// [`MultiSpan`]: ../rustc_span/struct.MultiSpan.html
138139
pub fn span_label<T: Into<String>>(&mut self, span: Span, label: T) -> &mut Self {
139140
self.span.push_span_label(span, label.into());
140141
self

src/librustc_errors/diagnostic_builder.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,15 @@ impl<'a> DiagnosticBuilder<'a> {
184184
}
185185

186186
/// Adds a span/label to be included in the resulting snippet.
187-
/// This is pushed onto the `MultiSpan` that was created when the
188-
/// diagnostic was first built. If you don't call this function at
189-
/// all, and you just supplied a `Span` to create the diagnostic,
190-
/// then the snippet will just include that `Span`, which is
191-
/// called the primary span.
187+
///
188+
/// This is pushed onto the [`MultiSpan`] that was created when the diagnostic
189+
/// was first built. That means it will be shown together with the original
190+
/// span/label, *not* a span added by one of the `span_{note,warn,help,suggestions}` methods.
191+
///
192+
/// This span is *not* considered a ["primary span"][`MultiSpan`]; only
193+
/// the `Span` supplied when creating the diagnostic is primary.
194+
///
195+
/// [`MultiSpan`]: ../rustc_span/struct.MultiSpan.html
192196
pub fn span_label(&mut self, span: Span, label: impl Into<String>) -> &mut Self {
193197
self.0.diagnostic.span_label(span, label);
194198
self

0 commit comments

Comments
 (0)