Panicking in a proc macro doesn't give the user particularly helpful errors. There's no way for them to know where their syntax error is, and the title of the error is the worrying "procedural macro panicked".
Instead, you can emit an invocation of the compile_error macro to give the user a more helpful error. If you give the tokens the span of the invalid tokens, rustc's error will even highlight them.
Panicking in a proc macro doesn't give the user particularly helpful errors. There's no way for them to know where their syntax error is, and the title of the error is the worrying "procedural macro panicked".
Instead, you can emit an invocation of the
compile_error
macro to give the user a more helpful error. If you give the tokens the span of the invalid tokens, rustc's error will even highlight them.