Do MTWT resolution during lowering to HIR#30145
Merged
bors merged 2 commits intorust-lang:masterfrom Dec 9, 2015
Merged
Conversation
Collaborator
|
☔ The latest upstream changes (presumably #29850) made this pull request unmergeable. Please resolve the merge conflicts. |
Contributor
Author
|
Rebased. |
Member
There was a problem hiding this comment.
Why does save-analysis need the mtwt tables?
Contributor
Author
There was a problem hiding this comment.
It calls lower_crate, lowering uses mtwt tables.
Member
|
Nice! |
Contributor
Author
|
Updated with comments for |
Member
|
@bors: r+ |
Collaborator
|
📌 Commit c1d3164 has been approved by |
Collaborator
bors
added a commit
that referenced
this pull request
Dec 9, 2015
Instead of `ast::Ident`, bindings, paths and labels in HIR now keep a new structure called `hir::Ident` containing mtwt-renamed `name` and the original not-renamed `unhygienic_name`. `name` is supposed to be used by default, `unhygienic_name` is rarely used. This is not ideal, but better than the status quo for two reasons: - MTWT tables can be cleared immediately after lowering to HIR - This is less bug-prone, because it is impossible now to forget applying `mtwt::resolve` to a name. It is still possible to use `name` instead of `unhygienic_name` by mistake, but `unhygienic_name`s are used only in few very special circumstances, so it shouldn't be a problem. Besides name resolution `unhygienic_name` is used in some lints and debuginfo. `unhygienic_name` can be very well approximated by "reverse renaming" `token::intern(name.as_str())` or even plain string `name.as_str()`, except that it would break gensyms like `iter` in desugared `for` loops. This approximation is likely good enough for lints and debuginfo, but not for name resolution, unfortunately (see #27639), so `unhygienic_name` has to be kept. cc #29782 r? @nrc
Collaborator
This was referenced Dec 9, 2015
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Instead of
ast::Ident, bindings, paths and labels in HIR now keep a new structure calledhir::Identcontaining mtwt-renamednameand the original not-renamedunhygienic_name.nameis supposed to be used by default,unhygienic_nameis rarely used.This is not ideal, but better than the status quo for two reasons:
mtwt::resolveto a name. It is still possible to usenameinstead ofunhygienic_nameby mistake, butunhygienic_names are used only in few very special circumstances, so it shouldn't be a problem.Besides name resolution
unhygienic_nameis used in some lints and debuginfo.unhygienic_namecan be very well approximated by "reverse renaming"token::intern(name.as_str())or even plain stringname.as_str(), except that it would break gensyms likeiterin desugaredforloops. This approximation is likely good enough for lints and debuginfo, but not for name resolution, unfortunately (see #27639), sounhygienic_namehas to be kept.cc #29782
r? @nrc