-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Do MTWT resolution during lowering to HIR #30145
Conversation
☔ The latest upstream changes (presumably #29850) made this pull request unmergeable. Please resolve the merge conflicts. |
Rebased. |
|
||
// Discard MTWT tables that aren't required past lowering to HIR. | ||
if !sess.opts.debugging_opts.keep_mtwt_tables && | ||
!sess.opts.debugging_opts.save_analysis { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does save-analysis need the mtwt tables?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It calls lower_crate
, lowering uses mtwt tables.
Nice! |
Updated with comments for |
@bors: r+ |
📌 Commit c1d3164 has been approved by |
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
Instead of
ast::Ident
, bindings, paths and labels in HIR now keep a new structure calledhir::Ident
containing mtwt-renamedname
and the original not-renamedunhygienic_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::resolve
to a name. It is still possible to usename
instead ofunhygienic_name
by mistake, butunhygienic_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 stringname.as_str()
, except that it would break gensyms likeiter
in desugaredfor
loops. This approximation is likely good enough for lints and debuginfo, but not for name resolution, unfortunately (see #27639), sounhygienic_name
has to be kept.cc #29782
r? @nrc