Fix up forward!
decls.
- Move comments onto corresponding `Diagnostic` methods. - Make formatting more consistent.
This commit is contained in:
parent
096b844a2b
commit
caefa55347
2 changed files with 16 additions and 32 deletions
|
@ -320,14 +320,18 @@ impl Diagnostic {
|
||||||
self.level = Level::DelayedBug;
|
self.level = Level::DelayedBug;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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
|
/// Labels are used to convey additional context for the diagnostic's primary span. They will
|
||||||
/// was first built. That means it will be shown together with the original
|
/// be shown together with the original diagnostic's span, *not* with spans added by
|
||||||
/// span/label, *not* a span added by one of the `span_{note,warn,help,suggestions}` methods.
|
/// `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
|
/// Implementation-wise, the label span is pushed onto the [`MultiSpan`] that was created when
|
||||||
/// the `Span` supplied when creating the diagnostic is primary.
|
/// 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.
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
pub fn span_label(&mut self, span: Span, label: impl Into<SubdiagnosticMessage>) -> &mut Self {
|
pub fn span_label(&mut self, span: Span, label: impl Into<SubdiagnosticMessage>) -> &mut Self {
|
||||||
self.span.push_span_label(span, self.subdiagnostic_message_to_diagnostic_message(label));
|
self.span.push_span_label(span, self.subdiagnostic_message_to_diagnostic_message(label));
|
||||||
|
|
|
@ -356,30 +356,16 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
||||||
self.emit()
|
self.emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
forward!(
|
forward!(pub fn span_label(
|
||||||
/// Appends a labeled span to the diagnostic.
|
&mut self,
|
||||||
///
|
span: Span,
|
||||||
/// Labels are used to convey additional context for the diagnostic's primary span. They will
|
label: impl Into<SubdiagnosticMessage>
|
||||||
/// be shown together with the original diagnostic's span, *not* with spans added by
|
) -> &mut Self);
|
||||||
/// `span_note`, `span_help`, etc. Therefore, if the primary span is not displayable (because
|
forward!(pub fn span_labels(
|
||||||
/// the span is `DUMMY_SP` or the source code isn't found), labels will not be displayed
|
|
||||||
/// either.
|
|
||||||
///
|
|
||||||
/// 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<SubdiagnosticMessage>) -> &mut Self);
|
|
||||||
|
|
||||||
forward!(
|
|
||||||
/// Labels all the given spans with the provided label.
|
|
||||||
/// See [`Diagnostic::span_label()`] for more information.
|
|
||||||
pub fn span_labels(
|
|
||||||
&mut self,
|
&mut self,
|
||||||
spans: impl IntoIterator<Item = Span>,
|
spans: impl IntoIterator<Item = Span>,
|
||||||
label: &str,
|
label: &str,
|
||||||
) -> &mut Self);
|
) -> &mut Self);
|
||||||
|
|
||||||
forward!(pub fn note_expected_found(
|
forward!(pub fn note_expected_found(
|
||||||
&mut self,
|
&mut self,
|
||||||
expected_label: &dyn fmt::Display,
|
expected_label: &dyn fmt::Display,
|
||||||
|
@ -387,7 +373,6 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
||||||
found_label: &dyn fmt::Display,
|
found_label: &dyn fmt::Display,
|
||||||
found: DiagnosticStyledString,
|
found: DiagnosticStyledString,
|
||||||
) -> &mut Self);
|
) -> &mut Self);
|
||||||
|
|
||||||
forward!(pub fn note_expected_found_extra(
|
forward!(pub fn note_expected_found_extra(
|
||||||
&mut self,
|
&mut self,
|
||||||
expected_label: &dyn fmt::Display,
|
expected_label: &dyn fmt::Display,
|
||||||
|
@ -397,7 +382,6 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
||||||
expected_extra: &dyn fmt::Display,
|
expected_extra: &dyn fmt::Display,
|
||||||
found_extra: &dyn fmt::Display,
|
found_extra: &dyn fmt::Display,
|
||||||
) -> &mut Self);
|
) -> &mut Self);
|
||||||
|
|
||||||
forward!(pub fn note(&mut self, msg: impl Into<SubdiagnosticMessage>) -> &mut Self);
|
forward!(pub fn note(&mut self, msg: impl Into<SubdiagnosticMessage>) -> &mut Self);
|
||||||
forward!(pub fn note_once(&mut self, msg: impl Into<SubdiagnosticMessage>) -> &mut Self);
|
forward!(pub fn note_once(&mut self, msg: impl Into<SubdiagnosticMessage>) -> &mut Self);
|
||||||
forward!(pub fn span_note(
|
forward!(pub fn span_note(
|
||||||
|
@ -424,9 +408,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
) -> &mut Self);
|
) -> &mut Self);
|
||||||
forward!(pub fn is_lint(&mut self,) -> &mut Self);
|
forward!(pub fn is_lint(&mut self,) -> &mut Self);
|
||||||
|
|
||||||
forward!(pub fn disable_suggestions(&mut self,) -> &mut Self);
|
forward!(pub fn disable_suggestions(&mut self,) -> &mut Self);
|
||||||
|
|
||||||
forward!(pub fn multipart_suggestion(
|
forward!(pub fn multipart_suggestion(
|
||||||
&mut self,
|
&mut self,
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
|
@ -493,7 +475,6 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
||||||
suggestion: impl ToString,
|
suggestion: impl ToString,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
) -> &mut Self);
|
) -> &mut Self);
|
||||||
|
|
||||||
forward!(pub fn primary_message(&mut self, msg: impl Into<DiagnosticMessage>) -> &mut Self);
|
forward!(pub fn primary_message(&mut self, msg: impl Into<DiagnosticMessage>) -> &mut Self);
|
||||||
forward!(pub fn span(&mut self, sp: impl Into<MultiSpan>) -> &mut Self);
|
forward!(pub fn span(&mut self, sp: impl Into<MultiSpan>) -> &mut Self);
|
||||||
forward!(pub fn code(&mut self, s: DiagnosticId) -> &mut Self);
|
forward!(pub fn code(&mut self, s: DiagnosticId) -> &mut Self);
|
||||||
|
@ -502,7 +483,6 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
||||||
name: impl Into<Cow<'static, str>>,
|
name: impl Into<Cow<'static, str>>,
|
||||||
arg: impl IntoDiagnosticArg,
|
arg: impl IntoDiagnosticArg,
|
||||||
) -> &mut Self);
|
) -> &mut Self);
|
||||||
|
|
||||||
forward!(pub fn subdiagnostic(
|
forward!(pub fn subdiagnostic(
|
||||||
&mut self,
|
&mut self,
|
||||||
subdiagnostic: impl crate::AddToDiagnostic
|
subdiagnostic: impl crate::AddToDiagnostic
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue