Skip to content
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

Closed
pnkfelix opened this issue Feb 14, 2014 · 2 comments
Closed

Define ExpansionContext trait for the quote_foo! macros to use #12265

pnkfelix opened this issue Feb 14, 2014 · 2 comments
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

@pnkfelix
Copy link
Member

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 the ast::CrateConfig) and ident_of (to map a string to an ast::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.

@eddyb
Copy link
Member

eddyb commented Feb 15, 2014

ident_of should be outright removed, I did remove similar methods from Session in #12162 - these methods just call through functions in syntax::parse::token which use the task-local IdentInterner.

@steveklabnik steveklabnik added the A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) label Jan 23, 2015
@steveklabnik
Copy link
Member

Triage: no change that I can see.

@Mark-Simulacrum 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
@bors bors closed this as completed in 01f8e25 Jan 24, 2019
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.
Projects
None yet
Development

No branches or pull requests

4 participants