macros: report unbound metavariables directly#156155
Conversation
|
r? @BoxyUwU rustbot has assigned @BoxyUwU. Use Why was this reviewer chosen?The reviewer was selected based on:
|
There was a problem hiding this comment.
Looks good overall. One edge case I noticed: the primary diagnostic seems to be updated in the no-suggestion path, but typo / other-matcher paths may still keep expected expression, found '$' as the headline while only adding the metavariable-specific help/note.
It may be worth moving the primary message/span rewrite to immediately after detecting $ident, before branching into typo / other-matcher / available-name suggestions, so all unbound metavariable cases consistently report cannot find macro parameter ....
Also, since this PR is actively addressing #95943, consider claiming the issue with @rustbot claim.
Approve with that as a non-blocking review comment.

Fixes #95943.
When a macro expansion contains an unbound
$ident, report it as a missing macro parameter instead of keeping the generic fragment parser error as the primary diagnostic.This keeps the existing typo suggestions and available-metavariable notes.