Skip to content

Commit 53dbc6b

Browse files
committed
Fix up forward! decls.
- Move comments onto corresponding `Diagnostic` methods. - Make formatting more consistent.
1 parent b3367a0 commit 53dbc6b

File tree

2 files changed

+16
-32
lines changed

2 files changed

+16
-32
lines changed

compiler/rustc_errors/src/diagnostic.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,18 @@ impl Diagnostic {
320320
self.level = Level::DelayedBug;
321321
}
322322

323-
/// Adds a span/label to be included in the resulting snippet.
323+
/// Appends a labeled span to the diagnostic.
324324
///
325-
/// This is pushed onto the [`MultiSpan`] that was created when the diagnostic
326-
/// was first built. That means it will be shown together with the original
327-
/// span/label, *not* a span added by one of the `span_{note,warn,help,suggestions}` methods.
325+
/// Labels are used to convey additional context for the diagnostic's primary span. They will
326+
/// be shown together with the original diagnostic's span, *not* with spans added by
327+
/// `span_note`, `span_help`, etc. Therefore, if the primary span is not displayable (because
328+
/// the span is `DUMMY_SP` or the source code isn't found), labels will not be displayed
329+
/// either.
328330
///
329-
/// This span is *not* considered a ["primary span"][`MultiSpan`]; only
330-
/// the `Span` supplied when creating the diagnostic is primary.
331+
/// Implementation-wise, the label span is pushed onto the [`MultiSpan`] that was created when
332+
/// the diagnostic was constructed. However, the label span is *not* considered a
333+
/// ["primary span"][`MultiSpan`]; only the `Span` supplied when creating the diagnostic is
334+
/// primary.
331335
#[rustc_lint_diagnostics]
332336
pub fn span_label(&mut self, span: Span, label: impl Into<SubdiagnosticMessage>) -> &mut Self {
333337
self.span.push_span_label(span, self.subdiagnostic_message_to_diagnostic_message(label));

compiler/rustc_errors/src/diagnostic_builder.rs

+6-26
Original file line numberDiff line numberDiff line change
@@ -356,38 +356,23 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
356356
self.emit()
357357
}
358358

359-
forward!(
360-
/// Appends a labeled span to the diagnostic.
361-
///
362-
/// Labels are used to convey additional context for the diagnostic's primary span. They will
363-
/// be shown together with the original diagnostic's span, *not* with spans added by
364-
/// `span_note`, `span_help`, etc. Therefore, if the primary span is not displayable (because
365-
/// the span is `DUMMY_SP` or the source code isn't found), labels will not be displayed
366-
/// either.
367-
///
368-
/// Implementation-wise, the label span is pushed onto the [`MultiSpan`] that was created when
369-
/// the diagnostic was constructed. However, the label span is *not* considered a
370-
/// ["primary span"][`MultiSpan`]; only the `Span` supplied when creating the diagnostic is
371-
/// primary.
372-
pub fn span_label(&mut self, span: Span, label: impl Into<SubdiagnosticMessage>) -> &mut Self);
373-
374-
forward!(
375-
/// Labels all the given spans with the provided label.
376-
/// See [`Diagnostic::span_label()`] for more information.
377-
pub fn span_labels(
359+
forward!(pub fn span_label(
360+
&mut self,
361+
span: Span,
362+
label: impl Into<SubdiagnosticMessage>
363+
) -> &mut Self);
364+
forward!(pub fn span_labels(
378365
&mut self,
379366
spans: impl IntoIterator<Item = Span>,
380367
label: &str,
381368
) -> &mut Self);
382-
383369
forward!(pub fn note_expected_found(
384370
&mut self,
385371
expected_label: &dyn fmt::Display,
386372
expected: DiagnosticStyledString,
387373
found_label: &dyn fmt::Display,
388374
found: DiagnosticStyledString,
389375
) -> &mut Self);
390-
391376
forward!(pub fn note_expected_found_extra(
392377
&mut self,
393378
expected_label: &dyn fmt::Display,
@@ -397,7 +382,6 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
397382
expected_extra: &dyn fmt::Display,
398383
found_extra: &dyn fmt::Display,
399384
) -> &mut Self);
400-
401385
forward!(pub fn note(&mut self, msg: impl Into<SubdiagnosticMessage>) -> &mut Self);
402386
forward!(pub fn note_once(&mut self, msg: impl Into<SubdiagnosticMessage>) -> &mut Self);
403387
forward!(pub fn span_note(
@@ -424,9 +408,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
424408
msg: impl Into<SubdiagnosticMessage>,
425409
) -> &mut Self);
426410
forward!(pub fn is_lint(&mut self,) -> &mut Self);
427-
428411
forward!(pub fn disable_suggestions(&mut self,) -> &mut Self);
429-
430412
forward!(pub fn multipart_suggestion(
431413
&mut self,
432414
msg: impl Into<SubdiagnosticMessage>,
@@ -493,7 +475,6 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
493475
suggestion: impl ToString,
494476
applicability: Applicability,
495477
) -> &mut Self);
496-
497478
forward!(pub fn primary_message(&mut self, msg: impl Into<DiagnosticMessage>) -> &mut Self);
498479
forward!(pub fn span(&mut self, sp: impl Into<MultiSpan>) -> &mut Self);
499480
forward!(pub fn code(&mut self, s: DiagnosticId) -> &mut Self);
@@ -502,7 +483,6 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
502483
name: impl Into<Cow<'static, str>>,
503484
arg: impl IntoDiagnosticArg,
504485
) -> &mut Self);
505-
506486
forward!(pub fn subdiagnostic(
507487
&mut self,
508488
subdiagnostic: impl crate::AddToDiagnostic

0 commit comments

Comments
 (0)