Closed gui1117 closed 1 year ago
CC @sam0x17
I believe this one is also addressed by https://github.com/sam0x17/macro_magic/issues/3 so should have something for this soon
@sam0x17 as you wrote here https://github.com/sam0x17/macro_magic/pull/5#discussion_r1218299839
extra
is a string literal used pass through all the macros the tokens of the impl item.
because impl item is converted to string and back to token stream the spans are lost.
you pointed the reason for string convertion is to have extra
being in any position.
I think we can also use {}
block to capture any token stream.
so the export_tokens generated macro, instead of matching on
($(::)?$($tokens_var:ident)::*, $(::)?$($callback:ident)::*, $extra:expr) => {
it could match on
($(::)?$($tokens_var:ident)::*, $(::)?$($callback:ident)::*, { $($extra:tt)* }) => {
this way it could take others parameters like:
($(::)?$($tokens_var:ident)::*, $(::)?$($callback:ident)::*, { $($extra1:tt)* }, { $($extra2:tt)* }, $extra3:ident) => {
But I don't know if macro_rules
call will keep the spans or not.
macro_rules
keeps the spans, initial implementation is here https://github.com/sam0x17/macro_magic/pull/6
This specific improvement will be really good for #13950 since we were having span issues there
should be fixed in https://github.com/sam0x17/macro_magic/pull/6 fix will come in substrate with next upgrade of macro magic
Is there an existing issue?
Experiencing problems? Have you tried our Stack Exchange first?
Description of bug
when implementing a trait with default configs, if there is an error, then it just points to the macro instead of the correct item in the trait implementation> I believe this can be solved by adding some spans or generating the tokens differently>
Steps to reproduce
1- create a faulty implementation like:
2- compile and see the error resulting
instead it should point to
traits