[][src]Struct proc_macro_error::single::MacroError

pub struct MacroError { /* fields omitted */ }

An single error in a proc-macro. This struct preserves the given span so rustc can highlight the exact place in user code responsible for the error.

You're not supposed to use this type directly, use span_error! and call_site_error!.

Methods

impl MacroError[src]

pub fn new(span: Span, msg: String) -> Self[src]

Create an error with the span and message provided.

pub fn call_site(msg: String) -> Self[src]

A shortcut for MacroError::new(Span::call_site(), message)

pub fn into_compile_error(self) -> TokenStream[src]

Convert this error into a TokenStream containing these tokens: compiler_error!(<message>);. All these tokens carry the span this error contains attached.

There are From<[MacroError]> for proc_macro/proc_macro2::TokenStream implementations so you can use error.into() instead of this method.

pub fn set_span(&mut self, span: Span)[src]

Abandon the old span and replace it with the given one.

pub fn span(&self) -> Span[src]

Get the span contained.

pub fn trigger(self) -> ![src]

Trigger single error, aborting the proc-macro's execution.

You're not supposed to use this function directly. Use span_error! or call_site_error! instead.

Trait Implementations

impl From<Error> for MacroError[src]

impl From<String> for MacroError[src]

impl<'_> From<&'_ str> for MacroError[src]

impl From<MacroError> for TokenStream[src]

impl From<MacroError> for TokenStream[src]

impl AsMut<String> for MacroError[src]

impl AsRef<String> for MacroError[src]

impl Display for MacroError[src]

impl Debug for MacroError[src]

impl FromIterator<MacroError> for MultiMacroErrors[src]

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]