For https://github.com/rust-analyzer/rust-analyzer/issues/3419 where would the checks for this ideally go? I would imagine in the syntax crate in validation?
syntax crate should have a pretty abstract way to tokenize a string
and then that should be used by other crates
I think we already have something like this already, for syntax highlighting
Yep, there is a
HasFormatSpecifier trait implemented on String and RawString which offers a lexing function for this thanks to syntax highlighting
Note that an AST validation pass is not enough to handle this – the validation needs to happen on expansion of the built-in
@veykril right! I think it might make sense to move it to a
format.rs module, and maybe change the interface to work with
&str, rather than with AST nodes
Things that can be indepemdent of AST should be independent
It is also true that it's only during macro expansion that we know which strings are actually format specifiers.
Right, where should the check go then though? I've been looking through things for a bit earlier but couldn't find another place where it was obvious for me to check.
What crate should that belong to then?
stdx or still
format_args_expand I think is conceptually the right place to do the check
The problem is, we don't yet have any infra for reporting errors from macro expansion so this'll require some plumbing
Oh, so invalid macro invocations aren't actually being reported at all by RA currently?