I updated the proc-macros to use the latest versions of syn and quote and improved the error messages by using syn::Error and Spans.
For example this error message is now returned
error: ascii control chars are forbidden for security reasons
--> $DIR/escaped_ascii_control.rs:7:29
|
7 | assert_rel_ref_literal!("https://www.example.com/a/%00/c");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
which previously was
error: proc-macro derive panicked
--> src/main.rs:4:5
|
4 | uri!("https://www.example.com/a/%00/c");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: message: Malformed percent encoding at index 29
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
In the future it would be possible to further improve the error messages to
error: ascii control chars are forbidden for security reasons
--> $DIR/escaped_ascii_control.rs:7:29
|
7 | assert_rel_ref_literal!("https://www.example.com/a/%00/c");
| ^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
I had to add proc-macro2 as a dependency, because syn only returns proc-macro2 types and the conversion between proc-macro and proc-macro2 is not always possible.
For the new error messages I added trybuild, which allows to test the stderr returned by proc-macros. I set up some basic tests for some of them, but not all of them.
I also improved the verification of the uri encoding, by removing a lot of redundant code and simplifying the remaining code, which should have improved the parsing speed :)
I updated the
proc-macro
s to use the latest versions ofsyn
andquote
and improved the error messages by usingsyn::Error
andSpan
s.For example this error message is now returned
which previously was
In the future it would be possible to further improve the error messages to
but this requires
proc_macro::Literal::subspan
to be stable.I had to add
proc-macro2
as a dependency, becausesyn
only returnsproc-macro2
types and the conversion betweenproc-macro
andproc-macro2
is not always possible.For the new error messages I added
trybuild
, which allows to test thestderr
returned byproc-macro
s. I set up some basic tests for some of them, but not all of them.I also improved the verification of the
uri
encoding, by removing a lot of redundant code and simplifying the remaining code, which should have improved the parsing speed :)