Skip to content

port lint attributes - #162811

Merged
rust-bors[bot] merged 8 commits into
rust-lang:mainfrom
mejrs:port_lint_check
Oct 13, 2026
Merged

rust-bors[bot] merged 8 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

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 think this is minor enough that I'll put it on my todo list as something that we should fix after merging this PR

@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
Comment thread tests/ui/unpretty/exhaustive.hir.stdout
@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
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@mejrs

mejrs commented Oct 12, 2026 •

Copy link
Copy Markdown
Member Author

I went through the PR and collected a list of items for follow up PRs. Not all are things we definitely want to do, but at least we can consider them:

Some thoughts on some of them:

* see if we can remove `rest: Option<Box[Symbol]>>` for perf

with register_tool comes the ability to define custom lint names (which can have as many segments as the user would like), so this will be a lang matter

* lint resolution in parsing [port lint attributes #162811 (comment)](https://github.com/rust-lang/rust/pull/162811#discussion_r4046648708)

If macro lints ever happen (in the form of #135432 or smth else) we likely need a tcx to resolve these lints, which cannot be done in attribute parsing

* remove unsafe? [port lint attributes #162811 (comment)](https://github.com/rust-lang/rust/pull/162811#discussion_r4173185326)

a "downcast_slice" method could also exist in std or e.g. rustc_data_structures.

* can we avoid calling `meta_item_list`? [port lint attributes #162811 (comment)](https://github.com/rust-lang/rust/pull/162811#discussion_r4173196063)

I think a "just try to parse this without actually erroring" might work (we kinda do this for diagnostic attributes), but it's a bit brittle for my liking, I'm also not sure I like ShouldEmit's state at this time.

Another option is to force pre-expansion lints to be crate level only (like #163714) but this would also be a lang (affects new_keyword lint) and clippy matter.

* Can we unify `LintCheckKind` and `Level`?

Level also has a ForceWarn variant, which has no lint check attribute counterpart.

@rust-bors

This comment has been minimized.

@rustbot

rustbot commented Oct 13, 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.

@rust-log-analyzer

This comment has been minimized.

@mejrs

mejrs commented Oct 13, 2026

Copy link
Copy Markdown
Member Author

@rustbot ready

@JonathanBrouwer JonathanBrouwer left a comment •

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'm looking at this, which is the rangediff since I last reviewed the PR
https://triagebot.infra.rust-lang.org/gh-range-diff/rust-lang/rust/a639ea0890c0977b1c45596fd6b5f9a70a1d67da..89b2c2ca86143266325fc3ddc3ae46d6b8077850/91e426a0518d5bb3672330c5238ccda6fd26fb54..ea4a0bd0643d32eddc2f0007ae38c09ec38aeed9

Why was the change in compiler/rustc_mir_build/src/thir/cx/expr.rs removed?
I liked having the lint attr check there

View changes since this review

@JonathanBrouwer

Copy link
Copy Markdown
Member

Ah @mejrs pointed out in DM that this entire codepath was removed by #163931

@JonathanBrouwer JonathanBrouwer left a comment •

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.

borsrplus in the style of the ToysRUs logo

(actually r=JonathanBrouwer,petrochenkov)
Thanks so much for the hard work in getting this attempt merged @mejrs

View changes since this review

@rust-bors

rust-bors Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

📌 Commit ea4a0bd has been approved by JonathanBrouwer,petrochenkov

It is now in the queue for this repository.

@JonathanBrouwer

This comment was marked as outdated.

@rust-bors

This comment was marked as outdated.

@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors rollup=never note=more likely than average to cause regressions, perf

@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors p=6
Scheduling

@rust-bors

This comment has been minimized.

@rust-bors

rust-bors Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

☀️ Test successful - CI
Approved by: JonathanBrouwer,petrochenkov
Duration: 3h 18m 54s
Pushing 822182d to main...

@github-actions

Copy link
Copy Markdown
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 1e16699 (parent) -> 822182d (this PR)

Test differences

Show 40 test diffs

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

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 822182db4c4a1827256881d8c7aa685f0bcf2b11 --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. test-x86_64-msvc-ext2: 1h 7m -> 1h 54m (+68.6%)
  2. test-x86_64-gnu-nopt: 1h 31m -> 2h 31m (+64.6%)
  3. dist-powerpc64le-linux-gnu: 1h 2m -> 1h 35m (+51.3%)
  4. dist-loongarch64-linux: 1h 23m -> 2h 6m (+50.4%)
  5. dist-x86_64-illumos: 1h 17m -> 1h 54m (+48.7%)
  6. test-x86_64-gnu: 2h 36m -> 1h 37m (-37.6%)
  7. test-x86_64-gnu-llvm-22-3: 2h 1m -> 1h 19m (-35.1%)
  8. test-x86_64-gnu-llvm-22-1: 1h 33m -> 1h 1m (-33.8%)
  9. test-x86_64-gnu-llvm-22: 58m 51s -> 39m 4s (-33.6%)
  10. dist-loongarch64-musl: 1h 34m -> 2h 5m (+33.3%)
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 (822182d): comparison URL.

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

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%] 6
Regressions ❌
(secondary)
0.2% [0.1%, 0.3%] 20
Improvements ✅
(primary)
-0.2% [-0.4%, -0.1%] 40
Improvements ✅
(secondary)
-0.2% [-0.4%, -0.1%] 10
All ❌✅ (primary) -0.2% [-0.4%, 0.2%] 46

Max RSS (memory usage)

Results (primary 4.5%, secondary 5.2%)

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

mean range count
Regressions ❌
(primary)
4.5% [4.5%, 4.5%] 1
Regressions ❌
(secondary)
5.2% [4.1%, 6.4%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 4.5% [4.5%, 4.5%] 1

Cycles

Results (secondary -6.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)
-6.0% [-7.1%, -5.0%] 2
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 487.497s -> 485.154s (-0.48%)
Artifact size: 406.62 MiB -> 406.56 MiB (-0.02%)

@JonathanBrouwer

Copy link
Copy Markdown
Member

@rustbot label: +perf-regression-triaged

This matches expectations.
Improvements outweigh regressions, and there are some ideas for possible further improvements

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.

8 participants