[][src]Macro proc_macro_error::span_error

macro_rules! span_error {
    ($span:expr, $fmt:literal, $($args:expr),*) => { ... };
    ($span:expr, $msg:expr) => { ... };
    ($err:expr) => { ... };

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


This macro is meant to be a panic! drop-in replacement so its syntax is very similar to panic!, but it has three forms instead of two:

  1. "panic-format-like" form: span, formatting str literal, comma-separated list of args. First argument is a span, all the rest gets passed to format! to build the error message.
  2. "panic-single-arg-like" form: span, expr, no comma at the end. First argument is a span, the second is our error message, it must implement ToString.
  3. "trigger_error-like" form: single expr. Literally trigger_error(arg). It's here just for convenience so span_error! can be used with instances of syn::Error, MacroError, [&str], String and so on...