[−][src]Struct proc_macro_error::single::MacroError
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]
fn from(err: MacroError) -> Self
[src]
impl From<MacroError> for TokenStream
[src]
fn from(err: MacroError) -> Self
[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]
fn from_iter<I>(iter: I) -> Self where
I: IntoIterator<Item = MacroError>,
[src]
I: IntoIterator<Item = MacroError>,
Auto Trait Implementations
impl Unpin for MacroError
impl !Send for MacroError
impl !Sync for MacroError
impl UnwindSafe for MacroError
impl !RefUnwindSafe for MacroError
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,