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

New attribute parsing infrastructure #135726

Merged
merged 10 commits into from
Feb 25, 2025
Merged

Conversation

jdonszelmann
Copy link
Contributor

@jdonszelmann jdonszelmann commented Jan 19, 2025

Another step in the plan outlined in #131229

introduces infrastructure for structured parsers for attributes, as well as converting a couple of complex attributes to have such structured parsers.

This PR may prove too large to review. I left some of my own comments to guide it a little. Some general notes:

  • The first commit is basically standalone. It just preps some mostly unrelated sources for the rest of the PR to work. It might not have enormous merit on its own, but not negative merit either. Could be merged alone, but also doesn't make the review a whole lot easier. (but it's only +274 -209)
  • The second commit is the one that introduces new infrastructure. It's the important one to review.
  • The 3rd commit uses the new infrastructure showing how some of the more complex attributes can be parsed using it. Theoretically can be split up, though the parsers in this commit are the ones that really test the new infrastructure and show that it all works.
  • The 4th commit fixes up rustdoc and clippy. In the previous 2 they didn't compile yet while the compiler does. Separated them out to separate concerns and make the rest more palatable.
  • The 5th commit blesses some test outputs. Sometimes that's just because a diagnostic happens slightly earlier than before, which I'd say is acceptable. Sometimes a diagnostic is now only emitted once where it would've been twice before (yay! fixed some bugs). One test I actually moved from crashes to fixed, because it simply doesn't crash anymore. That's why this PR Closes ICE: malformed malformed repr(align(N)) #132391. I think most choices I made here are generally reasonable, but let me know if you disagree anywhere.
  • The 6th commit adds a derive to pretty print attributes
  • The 7th removes smir apis for attributes, for the time being. The api will at some point be replaced by one based on rustc_ast_data_structures::AttributeKind

In general, a lot of the additions here are comments. I've found it very important to document new things in the 2nd commit well so other people can start using it.

Closes #132391
Closes #136717

@rustbot
Copy link
Collaborator

rustbot commented Jan 19, 2025

r? @Noratrieb

rustbot has assigned @Noratrieb.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) PG-exploit-mitigations Project group: Exploit mitigations T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jan 19, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@Noratrieb
Copy link
Member

r? oli-obk

@rust-log-analyzer

This comment has been minimized.

@bors

This comment was marked as resolved.

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jan 20, 2025
@jdonszelmann jdonszelmann force-pushed the attr-parsing branch 2 times, most recently from 4d3437f to b3d6ef4 Compare January 20, 2025 16:39
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@jdonszelmann jdonszelmann force-pushed the attr-parsing branch 3 times, most recently from 4aaff39 to 2f73b56 Compare January 20, 2025 19:53
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Feb 24, 2025

⌛ Testing commit 4daa35c with merge 7d8c6e781d347e087c7d30ea393d7dcd725ed623...

@jdonszelmann
Copy link
Contributor Author

omg :D

@BoxyUwU
Copy link
Member

BoxyUwU commented Feb 24, 2025

@bors rollup=never p=1 bitrotty

@bors
Copy link
Contributor

bors commented Feb 25, 2025

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing 7d8c6e7 to master...

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (7d8c6e7): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
0.4% [0.2%, 0.8%] 38
Regressions ❌
(secondary)
0.6% [0.3%, 1.3%] 43
Improvements ✅
(primary)
-4.1% [-4.1%, -4.1%] 1
Improvements ✅
(secondary)
-0.7% [-2.4%, -0.3%] 8
All ❌✅ (primary) 0.3% [-4.1%, 0.8%] 39

Max RSS (memory usage)

Results (primary -0.1%, secondary 0.2%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.2% [0.4%, 4.5%] 44
Regressions ❌
(secondary)
1.0% [0.4%, 3.4%] 76
Improvements ✅
(primary)
-0.9% [-2.7%, -0.4%] 68
Improvements ✅
(secondary)
-0.9% [-4.4%, -0.4%] 53
All ❌✅ (primary) -0.1% [-2.7%, 4.5%] 112

Cycles

Results (primary 0.4%, secondary 0.7%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.9% [0.4%, 5.1%] 97
Regressions ❌
(secondary)
1.1% [0.4%, 2.7%] 109
Improvements ✅
(primary)
-1.6% [-4.2%, -0.4%] 20
Improvements ✅
(secondary)
-1.4% [-3.8%, -0.5%] 18
All ❌✅ (primary) 0.4% [-4.2%, 5.1%] 117

Binary size

Results (primary -0.1%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.7%, -0.0%] 9
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.1% [-0.7%, -0.0%] 9

Bootstrap: 770.447s -> 772.781s (0.30%)
Artifact size: 359.63 MiB -> 362.01 MiB (0.66%)

Comment on lines -550 to +553
struct_span_code_err!(tcx.dcx(), item.span(), E0535, "invalid argument")
struct_span_code_err!(tcx.dcx(), items[0].span(), E0535, "invalid argument")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? item == items[0], as destructured in let [item] = &items[..] else

fmease added a commit to fmease/rust that referenced this pull request Feb 25, 2025
Revert accidental cargo submodule update

This was accidentally introduced in rust-lang#135726
Kobzol added a commit to Kobzol/rust that referenced this pull request Feb 25, 2025
…=oli-obk"

This reverts commit 7d8c6e7, reversing
changes made to 617aad8.
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 25, 2025
Revert "Auto merge of rust-lang#135726 - jdonszelmann:attr-parsing, r=oli-obk"

Trying to revert rust-lang#135726 and do some perf. runs on it.

r? `@ghost`
fmease added a commit to fmease/rust that referenced this pull request Feb 25, 2025
Revert accidental cargo submodule update

This was accidentally introduced in rust-lang#135726
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) A-rustdoc-json Area: Rustdoc JSON backend A-rustdoc-search Area: Rustdoc's search feature merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE: malformed repr(align(N)) ICE: malformed malformed repr(align(N))