-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Macro definitions should be regular HIR items #87406
Comments
See also #77862, #87257, #79396 (comment). |
Incidentally, how difficult do you think this task will be? |
@inquisitivecrystal my understanding without looking into it much is that basically everything that touches |
Alright. I'm currently looking at whether this might be within my ability to implement. I don't like saying I'll do something until I I've checked that I have some chance of figuring it out, but the |
I'm going to give this a go! There's no way of knowing for sure if I can do it until I actually try it out, and I can't do that properly until the PRs mentioned in the initial post are merged. |
@inquisitivecrystal : #87234 contains a perf regression which may very well be caused by this bug. I think you can go ahead with the implementation, I will rebase it on top of your work. |
I'm on it! |
I'm making progress on this. I'm going step by step, and I'm on step two, which is migrating the way My next subgoal is making the tests pass again. I currently have nine failing tests. As far as I can tell, there are at least two distinct bugs that are causing tests to fail, and possibly more. After I fix those, I've got to move onto the future steps. Here's what the checklist looks like:
I'll update that as I go. I may slow down a bit, as I'm not really sure I can keep up this intensity. :) |
No worries, slow progress is better than no progress :) thank you for working on this! |
I'm still working on this. Lifting the macros to top level is surprisingly complicated, but I'm making headway. |
After a fair bit of work, the standard library now builds again, even with the macros being lifted to the top level. However, I do still need to make the tests pass again. I'm also definitely going to need to spend a while cleaning my code up. It's horribly messy. |
I had to take a break for a few days, but I'm back at it. I'm hoping I'll be able to have a PR out for people to comment on soonish. |
The PR is up! It's #88019. |
Macro definitions are currently handled separately from other item kinds in HIR, either as
MacroDef
nodes insidehir::Crate::exported_macros
or as using thehir::Crate::non_exported_macro_attrs
.They should be transformed into additional variants in the
hir::ItemKind
enum, and iterated over like any other item.Instructions:
hir::ItemKind::ExportedMacro { ast: ast::MacroDef }
andhir::ItemKind::NonExportedMacro
;rustc_ast_lowering::item::LoweringContext::lower_item
intolower_item_kind
;hir::OwnerNode::{MacroDef, NonExportedMacro}
variants.I recomment waiting on #83723 and #87234 to be merged.
Original idea by @petrochenkov in #83723 (comment)
Should help with #73754
The text was updated successfully, but these errors were encountered: