Skip to content

port lint attributes - #162811

Open
mejrs wants to merge 1 commit into
rust-lang:mainfrom
mejrs:port_lint_check
Open

mejrs wants to merge 1 commit 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
@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-log-analyzer

This comment has been minimized.

@blyxyas

blyxyas commented Sep 15, 2026

Copy link
Copy Markdown
Member

Does this still filter allow-ed lints? I'm not sure if we have tests for lint filtering.

@rust-bors

rust-bors Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 963f3c5 (963f3c572f18e6b9322ac395768e693238957bad)
Base parent: 1936d44 (1936d44457352da43b2d740672b940ebc715ac38)

@rust-timer

This comment has been minimized.

@Bryntet

This comment was marked as resolved.

@mejrs

mejrs commented Sep 15, 2026

Copy link
Copy Markdown
Member Author

The job test-aarch64-gnu-llvm-21-1 failed! Check out the build log: (web) (plain enhanced) (plain)

when I was working on lint attrs, I remember also running into this target having errors

I did not bless pretty tests (they don't matter here, the second commit is just for benchmarking)

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 15, 2026
…nBrouwer,petrochenkov

Pre lint port cleanups

Some minor changes split off from rust-lang#162811, to make that a bit easier to review.

cc @JonathanBrouwer
@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (963f3c5): 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.5% [0.1%, 2.8%] 170
Regressions ❌
(secondary)
0.8% [0.1%, 4.7%] 155
Improvements ✅
(primary)
-36.3% [-77.2%, -10.6%] 4
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.3% [-77.2%, 2.8%] 174

Max RSS (memory usage)

Results (primary -9.2%, secondary -1.6%)

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

mean range count
Regressions ❌
(primary)
1.8% [0.6%, 3.0%] 2
Regressions ❌
(secondary)
4.0% [2.5%, 4.9%] 3
Improvements ✅
(primary)
-20.2% [-22.6%, -17.8%] 2
Improvements ✅
(secondary)
-7.2% [-9.5%, -3.7%] 3
All ❌✅ (primary) -9.2% [-22.6%, 3.0%] 4

Cycles

Results (primary -10.3%, secondary 3.0%)

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

mean range count
Regressions ❌
(primary)
2.9% [2.0%, 4.1%] 8
Regressions ❌
(secondary)
3.3% [1.8%, 5.2%] 18
Improvements ✅
(primary)
-36.8% [-77.7%, -10.1%] 4
Improvements ✅
(secondary)
-3.4% [-3.4%, -3.4%] 1
All ❌✅ (primary) -10.3% [-77.7%, 4.1%] 12

Binary size

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

Bootstrap: 495.925s -> 499.736s (0.77%)
Artifact size: 406.90 MiB -> 407.72 MiB (0.20%)

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

mejrs commented Sep 15, 2026

Copy link
Copy Markdown
Member Author

Does this still filter allow-ed lints? I'm not sure if we have tests for lint filtering.

What do you mean?

@mejrs

mejrs commented Sep 15, 2026

Copy link
Copy Markdown
Member Author

woops, here we go again

    thread 'rustc' (290057) panicked at /rustc-dev/963f3c572f18e6b9322ac395768e693238957bad/compiler/rustc_middle/src/query/on_disk_cache.rs:662:9:
    cannot decode `AttrId` with `CacheDecoder`

rust-bors Bot pushed a commit that referenced this pull request Sep 16, 2026
Rollup merge of #162813 - mejrs:pre_lint_cleanups, r=JonathanBrouwer,petrochenkov

Pre lint port cleanups

Some minor changes split off from #162811, to make that a bit easier to review.

cc @JonathanBrouwer
@rust-bors

This comment has been minimized.

@blyxyas

blyxyas commented Sep 16, 2026

Copy link
Copy Markdown
Member

What do you mean?

I mean, is the output from the skippable_lints query still faithful to the lint attributes?

@Bryntet

Bryntet commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

What do you mean?

I mean, is the output from the skippable_lints query still faithful to the lint attributes?

That query uses
tcx.shallow_lint_levels_on(hir::CRATE_OWNER_ID); to know about lints

which means that as long as shallow_lint_levels_on is consistent, it shouldn't break.

And we have plenty of testing for that

@rustbot

rustbot commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main 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.

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-blocked Status: Blocked on something else such as an RFC or other implementation work. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants