-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Define ExpansionContext trait for the quote_foo! macros to use #12265
Labels
A-macros
Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
Comments
|
steveklabnik
added
the
A-macros
Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
label
Jan 23, 2015
Triage: no change that I can see. |
Mark-Simulacrum
added
the
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
label
Jul 20, 2017
bors
added a commit
that referenced
this issue
Sep 30, 2018
Remove quote_*! macros This deletes a considerable amount of test cases, some of which we may want to keep. I'm not entirely certain what the primary intent of many of them was; if we should keep them I can attempt to edit each case to continue compiling without the quote_*! macros involved. Fixes #46849. Fixes #12265. Fixes #12266. r? @Manishearth
bors
added a commit
that referenced
this issue
Oct 2, 2018
Remove quote_*! macros This deletes a considerable amount of test cases, some of which we may want to keep. I'm not entirely certain what the primary intent of many of them was; if we should keep them I can attempt to edit each case to continue compiling without the quote_*! macros involved. Fixes #46849. Fixes #12265. Fixes #12266. r? @Manishearth
bors
added a commit
that referenced
this issue
Dec 8, 2018
Remove quote_*! macros This deletes a considerable amount of test cases, some of which we may want to keep. I'm not entirely certain what the primary intent of many of them was; if we should keep them I can attempt to edit each case to continue compiling without the quote_*! macros involved. Fixes #46849. Fixes #12265. Fixes #12266. Fixes #26994. r? @Manishearth
bors
added a commit
that referenced
this issue
Jan 23, 2019
Remove quote_*! macros This deletes a considerable amount of test cases, some of which we may want to keep. I'm not entirely certain what the primary intent of many of them was; if we should keep them I can attempt to edit each case to continue compiling without the quote_*! macros involved. Fixes #46849. Fixes #12265. Fixes #12266. Fixes #26994. r? @Manishearth
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-macros
Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
The current
quote_foo!
macros (quote_expr!
,quote_pat!
, etc) all inject method calls on the first parameter to the macro invocation, which represents the expansion contexts.The method calls are to methods like
cfg
(for getting theast::CrateConfig
) andident_of
(to map a string to anast::Ident
).But there is no documentation for these methods, nor any standard trait defining how they should be packaged together to work with an invocation of
quote_foo!
. (The unit test shows examples of how you might do this; see e.g. the sample code I put on the description for #12264.)Plus, when you omit the first argument, or plug in a random value for the first argument, the error message you get is less than ideal (since the compiler just complains about one method not existing, and this is one method among many).
Maybe I'm mistaken, but I think we can do better; in particular, if we make the macro expand into something that calls out to another function parameterized over
<C:ExpansionContext>
where the trait-bound defines all the necessarily methods that the macro(s) expect, then we will get much better error messages from the compiler, since the user will see that there is a particular trait that they need to implement on the first argument to the macro.The text was updated successfully, but these errors were encountered: