diff options
| author | Andy Russell <arussell123@gmail.com> | 2020-11-15 22:39:51 -0500 |
|---|---|---|
| committer | Andy Russell <arussell123@gmail.com> | 2020-11-16 18:05:45 -0500 |
| commit | a78966df830c7be793823c7e5ba32c3cacad26e3 (patch) | |
| tree | 2174dcf6017ca135e431b995836967436b23090f /compiler/rustc_errors/src | |
| parent | 603ab5bd6e0ffefafa7411cd8bd23a6ca82bcff0 (diff) | |
| download | rust-a78966df830c7be793823c7e5ba32c3cacad26e3.tar.gz rust-a78966df830c7be793823c7e5ba32c3cacad26e3.zip | |
clarify `span_label` documentation
Diffstat (limited to 'compiler/rustc_errors/src')
| -rw-r--r-- | compiler/rustc_errors/src/diagnostic_builder.rs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/compiler/rustc_errors/src/diagnostic_builder.rs b/compiler/rustc_errors/src/diagnostic_builder.rs index 56acdf699ef..c9259a1502c 100644 --- a/compiler/rustc_errors/src/diagnostic_builder.rs +++ b/compiler/rustc_errors/src/diagnostic_builder.rs @@ -184,16 +184,18 @@ impl<'a> DiagnosticBuilder<'a> { self.cancel(); } - /// Adds a span/label to be included in the resulting snippet. + /// Appends a labeled span to the diagnostic. /// - /// 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. + /// Labels are used to convey additional context for the diagnostic's primary span. They will + /// be shown together with the original diagnostic's span, *not* with spans added by + /// `span_note`, `span_help`, etc. Therefore, if the primary span is not displayable (because + /// the span is `DUMMY_SP` or the source code isn't found), labels will not be displayed + /// either. /// - /// 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 + /// Implementation-wise, the label span is pushed onto the [`MultiSpan`] that was created when + /// the diagnostic was constructed. However, the label span is *not* considered a + /// ["primary span"][`MultiSpan`]; only the `Span` supplied when creating the diagnostic is + /// primary. pub fn span_label(&mut self, span: Span, label: impl Into<String>) -> &mut Self { self.0.diagnostic.span_label(span, label); self |
