Skip to content

port lint attributes - #162811

Open
mejrs wants to merge 4 commits into
rust-lang:mainfrom
mejrs:port_lint_check
Open

mejrs wants to merge 4 commits into
rust-lang:mainfrom
mejrs:port_lint_check

Conversation

@mejrs

@mejrs mejrs commented Sep 15, 2026

Copy link
Copy Markdown
Member

View all comments

Ports the lint attributes. I've kept this as small as possible, but there is a decent amount of clean up/refactoring that can be done afterwards,

r? @JonathanBrouwer @jdonszelmann
cc @Bryntet

@rustbot

rustbot commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

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

cc @jdonszelmann, @JonathanBrouwer

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

Some changes occurred in compiler/rustc_attr_ir

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

clippy is developed in its own repository. If possible, consider making this change to rust-lang/rust-clippy instead.

cc @rust-lang/clippy

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 15, 2026
Comment on lines +10 to +11
LL | let y: u32 = (x?).try_into().unwrap();
| + +++++++++++++++++++++

@mejrs mejrs Sep 15, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Uh yeah I don't know what's happening here

View changes since the review

@JonathanBrouwer

Copy link
Copy Markdown
Member

I'll take a look at this on Friday! Thanks for doing this!

@Bryntet

Bryntet commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Thanks for picking this up ❤️

@JonathanBrouwer

Copy link
Copy Markdown
Member

cc @cjgillot @petrochenkov in case you'd like to take a look (as reviewers of the original pr #155691)

@mejrs

mejrs commented Sep 15, 2026

Copy link
Copy Markdown
Member Author

I'll take a look at this on Friday! Thanks for doing this!

I'll go ahead and cherrypick some changes from this PR then, some things can be split off.

@petrochenkov petrochenkov self-assigned this Sep 15, 2026
#[allow()]
{ }
}
fn expr_block() { { } unsafe { } 'a: { } { } { } }

@mejrs mejrs Sep 15, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We drop these empty lint attributes, this is nice because when we query for the attribute we know it's non-empty and we can do things like lints.first().unwrap()

View changes since the review

@mejrs mejrs mentioned this pull request Sep 15, 2026
@JonathanBrouwer JonathanBrouwer added the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Sep 15, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member

Blocked on #162813

@rust-log-analyzer

This comment has been minimized.

@mejrs

mejrs commented Sep 15, 2026

Copy link
Copy Markdown
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 15, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Sep 15, 2026
@rust-bors

rust-bors Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 837b948 (837b9481206c510936be02f4b200f8db8aae1286)
Base parent: 1936d44 (1936d44457352da43b2d740672b940ebc715ac38)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (837b948): comparison URL.

Overall result: ❌✅ regressions and improvements - BENCHMARK(S) FAILED

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

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

❗ ❗ ❗ ❗ ❗
Warning ⚠️: The following benchmark(s) failed to build:

  • image-0.25.6
  • Job failure

❗ ❗ ❗ ❗ ❗

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.6% [0.2%, 3.5%] 197
Regressions ❌
(secondary)
0.9% [0.1%, 5.8%] 170
Improvements ✅
(primary)
-36.2% [-77.2%, -10.4%] 4
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.1% [-77.2%, 3.5%] 201

Max RSS (memory usage)

Results (primary -7.1%, secondary -1.8%)

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

mean range count
Regressions ❌
(primary)
1.6% [0.6%, 3.1%] 3
Regressions ❌
(secondary)
3.5% [2.4%, 4.1%] 3
Improvements ✅
(primary)
-20.2% [-22.6%, -17.8%] 2
Improvements ✅
(secondary)
-7.1% [-9.4%, -3.6%] 3
All ❌✅ (primary) -7.1% [-22.6%, 3.1%] 5

Cycles

Results (primary -7.6%, secondary 2.7%)

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

mean range count
Regressions ❌
(primary)
3.0% [1.3%, 4.3%] 11
Regressions ❌
(secondary)
3.1% [2.0%, 5.2%] 16
Improvements ✅
(primary)
-36.8% [-77.7%, -10.0%] 4
Improvements ✅
(secondary)
-4.5% [-4.5%, -4.5%] 1
All ❌✅ (primary) -7.6% [-77.7%, 4.3%] 15

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 495.925s -> 496.275s (0.07%)
Artifact size: 406.90 MiB -> 407.07 MiB (0.04%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Sep 15, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 19, 2026
@rust-bors

rust-bors Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 6091374 (6091374e5f097ca91586512a9ae4c835892d1bb3)
Base parent: 36b04f3 (36b04f3ad12a98b1a3cf9efe5313306ef7d5848d)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (6091374): comparison URL.

Overall result: ❌ regressions - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never rustc-perf
@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.6% [0.1%, 3.4%] 190
Regressions ❌
(secondary)
1.0% [0.1%, 6.0%] 149
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.2% [-0.2%, -0.2%] 1
All ❌✅ (primary) 0.6% [0.1%, 3.4%] 190

Max RSS (memory usage)

Results (primary -2.4%, 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)
- - 0
Regressions ❌
(secondary)
2.5% [2.5%, 2.5%] 1
Improvements ✅
(primary)
-2.4% [-3.0%, -1.3%] 3
Improvements ✅
(secondary)
-3.1% [-5.2%, -0.4%] 4
All ❌✅ (primary) -2.4% [-3.0%, -1.3%] 3

Cycles

Results (primary 3.4%, 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)
3.4% [1.7%, 5.0%] 7
Regressions ❌
(secondary)
3.6% [2.0%, 5.4%] 18
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.4% [1.7%, 5.0%] 7

Binary size

Results (primary -0.1%, secondary -0.1%)

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.1% [-0.2%, -0.0%] 70
Improvements ✅
(secondary)
-0.1% [-0.2%, -0.0%] 53
All ❌✅ (primary) -0.1% [-0.2%, -0.0%] 70

Bootstrap: 497.193s -> 499.023s (0.37%)
Artifact size: 408.84 MiB -> 408.82 MiB (-0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 19, 2026
@mejrs

mejrs commented Sep 19, 2026

Copy link
Copy Markdown
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 19, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Sep 19, 2026
@rust-bors

rust-bors Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 4b49dca (4b49dca8eb42071c8cc3df24e58dedfe791172a8)
Base parent: feaadee (feaadeeaca7db0594da854e7c8c07495341c7439)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (4b49dca): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never rustc-perf
@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.3% [0.1%, 0.4%] 15
Regressions ❌
(secondary)
0.4% [0.2%, 1.0%] 27
Improvements ✅
(primary)
-0.2% [-0.3%, -0.1%] 4
Improvements ✅
(secondary)
-0.3% [-0.6%, -0.2%] 7
All ❌✅ (primary) 0.2% [-0.3%, 0.4%] 19

Max RSS (memory usage)

Results (primary -1.1%, secondary -2.2%)

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

mean range count
Regressions ❌
(primary)
1.7% [1.7%, 1.7%] 1
Regressions ❌
(secondary)
2.1% [2.1%, 2.1%] 1
Improvements ✅
(primary)
-3.9% [-3.9%, -3.9%] 1
Improvements ✅
(secondary)
-3.6% [-5.0%, -1.1%] 3
All ❌✅ (primary) -1.1% [-3.9%, 1.7%] 2

Cycles

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)
2.9% [2.9%, 2.9%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.0% [-3.0%, -3.0%] 1
All ❌✅ (primary) - - 0

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 502.551s -> 499.436s (-0.62%)
Artifact size: 406.86 MiB -> 408.95 MiB (0.51%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 19, 2026
@mejrs

mejrs commented Sep 19, 2026

Copy link
Copy Markdown
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 19, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Sep 19, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 9ae8a4a (9ae8a4a92916fb5730164bd285bbe4675e106e09)
Base parent: feaadee (feaadeeaca7db0594da854e7c8c07495341c7439)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (9ae8a4a): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never rustc-perf
@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.3% [0.1%, 0.4%] 13
Regressions ❌
(secondary)
0.4% [0.2%, 0.9%] 26
Improvements ✅
(primary)
-0.3% [-0.3%, -0.2%] 8
Improvements ✅
(secondary)
-0.4% [-0.6%, -0.3%] 6
All ❌✅ (primary) 0.1% [-0.3%, 0.4%] 21

Max RSS (memory usage)

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

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.8% [2.6%, 2.9%] 2
Improvements ✅
(primary)
-2.6% [-2.9%, -2.3%] 2
Improvements ✅
(secondary)
-4.3% [-4.3%, -4.3%] 2
All ❌✅ (primary) -2.6% [-2.9%, -2.3%] 2

Cycles

Results (primary 2.8%, secondary 0.7%)

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

mean range count
Regressions ❌
(primary)
2.8% [2.7%, 2.9%] 2
Regressions ❌
(secondary)
3.1% [2.9%, 3.3%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.0% [-4.0%, -4.0%] 1
All ❌✅ (primary) 2.8% [2.7%, 2.9%] 2

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 502.551s -> 496.987s (-1.11%)
Artifact size: 406.86 MiB -> 408.96 MiB (0.52%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 20, 2026
DUMMY_SP,
CRATE_NODE_ID,
Some(self.features),
ShouldEmit::ErrorsAndLints { recovery: Recovery::Allowed },

@Bryntet Bryntet Sep 20, 2026

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.

if you make this ShouldEmit::Nothing then the majority of all the duplicate lints go away. Issue is that this leads to delay_bug from pre-ast-expansion parsing which leads to ICE

there is a way to do this a bit hackily (basically in lintcheck parsing, check if ShouldEmit::Nothing and then never return an error)

there is also the possibility of changing how pre-ast-expansion emits lints. I've been considering making a PR where we change so that pre-ast-expansion doesn't parse lint attrs but instead just saves diagnostic + span and then that gets sent to the lint store that we instantiate later.

View changes since the review

@mejrs mejrs Sep 20, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

there is a way to do this a bit hackily (basically in lintcheck parsing, check if ShouldEmit::Nothing and then never return an error)

I don't really want to do this (especially not in this PR), it sounds rather brittle.

In any case I would prefer to just not parse these attributes at all, perhaps we can force all all pre-expansion lints to be crate level only which would sidestep this problem.

@rust-log-analyzer

This comment has been minimized.

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

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) perf-regression Performance regression. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

8 participants