- 
                Notifications
    
You must be signed in to change notification settings  - Fork 13.9k
 
Do MTWT resolution during lowering to HIR #30145
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
Conversation
| 
           ☔ The latest upstream changes (presumably #29850) made this pull request unmergeable. Please resolve the merge conflicts.  | 
    
| 
           Rebased.  | 
    
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::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