Skip to content

Rewrite the new attribute argument parser #144689

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

Merged
merged 4 commits into from
Aug 22, 2025

Conversation

JonathanBrouwer
Copy link
Contributor

@JonathanBrouwer JonathanBrouwer commented Jul 30, 2025

Fixes #143940

This rewrites the parser, should improve performance and maintainability.
This can be reviewed commit by commit

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 30, 2025
@jdonszelmann
Copy link
Contributor

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Jul 30, 2025

⌛ Trying commit 7b3bb12 with merge acc46aa

To cancel the try build, run the command @bors try cancel.

rust-bors bot added a commit that referenced this pull request Jul 30, 2025
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 30, 2025
@@ -51,12 +37,26 @@ error[E0589]: invalid alignment value: not a power of two
LL | #[rustc_align(0)]
| ^

error: expected unsuffixed literal, found `-`
Copy link
Contributor

Choose a reason for hiding this comment

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

it would be pretty cool if we could explain here what an unsuffixed literal is. Maybe give an example of one with a short explanation. It's not required, but does teach the language better through diagnostics which is always cool

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I improved the error a lot :)

error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `-`
  --> $DIR/malformed-fn-align.rs:29:15
   |
LL | #[rustc_align(-1)]
   |               ^
   |
help: negative numbers are not literals, try removing the `-` sign
   |
LL - #[rustc_align(-1)]
LL + #[rustc_align(1)]
   |

@rust-bors
Copy link

rust-bors bot commented Jul 30, 2025

☀️ Try build successful (CI)
Build commit: acc46aa (acc46aa5d053362bb20ae7f352cba2635ef61120, parent: e5e79f8bd428d0b8d26e8240d718b134ef297459)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (acc46aa): comparison URL.

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

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.2% [0.2%, 0.2%] 1
Regressions ❌
(secondary)
0.8% [0.0%, 1.0%] 7
Improvements ✅
(primary)
-0.3% [-0.5%, -0.1%] 12
Improvements ✅
(secondary)
-0.2% [-0.2%, -0.1%] 12
All ❌✅ (primary) -0.2% [-0.5%, 0.2%] 13

Max RSS (memory usage)

Results (secondary -1.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.0% [2.0%, 2.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.4% [-2.9%, -2.0%] 3
All ❌✅ (primary) - - 0

Cycles

Results (secondary -0.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.7% [4.7%, 4.7%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.1% [-3.7%, -2.5%] 2
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 469.342s -> 468.873s (-0.10%)
Artifact size: 376.86 MiB -> 376.85 MiB (-0.00%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jul 30, 2025
@lqd
Copy link
Member

lqd commented Jul 31, 2025

(match-stress looks currently noisy to me)

@jdonszelmann
Copy link
Contributor

Mhm, we came to the same conclusion (@JonathanBrouwer )

@JonathanBrouwer JonathanBrouwer force-pushed the share_parse_path branch 2 times, most recently from 4c9a573 to 244cefa Compare July 31, 2025 13:39
@@ -4,7 +4,7 @@ macro_rules! bar (

macro_rules! foo (
() => (
#[allow_internal_unstable] //~ ERROR allow_internal_unstable side-steps
#[allow_internal_unstable()] //~ ERROR allow_internal_unstable side-steps
Copy link
Contributor Author

Choose a reason for hiding this comment

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

BREAKING CHANGE:
Previously, attributes on macro calls were partially checked for correct syntax (only what check_builtin_meta_item can check).
After this PR, the attributes are fully parsed.

In any case, these attributes are always completely ignored, except for #[cfg], which was always completely parsed and still is and is not affected by this breaking change.

@@ -1095,7 +1095,7 @@ impl<'a> Parser<'a> {
/// Parses a comma-separated sequence delimited by parentheses (e.g. `(x, y)`).
/// The function `f` must consume tokens until reaching the next separator or
/// closing bracket.
fn parse_paren_comma_seq<T>(
pub fn parse_paren_comma_seq<T>(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've had to make quite a few of these functions public, how problematic is that?
I don't think it matters right, or at least it's better than the alternative of copying them over

@JonathanBrouwer
Copy link
Contributor Author

@rustbot ready
r? @jdonszelmann

@JonathanBrouwer JonathanBrouwer marked this pull request as ready for review July 31, 2025 13:47
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 31, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 31, 2025

r? @SparrowLii

rustbot has assigned @SparrowLii.
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
Copy link
Collaborator

rustbot commented Jul 31, 2025

jdonszelmann is currently at their maximum review capacity.
They may take a while to respond.

@rust-log-analyzer

This comment has been minimized.

@JonathanBrouwer
Copy link
Contributor Author

@rustbot author
:c will take a look later

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 19, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 19, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@JonathanBrouwer
Copy link
Contributor Author

JonathanBrouwer commented Aug 20, 2025

@rustbot ready
@jdonszelmann

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 20, 2025
@bors
Copy link
Collaborator

bors commented Aug 22, 2025

☔ The latest upstream changes (presumably #145728) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot
Copy link
Collaborator

rustbot commented Aug 22, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@jdonszelmann
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 22, 2025

📌 Commit ec5b2cc has been approved by jdonszelmann

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 22, 2025
@bors
Copy link
Collaborator

bors commented Aug 22, 2025

⌛ Testing commit ec5b2cc with merge f5703d5...

@bors
Copy link
Collaborator

bors commented Aug 22, 2025

☀️ Test successful - checks-actions
Approved by: jdonszelmann
Pushing f5703d5 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 22, 2025
@bors bors merged commit f5703d5 into rust-lang:master Aug 22, 2025
11 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 22, 2025
Copy link
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 831e291 (parent) -> f5703d5 (this PR)

Test differences

Show 31 test diffs

Stage 1

  • errors::verify_parse_asm_expected_comma_183: [missing] -> pass (J0)
  • errors::verify_parse_asm_expected_comma_184: pass -> [missing] (J0)
  • errors::verify_parse_asm_expected_other_184: [missing] -> pass (J0)
  • errors::verify_parse_asm_expected_other_185: pass -> [missing] (J0)
  • errors::verify_parse_asm_expected_register_class_or_explicit_register_187: [missing] -> pass (J0)
  • errors::verify_parse_asm_expected_register_class_or_explicit_register_188: pass -> [missing] (J0)
  • errors::verify_parse_asm_expected_string_literal_186: [missing] -> pass (J0)
  • errors::verify_parse_asm_expected_string_literal_187: pass -> [missing] (J0)
  • errors::verify_parse_asm_non_abi_185: [missing] -> pass (J0)
  • errors::verify_parse_asm_non_abi_186: pass -> [missing] (J0)
  • errors::verify_parse_asm_requires_template_182: [missing] -> pass (J0)
  • errors::verify_parse_asm_requires_template_183: pass -> [missing] (J0)
  • errors::verify_parse_asm_sym_no_path_181: [missing] -> pass (J0)
  • errors::verify_parse_asm_sym_no_path_182: pass -> [missing] (J0)
  • errors::verify_parse_asm_underscore_input_180: [missing] -> pass (J0)
  • errors::verify_parse_asm_underscore_input_181: pass -> [missing] (J0)
  • errors::verify_parse_asm_unsupported_operand_179: [missing] -> pass (J0)
  • errors::verify_parse_asm_unsupported_operand_180: pass -> [missing] (J0)
  • errors::verify_parse_binder_and_polarity_177: [missing] -> pass (J0)
  • errors::verify_parse_binder_and_polarity_178: pass -> [missing] (J0)
  • errors::verify_parse_binder_before_modifiers_176: [missing] -> pass (J0)
  • errors::verify_parse_binder_before_modifiers_177: pass -> [missing] (J0)
  • errors::verify_parse_invalid_attr_unsafe_176: pass -> [missing] (J0)
  • errors::verify_parse_modifiers_and_polarity_178: [missing] -> pass (J0)
  • errors::verify_parse_modifiers_and_polarity_179: pass -> [missing] (J0)
  • session_diagnostics::verify_attr_parsing_invalid_attr_unsafe_44: [missing] -> pass (J0)
  • session_diagnostics::verify_attr_parsing_suffixed_literal_in_attribute_45: [missing] -> pass (J0)
  • [ui] tests/ui/parser/attribute/attr-incomplete.rs: [missing] -> pass (J1)

Stage 2

  • [ui] tests/ui/parser/attribute/attr-incomplete.rs: [missing] -> pass (J2)

Additionally, 2 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard f5703d5dd3eec176f86a6e9bf7e668b48b84eabb --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-aarch64-apple: 6805.9s -> 7685.4s (12.9%)
  2. x86_64-gnu-llvm-19: 2736.4s -> 2434.2s (-11.0%)
  3. x86_64-rust-for-linux: 2960.4s -> 2689.6s (-9.1%)
  4. dist-x86_64-illumos: 6304.7s -> 5842.7s (-7.3%)
  5. aarch64-msvc-2: 4942.2s -> 5277.0s (6.8%)
  6. x86_64-gnu-aux: 6746.3s -> 6307.6s (-6.5%)
  7. test-various: 4961.2s -> 4647.0s (-6.3%)
  8. dist-x86_64-apple: 7374.5s -> 6907.5s (-6.3%)
  9. aarch64-apple: 6416.0s -> 6034.4s (-5.9%)
  10. dist-apple-various: 4984.6s -> 4707.4s (-5.6%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f5703d5): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.1% [0.7%, 1.4%] 8
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 0.2%, secondary 2.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.4% [1.4%, 1.4%] 1
Regressions ❌
(secondary)
2.7% [2.2%, 3.9%] 7
Improvements ✅
(primary)
-1.0% [-1.0%, -1.0%] 1
Improvements ✅
(secondary)
-0.7% [-1.0%, -0.4%] 2
All ❌✅ (primary) 0.2% [-1.0%, 1.4%] 2

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

Results (secondary -0.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

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

Bootstrap: 466.749s -> 466.339s (-0.09%)
Artifact size: 378.24 MiB -> 378.27 MiB (0.01%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. merged-by-bors This PR was explicitly merged by bors. needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-lang Relevant to the language team to-announce Announce this issue on triage meeting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attributes are parsed twice