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

Generalize MacExpr / MacPat / MacItems #17637

Closed
kmcallister opened this issue Sep 29, 2014 · 3 comments · Fixed by #22875
Closed

Generalize MacExpr / MacPat / MacItems #17637

kmcallister opened this issue Sep 29, 2014 · 3 comments · Fixed by #22875
Assignees
Labels
A-syntaxext Area: Syntax extensions C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@kmcallister
Copy link
Contributor

There should be a single type implementing MacResult with Option fields for all the types MacResult can return, and a Default impl that fills in None.

@kmcallister kmcallister added A-syntaxext Area: Syntax extensions C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. labels Sep 29, 2014
@gamazeps
Copy link
Contributor

gamazeps commented Oct 1, 2014

On it :)

@eddyb
Copy link
Member

eddyb commented Nov 9, 2014

IMO this is the wrong way to go about doing things, a macro that can expand to different nodes depending on context would need to produce all of the possible expansions ahead of time.

@kmcallister
Copy link
Contributor Author

@eddyb: No, you can still implement MacResult yourself; this is much more convenient in the common case where it's no problem to produce all of the expansions ahead of time.

gamazeps added a commit to gamazeps/rust that referenced this issue Nov 9, 2014
@kmcallister kmcallister self-assigned this Feb 2, 2015
kmcallister added a commit to kmcallister/rust that referenced this issue Feb 27, 2015
MacEager is a MacResult implementation for the common case where you've already
built each form of AST that you might return.

Fixes rust-lang#17637. Based on rust-lang#18814.

This is a [breaking-change] for syntax extensions:

  * MacExpr::new becomes MacEager::expr.

  * MacPat::new becomes MacEager::pat.

  * MacItems::new becomes MacEager::items. It takes a SmallVector directly,
    not an iterator.
Manishearth added a commit to Manishearth/rust that referenced this issue Feb 28, 2015
 MacEager is a MacResult implementation for the common case where you've already built each form of AST that you might return.

Fixes rust-lang#17637. Based on rust-lang#18814.

This is a [breaking-change] for syntax extensions:

  * MacExpr::new becomes MacEager::expr.

  * MacPat::new becomes MacEager::pat.

  * MacItems::new becomes MacEager::items. It takes a SmallVector directly,
    not an iterator.

r? @sfackler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-syntaxext Area: Syntax extensions C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
3 participants