[][src]Crate proc_macro_error

Re-exports

pub extern crate proc_macro;
pub extern crate proc_macro2;

Macros

call_site_error

Shortcut for span_error!(Span::call_site(), msg...). This macro is still preferable over plain panic, see Motivation

filter_macro_errors

This macro is supposed to be used at the top level of your proc-macro, the function marked with a #[proc_macro*] attribute. It catches all the errors triggered by span_error!, call_site_error!, and trigger_error. Once caught, it converts it to a proc_macro::TokenStream containing a compile_error! invocation.

span_error

Makes a MacroError instance from provided arguments (panic!-like) and triggers panic in hope it will be caught by filter_macro_errors!.

Structs

MacroError

An 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.

Traits

OptionExt

This traits expands Option<T> with some handy shortcuts.

ResultExt

This traits expands Result<T, Into<MacroError>> with some handy shortcuts.

Functions

filter_macro_error_panics

Execute the closure and catch all the panics triggered by trigger_error, converting them to proc_macro::TokenStream. All the other panics will be passed through as is.

trigger_error

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