Struct proc_macro_error::single::MacroError

source ·
pub struct MacroError { /* private fields */ }
Expand description

An single error message in a proc macro with span info attached.

Implementations§

source§

impl MacroError

source

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

Create an error with the span and message provided.

source

pub fn call_site(msg: String) -> Self

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

source

pub fn set_message(&mut self, msg: String) -> String

Replace the error message with msg. Returns old message.

source

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

Replace the span info with span. Returns old span.

source

pub fn span(&self) -> Span

Get the span contained.

source

pub fn abort(self) -> !

Abort the proc-macro’s execution and show the error.

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

Trait Implementations§

source§

impl AsMut<String> for MacroError

source§

fn as_mut(&mut self) -> &mut String

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsRef<String> for MacroError

source§

fn as_ref(&self) -> &String

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Debug for MacroError

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for MacroError

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<&str> for MacroError

source§

fn from(msg: &str) -> Self

Converts to this type from the input type.
source§

impl From<Error> for MacroError

source§

fn from(e: Error) -> Self

Converts to this type from the input type.
source§

impl From<String> for MacroError

source§

fn from(msg: String) -> Self

Converts to this type from the input type.
source§

impl ToTokens for MacroError

source§

fn to_tokens(&self, ts: &mut TokenStream)

Write self to the given TokenStream. Read more
source§

fn to_token_stream(&self) -> TokenStream

Convert self directly into a TokenStream object. Read more
source§

fn into_token_stream(self) -> TokenStream
where Self: Sized,

Convert self directly into a TokenStream object. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Spanned for T
where T: Spanned + ?Sized,

source§

fn span(&self) -> Span

Returns a Span covering the complete contents of this syntax tree node, or Span::call_site() if this node is empty.
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.