Skip to content

Rewrite inline attribute parser to use new infrastructure and improve diagnostics for all parsed attributes - #138165

Merged
bors merged 8 commits into
rust-lang:masterfrom
jdonszelmann:inline
Jun 18, 2025
Merged

Rewrite inline attribute parser to use new infrastructure and improve diagnostics for all parsed attributes#138165
bors merged 8 commits into
rust-lang:masterfrom
jdonszelmann:inline

Conversation

@jdonszelmann

@jdonszelmannjdonszelmann commented Mar 7, 2025

Copy link
Copy Markdown
Contributor

r? @oli-obk

This PR:

Builds on top of #138164

Closes#137950

@rustbotrustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 7, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

return OptimizeAttr::Default;
};

inline_span = Some(attr.span());

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

This fixes #137950

@jdonszelmann
jdonszelmannforce-pushed the inline branch 2 times, most recently from e6dad01 to 2a707bfCompareMarch 9, 2025 15:34
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors

bors commented Mar 11, 2025

Copy link
Copy Markdown
Collaborator

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

@oli-obkoli-obk 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 Apr 28, 2025
@jdonszelmann
jdonszelmannforce-pushed the inline branch 2 times, most recently from b7dda57 to 88a713aCompareJune 9, 2025 22:40
@rust-log-analyzer

This comment has been minimized.

@jdonszelmann

Copy link
Copy Markdown
ContributorAuthor

@rustbot review

@rustbotrustbot 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 Jun 9, 2025
@rust-log-analyzer

This comment has been minimized.

@jdonszelmann

Copy link
Copy Markdown
ContributorAuthor

ah shit, broke clippy 😭

@jdonszelmann

Copy link
Copy Markdown
ContributorAuthor

Yay!

// Latest feature: rustdoc JSON: Don't apply #[repr] privacy heuristics
pub const FORMAT_VERSION: u32 = 46;
// Latest feature: Pretty printing of inline attributes changed
pub const FORMAT_VERSION: u32 = 48;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Uh, we skipped 47. Oh well, not much to be done about it now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@GuillaumeGomez: when you add the (tidy?) check for updating the number and comment in tandem, could you also add a check that the number is being increased by one?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I opened #142677 for that. But that's a good point. Added to my TODO list.

@aDotInTheVoidaDotInTheVoidJun 19, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

#138165 (comment), earlier it was thaught that someone else was going to do 46->47, to this should do 47->48. I think the takeaways are:

a) Don't try to be too clever and do a double bounce
b) #142601should fix this. 🤞

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've published rustdoc-types = "0.48.0", with a note that 0.47.0/format_version=47 will never exist. https://github.com/rust-lang/rustdoc-types/blob/trunk/CHANGELOG.md#v0.48.0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've published rustdoc-types = "0.48.0", with a note that 0.47.0/format_version=47 will never exist. https://github.com/rust-lang/rustdoc-types/blob/trunk/CHANGELOG.md#v0.48.0

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (1bb3352): comparison URL.

Overall result: ❌ regressions - 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

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

meanrangecount
Regressions ❌
(primary)
0.3%[0.2%, 0.8%]12
Regressions ❌
(secondary)
0.5%[0.2%, 0.8%]21
Improvements ✅
(primary)
-0.2%[-0.2%, -0.2%]2
Improvements ✅
(secondary)
-0.2%[-0.2%, -0.2%]1
All ❌✅ (primary)0.3%[-0.2%, 0.8%]14

Max RSS (memory usage)

Results (primary -0.8%, secondary -1.0%)

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

meanrangecount
Regressions ❌
(primary)
7.0%[7.0%, 7.0%]1
Regressions ❌
(secondary)
3.4%[3.4%, 3.4%]1
Improvements ✅
(primary)
-1.5%[-2.5%, -0.8%]11
Improvements ✅
(secondary)
-3.1%[-3.1%, -3.1%]2
All ❌✅ (primary)-0.8%[-2.5%, 7.0%]12

Cycles

Results (secondary 4.2%)

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

meanrangecount
Regressions ❌
(primary)
--0
Regressions ❌
(secondary)
4.2%[4.2%, 4.2%]1
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
--0
All ❌✅ (primary)--0

Binary size

Results (primary 0.1%, secondary 0.2%)

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

meanrangecount
Regressions ❌
(primary)
0.1%[0.0%, 0.6%]87
Regressions ❌
(secondary)
0.2%[0.0%, 0.8%]40
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
--0
All ❌✅ (primary)0.1%[0.0%, 0.6%]87

Bootstrap: 693.071s -> 692.01s (-0.15%)
Artifact size: 372.10 MiB -> 372.13 MiB (0.01%)

@rustbotrustbot added the perf-regression Performance regression. label Jun 18, 2025
jhpratt added a commit to jhpratt/rust that referenced this pull request Jun 19, 2025
rewrite `optimize` attribute to use new attribute parsing infrastructure
r? `@oli-obk`
I'm afraid we'll get quite a few of these PRs in the future. If we get a lot of trivial changes I'll start merging multiple into one PR. They should be easy to review :)
Waiting on rust-lang#138165 first
tgross35 added a commit to tgross35/rust that referenced this pull request Jun 20, 2025
rewrite `optimize` attribute to use new attribute parsing infrastructure
r? ``@oli-obk``
I'm afraid we'll get quite a few of these PRs in the future. If we get a lot of trivial changes I'll start merging multiple into one PR. They should be easy to review :)
Waiting on rust-lang#138165 first
tgross35 added a commit to tgross35/rust that referenced this pull request Jun 20, 2025
rewrite `optimize` attribute to use new attribute parsing infrastructure
r? ```@oli-obk```
I'm afraid we'll get quite a few of these PRs in the future. If we get a lot of trivial changes I'll start merging multiple into one PR. They should be easy to review :)
Waiting on rust-lang#138165 first
@therealprof

Copy link
Copy Markdown
Contributor

@jdonszelmann Is the binary size jump expected? I thought this would only change the infrastructure but not actual inlining?

@jdonszelmann

jdonszelmann commented Jun 20, 2025

Copy link
Copy Markdown
ContributorAuthor

@oli-obk and I have been looking at this this morning. It has to do with attribute encoding cross crate and I'm working on a fix. The fix is luckily rather simple, but it was definitely an unexpected side effect. I expect to be busy for an hour or so more and then have a pr ready :)

bors added a commit that referenced this pull request Jun 20, 2025
Encode hir attributes cross-crate properly
r? `@oli-obk`
This should return the lost perf in #138165
cc: `@therealprof`
rust-timer added a commit that referenced this pull request Jun 20, 2025
Rollup merge of #138291 - jdonszelmann:optimize-attr, r=oli-obk
rewrite `optimize` attribute to use new attribute parsing infrastructure
r? ```@oli-obk```
I'm afraid we'll get quite a few of these PRs in the future. If we get a lot of trivial changes I'll start merging multiple into one PR. They should be easy to review :)
Waiting on #138165 first
@rylev

Copy link
Copy Markdown
Member

The perf regression has been addressed in #142777

@rustbot label: +perf-regression-triaged

@rustbotrustbot added the perf-regression-triaged The performance regression has been triaged. label Jun 24, 2025
@apiraino

apiraino commented Jun 24, 2025

Copy link
Copy Markdown
Contributor

The perf regression has been addressed in #142777

To be precise almost completely addressed, the clap crate still suffers on binary size regression.

@jdonszelmann

Copy link
Copy Markdown
ContributorAuthor

@Kobzol has theorized this is noise, saying that the noise threshold isn't very accurate caused by the bimodal nature of the data. It sounds reasonable to me looking at the graph so I think this is actually entirely addressed @rylev

bors added a commit that referenced this pull request Jun 25, 2025
…i-obk
Encode hir attributes cross-crate properly
r? `@oli-obk`
This should return the lost perf in #138165
cc: `@therealprof`
bors added a commit that referenced this pull request Jun 25, 2025
…i-obk
Encode hir attributes cross-crate properly
r? `@oli-obk`
This should return the lost perf in #138165
cc: `@therealprof`
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jun 26, 2025
Rewrite `inline` attribute parser to use new infrastructure and improve diagnostics for all parsed attributes
r? `@oli-obk`
This PR:
- creates a new parser for inline attributes
- creates consistent error messages and error codes between attribute parsers; inline and others
- as such changes a few error messages for other attributes to be (in my eyes) much more consistent
- tests ast-lowering lints introduced by rust-lang#138164 since this is now useful for the first time
- Coalesce some useless error codes
Builds on top of rust-lang#138164Closesrust-lang#137950
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)A-rustdoc-jsonArea: Rustdoc JSON backendmerged-by-borsThis PR was explicitly merged by bors.perf-regressionPerformance regression.perf-regression-triagedThe performance regression has been triaged.S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Diagnostics error in interaction between #[optimize(..)] and #[no_sanitize(..)]

15 participants

@jdonszelmann@rust-log-analyzer@bors@rustbot@fmease@rust-timer@therealprof@rylev@apiraino@oli-obk@nnethercote@obi1kenobi@GuillaumeGomez@aDotInTheVoid@mejrs