Trait proc_macro_error::DiagnosticExt
source · pub trait DiagnosticExt: Sealed {
// Required methods
fn spanned_range(
span_range: SpanRange,
level: Level,
message: String,
) -> Self;
fn span_range_error(self, span_range: SpanRange, msg: String) -> Self;
fn span_range_help(self, span_range: SpanRange, msg: String) -> Self;
fn span_range_note(self, span_range: SpanRange, msg: String) -> Self;
}
Expand description
A collection of methods that do not exist in proc_macro::Diagnostic
but still useful to have around.
This trait is sealed and cannot be implemented outside of proc_macro_error
.
Required Methods§
sourcefn spanned_range(span_range: SpanRange, level: Level, message: String) -> Self
fn spanned_range(span_range: SpanRange, level: Level, message: String) -> Self
Create a new diagnostic message that points to the span_range
.
This function is the same as Diagnostic::spanned
but produces considerably
better error messages for multi-token spans on stable.
sourcefn span_range_error(self, span_range: SpanRange, msg: String) -> Self
fn span_range_error(self, span_range: SpanRange, msg: String) -> Self
Add another error message to self such that it will be emitted right after the main message.
This function is the same as Diagnostic::span_error
but produces considerably
better error messages for multi-token spans on stable.
sourcefn span_range_help(self, span_range: SpanRange, msg: String) -> Self
fn span_range_help(self, span_range: SpanRange, msg: String) -> Self
Attach a “help” note to your main message, the note will have it’s own span on nightly.
This function is the same as Diagnostic::span_help
but produces considerably
better error messages for multi-token spans on stable.
§Span
The span is ignored on stable, the note effectively inherits its parent’s (main message) span
sourcefn span_range_note(self, span_range: SpanRange, msg: String) -> Self
fn span_range_note(self, span_range: SpanRange, msg: String) -> Self
Attach a note to your main message, the note will have it’s own span on nightly.
This function is the same as Diagnostic::span_note
but produces considerably
better error messages for multi-token spans on stable.
§Span
The span is ignored on stable, the note effectively inherits its parent’s (main message) span