Description
Proposal
Attributes are only partially lowered, and parsed in no less than 60 different places all around the compiler. I filed an issue earlier on rust-lang/rust but on the recomendation of @BoxyUwU and @WaffleLapkin I'm filing this as an MCP. Usually a proposal goes here, but I think my original issue already rougly covers that. I will, below, discuss steps in which we can implement this change.
- Refactor attributes into separate
ast::Attribute
andhir::Attribute
Hir attributes rust#131808 - Make
hir::Attribute
with one variant that represents "old style" attributes and contains the current structure, and where more variants can be added that are pre-parsed - Refactor
rustc_attr
to be the place where attributes are parsed and checked, making this a central place for this. - Slowly move over every built-in attribute to this location, except for custom tool attributes which will remain unparsed
Mentors or Reviewers
I'll certainly talk a lot to @WaffleLapkin and @m-ou-se about this as I work with them daily. Apart from that, maybe more people are interested? Possibly @petrochenkov should second this too.
Process
The main points of the Major Change Process are as follows:
- File an issue describing the proposal.
- A compiler team member or contributor who is knowledgeable in the area can second by writing
@rustbot second
.- Finding a "second" suffices for internal changes. If however, you are proposing a new public-facing feature, such as a
-C flag
, then full team check-off is required. - Compiler team members can initiate a check-off via
@rfcbot fcp merge
on either the MCP or the PR.
- Finding a "second" suffices for internal changes. If however, you are proposing a new public-facing feature, such as a
- Once an MCP is seconded, the Final Comment Period begins. If no objections are raised after 10 days, the MCP is considered approved.
You can read more about Major Change Proposals on forge.
Comments
There was already a zulip stream for this: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Attribute.20handling.20reworks
Let me also ping @jieyouxu and @bjorn3 here as they commented on the orginal proposal.