Skip to content

Port lint attributes to attribute parser#152369

Merged
rust-bors[bot] merged 11 commits intorust-lang:mainfrom
Bryntet:lint_attrs
Apr 3, 2026
Merged

Port lint attributes to attribute parser#152369
rust-bors[bot] merged 11 commits intorust-lang:mainfrom
Bryntet:lint_attrs

Conversation

@Bryntet
Copy link
Copy Markdown
Contributor

@Bryntet Bryntet commented Feb 9, 2026

View all comments

Tracking issue: #131229

Ports #[allow], #[deny], #[expect], #[forbid], and #[warn] to being parsed attrs

I tried my best to make this PR as small as possible, it was difficult. I hope it isn't too difficult to review

r? @JonathanBrouwer
r? @jdonszelmann

@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 Feb 9, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the T-clippy Relevant to the Clippy team. label Feb 22, 2026
@Bryntet Bryntet changed the title lint attrs Port lint attributes to attribute parser Feb 22, 2026
@Bryntet Bryntet marked this pull request as ready for review February 22, 2026 18:57
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 22, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Feb 22, 2026

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

Some changes occurred in compiler/rustc_hir/src/attrs

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 22, 2026
@JonathanBrouwer
Copy link
Copy Markdown
Contributor

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Feb 22, 2026
Port lint attributes to attribute parser
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 22, 2026
@Bryntet Bryntet force-pushed the lint_attrs branch 2 times, most recently from e70b414 to d9434c9 Compare February 22, 2026 20:19
Comment thread compiler/rustc_passes/src/check_attr.rs Outdated
@JonathanBrouwer
Copy link
Copy Markdown
Contributor

@bors r=JonathanBrouwer,jdonszelmann

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 3, 2026

📌 Commit ce7c492 has been approved by JonathanBrouwer,jdonszelmann

It is now in the queue for this repository.

@rust-bors

This comment has been minimized.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 3, 2026

☀️ Test successful - CI
Approved by: JonathanBrouwer,jdonszelmann
Duration: 3h 37m 9s
Pushing 2972b5e to main...

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

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 f908263 (parent) -> 2972b5e (this PR)

Test differences

Show 108 test diffs

Stage 1

  • [ui] tests/rustdoc-ui/lints/renamed-lint-still-applies-2.rs: [missing] -> pass (J1)
  • [ui] tests/ui/error-codes/E0452.rs: pass -> [missing] (J1)

Stage 2

  • [ui] tests/ui/error-codes/E0452.rs: pass -> [missing] (J0)
  • [ui] tests/rustdoc-ui/lints/renamed-lint-still-applies-2.rs: [missing] -> pass (J2)

Additionally, 104 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 2972b5e59f1c5529b6ba770437812fd83ab4ebd4 --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. aarch64-apple: 2h 45m -> 3h 30m (+27.3%)
  2. dist-aarch64-llvm-mingw: 1h 28m -> 1h 48m (+22.9%)
  3. dist-apple-various: 1h 29m -> 1h 41m (+13.3%)
  4. pr-check-1: 30m 15s -> 33m 52s (+12.0%)
  5. x86_64-gnu-llvm-22-3: 1h 47m -> 1h 59m (+11.8%)
  6. dist-x86_64-apple: 1h 58m -> 2h 12m (+11.5%)
  7. dist-aarch64-apple: 1h 54m -> 1h 42m (-10.9%)
  8. x86_64-gnu-llvm-21-2: 1h 30m -> 1h 39m (+10.0%)
  9. dist-x86_64-llvm-mingw: 1h 54m -> 2h 3m (+8.6%)
  10. dist-i686-msvc: 2h 10m -> 2h 21m (+7.8%)
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
Copy Markdown
Collaborator

Finished benchmarking commit (2972b5e): 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

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.3% [0.2%, 0.5%] 7
Improvements ✅
(primary)
-0.3% [-0.6%, -0.2%] 20
Improvements ✅
(secondary)
-0.4% [-0.6%, -0.0%] 37
All ❌✅ (primary) -0.3% [-0.6%, 0.2%] 21

Max RSS (memory usage)

Results (primary -1.6%, secondary 2.9%)

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% [1.8%, 10.0%] 13
Improvements ✅
(primary)
-1.6% [-2.3%, -1.0%] 2
Improvements ✅
(secondary)
-3.0% [-8.3%, -1.1%] 4
All ❌✅ (primary) -1.6% [-2.3%, -1.0%] 2

Cycles

Results (primary 2.2%, secondary 3.6%)

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

mean range count
Regressions ❌
(primary)
2.2% [1.3%, 2.8%] 5
Regressions ❌
(secondary)
4.4% [3.3%, 5.5%] 8
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.3% [-3.3%, -3.3%] 1
All ❌✅ (primary) 2.2% [1.3%, 2.8%] 5

Binary size

Results (primary 0.0%, 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.0% [0.0%, 0.0%] 4
Regressions ❌
(secondary)
0.0% [0.0%, 0.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [0.0%, 0.0%] 4

Bootstrap: 491.353s -> 489.759s (-0.32%)
Artifact size: 395.11 MiB -> 395.08 MiB (-0.01%)

@JonathanBrouwer
Copy link
Copy Markdown
Contributor

Perf wins significantly outweigh the regressions
@rustbot label: +perf-regression-triaged

@the8472
Copy link
Copy Markdown
Member

the8472 commented Apr 6, 2026

Perf wins significantly outweigh the regressions

Walltime numbers seem to disagree, and eyeballing the summary charts looks like those regressions are real, i.e. the shift persists.

image

@JonathanBrouwer
Copy link
Copy Markdown
Contributor

Ooh interesting, walltime numbers are usually super noisy so I tend to ignore them, but this does indeed look kinda real
This is the one for eza incr-patched, the worst walltime regression in the primary benchmarks, and this one does seem to go back to normal. Which one were you looking at @the8472 ?

image

@the8472
Copy link
Copy Markdown
Member

the8472 commented Apr 6, 2026

@Bryntet
Copy link
Copy Markdown
Contributor Author

Bryntet commented Apr 6, 2026

Perf wins significantly outweigh the regressions

Walltime numbers seem to disagree, and eyeballing the summary charts looks like those regressions are real, i.e. the shift persists.
image

I think some walltime increase can be expected due to: https://github.com/rust-lang/rust/pull/152369/changes#diff-f108051d119300655064d5988094ba485d04880e8669944bbc484f35c49b6743R126

@JonathanBrouwer
Copy link
Copy Markdown
Contributor

I don't really believe that sort could cause such a major change, given how small the list it is sorting is, though perf is always a surprise so it always could be...

Am I reading the summary charts correctly when I say the walltime regressions only persists in doc builds?

@the8472
Copy link
Copy Markdown
Member

the8472 commented Apr 6, 2026

Actually, that's just in the summary charts, where churn from other PRs can easily mask it if they happen to be an improvement.

Going back to individual benchmarks shows that unicode-normalization, tuple-stress and ucd are persistent and not limited to doc benchmarks.

image image

@apiraino
Copy link
Copy Markdown
Contributor

apiraino commented Apr 9, 2026

hey @Bryntet @JonathanBrouwer @jdonszelmann 👋

I notice a number of issues popping up linked to this PR. Tomorrow a beta branching is scheduled and a crater run will soon run on it. My vague feeling is that we might get a number of regressions and then we need to fix and backport them.

So, what is your gut feeling about #154906? Would it solve all/most of the issues I see linked to this PR? And what do you think about temporarily reverting this PR to give us a bit more time before the beta cut?

Leaving a note here as today we have the weekly compiler triage (on Zulip), so possibly also include your opinion first (feel free to stop by if you want).

and thanks :)

@Bryntet
Copy link
Copy Markdown
Contributor Author

Bryntet commented Apr 9, 2026

I think temporarily reverting this PR may be wise.

I think #154906 fixes most problems from this PR (especially those that would commonly be stumbled upon by end users), but the way it does so is not so idiomatic, and preferably still needs some work

I don't know what the process for reverting/not including a PR in beta, but I'd love to help in anyway I can

@JonathanBrouwer
Copy link
Copy Markdown
Contributor

I'll take a look later today at what the best option is here, this will be a painful revert because of the large amount of changes since this pr, but it might be needed

@Bryntet
Copy link
Copy Markdown
Contributor Author

Bryntet commented Apr 9, 2026

Right, didn't think of that. This could indeed be quite painful to revert.

@JonathanBrouwer
Copy link
Copy Markdown
Contributor

JonathanBrouwer commented Apr 9, 2026

To summarize, we currently have the following regressions:

  1. [ICE]: cannot decode AttrId with CacheDecoder #154878
  2. [ICE]: malformed lint attributes #154800
  3. #[expect] doesn't work anymore with pre-expansion early lints #155008
  4. Minor regression in walltime perf, even tho there is an improvement in instruction counts. We can likely just accept this.
  5. Possibly more regressions since this is a relatively recently merged PR

Because of this, I believe the best decision is to revert. Note that I still believe this PR to be awesome and I think we will re-land it with the fixes on top in the near future, but I have limited time and I don't want to cause time pressure on a project that we're all contributing to for fun, because that is a path doomed to burnout <3

Because quite a few PRs already landed on top of this one reverting will be painful. I will see if I can get a revert up before the beta cutoff, but no promises. Otherwise we can beta-nominate the revert.

@JonathanBrouwer
Copy link
Copy Markdown
Contributor

JonathanBrouwer commented Apr 9, 2026

Revert was surprisingly painless, there were quite a few conflicts but they solved relatively easy
#155056

bug!("tools required while parsing attributes");
};

let tools = tools.iter().map(|tool| tool.name).collect::<Vec<_>>();
Copy link
Copy Markdown
Contributor

@cjgillot cjgillot Mar 5, 2026

Choose a reason for hiding this comment

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

View changes since the review

Do we really need to collect here, or could we change the tools.contains check below to use cx.tools directly?

Comment on lines +235 to +246
if !skip_reason_check && !errored && lint_instances.is_empty() {
cx.warn_empty_attribute(cx.attr_span);
}

(!errored).then_some(LintAttribute {
reason,
lint_instances,
attr_span: cx.attr_span,
attr_style: cx.attr_style,
attr_id: HashIgnoredAttrId { attr_id: cx.attr_id },
attr_index,
})
Copy link
Copy Markdown
Contributor

@cjgillot cjgillot Mar 5, 2026

Choose a reason for hiding this comment

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

View changes since the review

Suggested change
if !skip_reason_check && !errored && lint_instances.is_empty() {
cx.warn_empty_attribute(cx.attr_span);
}
(!errored).then_some(LintAttribute {
reason,
lint_instances,
attr_span: cx.attr_span,
attr_style: cx.attr_style,
attr_id: HashIgnoredAttrId { attr_id: cx.attr_id },
attr_index,
})
if errored {
return None;
}
if !skip_reason_check && lint_instances.is_empty() {
cx.warn_empty_attribute(cx.attr_span);
}
Some(LintAttribute {
reason,
lint_instances,
attr_span: cx.attr_span,
attr_style: cx.attr_style,
attr_id: HashIgnoredAttrId { attr_id: cx.attr_id },
attr_index,
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. T-clippy Relevant to the Clippy team. T-compiler Relevant 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.

10 participants