Misleading diagnostic when passing a doc comment to macro #97850
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Given the following code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=ef09a8b3babfcc78309404420421b477
The current output is:
Replacing the empty macro pattern with
#
,#[]
,#[doc]
or#[doc=]
will result in near-identical error messages about the[
,doc
,=
or string literal tokens, respectively. This is misleading, because these tokens do not exist in the original source code. If I didn't already know that doc comments get turned into doc attributes in the form#[doc = "..."]
, I probably would have assumed this was a compiler bug. A possible solution would be to point this out in the diagnostic (formatting and contents very much up for debate):This is related to (and possibly a generalization of) #92846.
The text was updated successfully, but these errors were encountered: