pub trait SpanDiagnosticExt {
// Required methods
fn error<T: Into<String>>(self, message: T) -> Diagnostic;
fn warning<T: Into<String>>(self, message: T) -> Diagnostic;
fn note<T: Into<String>>(self, message: T) -> Diagnostic;
fn help<T: Into<String>>(self, message: T) -> Diagnostic;
}Expand description
Extension trait for proc_macro2::Span emulating the proc-macro diagnostic
API on stable and nightly.
§Example
use proc_macro2::Span;
use proc_macro2_diagnostics::SpanDiagnosticExt;
let span = Span::call_site();
let diag = span.error("there's a problem here...");
// emit into an expression context.
let tokens = diag.emit_as_expr_tokens();
// or emit into an item context.
let tokens = diag.emit_as_item_tokens();Required Methods§
Sourcefn error<T: Into<String>>(self, message: T) -> Diagnostic
fn error<T: Into<String>>(self, message: T) -> Diagnostic
Create a new Diagnostic of the kind of this method’s name with the
span self.
Sourcefn warning<T: Into<String>>(self, message: T) -> Diagnostic
fn warning<T: Into<String>>(self, message: T) -> Diagnostic
Create a new Diagnostic of the kind of this method’s name with the
span self.
Sourcefn note<T: Into<String>>(self, message: T) -> Diagnostic
fn note<T: Into<String>>(self, message: T) -> Diagnostic
Create a new Diagnostic of the kind of this method’s name with the
span self.
Sourcefn help<T: Into<String>>(self, message: T) -> Diagnostic
fn help<T: Into<String>>(self, message: T) -> Diagnostic
Create a new Diagnostic of the kind of this method’s name with the
span self.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.