-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rust: expand attribute macros #19334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
49cf173
adeaceb
2d32c36
a7a887c
ecd80fb
8ffe4d6
6ecaf65
82736ea
557f468
6748007
a99556e
f543839
3d38d77
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to register any failure reason as a diagnostic, so we can keep track of how many macro expansions were successful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after looking a bit at the rust analyzer code, I have the feeling the
err
in theExpandResult
gets recovered again inparse_macro_expansion_error
which is called by ouremit_macro_expansion_parse_errors
function called just below. So I think we should ignore theerr
here, as otherwise we would be emitting a diagnostic twice about it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah that makes sense. I guess that leaves the
?
after thecast
as a potential error that may be worth reporting. I suppose the result is always aMacroItem
, but perhaps it could be just anItem
if the macro expands to a single item, or anError
if something went wrong (although in that case I'd expect a parse error to be reported).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, maybe reporting an error there makes sense, just to be defensive. I think attribute and derive macros will always expand to
MacroItems
, as that's the only context in which they appear.