macro_rules! emit { ($emitter:expr, $msg:literal) => { ... }; ($emitter:expr, $error:expr) => { ... }; ($emitter:expr, $($tt:tt)*) => { ... }; }
Expand description
Push an error to an emitter.
The syntax is identical to error_message!
and bail!
, but the first
argument is the Emitter
.
let mut emitter = Emitter::new();
emit!(emitter, "an error message");
emit!(emitter, "an error message"; error = "with attachments");
let span = Span::call_site();
emit!(emitter, span, "error message");
let error = syn::Error::new(Span::call_site(), "an error");
emit!(emitter, error);
It can also be used with Error
.
let mut error: Error = error_message!("initial error").into();
emit!(error, "an error message");
Or any collection implementing Extend
.
let mut errors = Vec::new();
emit!(errors, "an error message");