Skip to content

Hygiene for methods #15537

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

Merged
merged 17 commits into from
Jul 9, 2014
Merged

Hygiene for methods #15537

merged 17 commits into from
Jul 9, 2014

Conversation

jbclements
Copy link
Contributor

This patch adds hygiene for methods. This one was more difficult than the others, due principally to issues surrounding self. Specifically, there were a whole bunch of places in the code that assumed that a self identifier could be discarded and then made up again later, causing the discard of contexts and hygiene breakage.

jbclements added 17 commits July 8, 2014 15:14
The let-syntax expander is different in that it doesn't apply
a mark to its token trees before expansion. This is used
for macro_rules, and it's because macro_rules is essentially
MTWT's let-syntax. You don't want to mark before expand sees
let-syntax, because there's no "after" syntax to mark again.

In some sense, the cleaner approach might be to introduce a new
AST node that macro_rules expands into; this would make it clearer
that the expansion of a macro is distinct from the addition of a
new macro binding.

This should work for now, though...
I believe this comment is now irrelevant, as a result of
commit 6757053
formerly, the self identifier was being discarded during parsing, which
stymies hygiene. The best fix here seems to be to attach a self identifier
to ExplicitSelf_, a change that rippled through the rest of the compiler,
but without any obvious damage.
@alexcrichton
Copy link
Member

Awesome!

bors added a commit that referenced this pull request Jul 9, 2014
This patch adds hygiene for methods. This one was more difficult than the others, due principally to issues surrounding `self`. Specifically, there were a whole bunch of places in the code that assumed that a `self` identifier could be discarded and then made up again later, causing the discard of contexts and hygiene breakage.
@bors bors closed this Jul 9, 2014
@bors bors merged commit 4c312b6 into rust-lang:master Jul 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants