Trait devise_core::ext::SpanDiagnosticExt

source ·
pub trait SpanDiagnosticExt {
    // Required methods
    fn error<T>(self, message: T) -> Diagnostic
       where T: Into<String>;
    fn warning<T>(self, message: T) -> Diagnostic
       where T: Into<String>;
    fn note<T>(self, message: T) -> Diagnostic
       where T: Into<String>;
    fn help<T>(self, message: T) -> Diagnostic
       where T: Into<String>;
}
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§

source

fn error<T>(self, message: T) -> Diagnostic
where T: Into<String>,

Create a new Diagnostic of the kind of this method’s name with the span self.

source

fn warning<T>(self, message: T) -> Diagnostic
where T: Into<String>,

Create a new Diagnostic of the kind of this method’s name with the span self.

source

fn note<T>(self, message: T) -> Diagnostic
where T: Into<String>,

Create a new Diagnostic of the kind of this method’s name with the span self.

source

fn help<T>(self, message: T) -> Diagnostic
where T: Into<String>,

Create a new Diagnostic of the kind of this method’s name with the span self.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl SpanDiagnosticExt for Span

source§

fn error<T>(self, message: T) -> Diagnostic
where T: Into<String>,

source§

fn warning<T>(self, message: T) -> Diagnostic
where T: Into<String>,

source§

fn note<T>(self, message: T) -> Diagnostic
where T: Into<String>,

source§

fn help<T>(self, message: T) -> Diagnostic
where T: Into<String>,

Implementors§