Skip to content
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

Attribute handling reworks #796

Closed
1 of 7 tasks
jdonszelmann opened this issue Oct 16, 2024 · 3 comments
Closed
1 of 7 tasks

Attribute handling reworks #796

jdonszelmann opened this issue Oct 16, 2024 · 3 comments
Labels
major-change A proposal to make a major change to rustc major-change-accepted A major change proposal that was accepted T-compiler Add this label so rfcbot knows to poll the compiler team

Comments

@jdonszelmann
Copy link

jdonszelmann commented Oct 16, 2024

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 and hir::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.
  • 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.

@jdonszelmann jdonszelmann added major-change A proposal to make a major change to rustc T-compiler Add this label so rfcbot knows to poll the compiler team labels Oct 16, 2024
@rustbot
Copy link
Collaborator

rustbot commented Oct 16, 2024

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

Concerns or objections to the proposal should be discussed on Zulip and formally registered here by adding a comment with the following syntax:

@rustbot concern reason-for-concern 
<description of the concern> 

Concerns can be lifted with:

@rustbot resolve reason-for-concern 

See documentation at https://forge.rust-lang.org

cc @rust-lang/compiler @rust-lang/compiler-contributors

@rustbot rustbot added the to-announce Announce this issue on triage meeting label Oct 16, 2024
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Oct 17, 2024
@WaffleLapkin
Copy link
Member

@rustbot second

@rustbot rustbot added the final-comment-period The FCP has started, most (if not all) team members are in agreement label Oct 17, 2024
@apiraino
Copy link
Contributor

@rustbot label -final-comment-period +major-change-accepted

@rustbot rustbot added major-change-accepted A major change proposal that was accepted to-announce Announce this issue on triage meeting and removed final-comment-period The FCP has started, most (if not all) team members are in agreement labels Oct 30, 2024
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Oct 31, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 15, 2024
…bk,petrochenkov

Hir attributes

This PR needs some explanation, it's somewhat large.

- This is step one as described in rust-lang/compiler-team#796. I've added a new `hir::Attribute` which is a lowered version of `ast::Attribute`. Right now, this has few concrete effects, however every place that after this PR parses a `hir::Attribute` should later get a pre-parsed attribute as described in rust-lang/compiler-team#796 and transitively rust-lang#131229.
- an extension trait `AttributeExt` is added, which is implemented for both `ast::Attribute` and `hir::Atribute`. This makes `hir::Attributes` mostly compatible with code that used to parse `ast::Attribute`. All its methods are also added as inherent methods to avoid having to import the trait everywhere in the compiler.
  - Incremental can not not hash `ast::Attribute` at all.
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 15, 2024
…bk,petrochenkov

Hir attributes

This PR needs some explanation, it's somewhat large.

- This is step one as described in rust-lang/compiler-team#796. I've added a new `hir::Attribute` which is a lowered version of `ast::Attribute`. Right now, this has few concrete effects, however every place that after this PR parses a `hir::Attribute` should later get a pre-parsed attribute as described in rust-lang/compiler-team#796 and transitively rust-lang#131229.
- an extension trait `AttributeExt` is added, which is implemented for both `ast::Attribute` and `hir::Atribute`. This makes `hir::Attributes` mostly compatible with code that used to parse `ast::Attribute`. All its methods are also added as inherent methods to avoid having to import the trait everywhere in the compiler.
  - Incremental can not not hash `ast::Attribute` at all.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major-change A proposal to make a major change to rustc major-change-accepted A major change proposal that was accepted T-compiler Add this label so rfcbot knows to poll the compiler team
Projects
None yet
Development

No branches or pull requests

4 participants