From this issue https://github.com/rust-analyzer/rust-analyzer/issues/6292 I would like to pick this one up. Any directions or head starts?
I'm pretty sure the error means that the macro didn't expand fully, and my guess as to why would be that
-1.0 doesn't get matched as a literal because (I'm guessing) it probably gets parsed as two tokens which would form a unary expression
Yeah, according to the spec
$x:literal should match "
-? LiteralExpression" https://doc.rust-lang.org/reference/macros-by-example.html#metavariables
so it gets parsed as two tokens one
- and other
1.0 right? (When it should be a single literal
-1.0) So where's the parsing for literals done?
it's correct that it's being parsed that way, probably our definition of a literal fragment is wrong (according to what Jonas wrote)
I think the relevant code is this function, which implements literals as just parsing a single literal token
instead, literal will probably need to be a
FragmentKind and handled by
https://github.com/rust-analyzer/rust-analyzer/blob/81609960fa30ea92e37b23dc7b025d1939626812/crates/parser/src/lib.rs#L99 I saw this, do I have to include some seperate variants to proceed?
@weegee yeah, I think you'll need to add a new function to
grammar::fragments that first parses an optional
-, and then a literal (