Skip to content

Port lint attributes to attribute parser#152369

Open
Bryntet wants to merge 13 commits intorust-lang:mainfrom
Bryntet:lint_attrs
Open

Port lint attributes to attribute parser#152369
Bryntet wants to merge 13 commits intorust-lang:mainfrom
Bryntet:lint_attrs

Conversation

@Bryntet
Copy link
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
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
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
also add attr_id to `Stable` variant directly, instead of having to
iterate over all the attrs on the hir_id to find it
also changes method `parse_limited_all` to take Iterator as an input,
to avoid needing to do expensive allocation
@rustbot
Copy link
Collaborator

rustbot commented Feb 26, 2026

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.

@Bryntet
Copy link
Contributor Author

Bryntet commented Feb 26, 2026

@bors try

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Feb 26, 2026
Port lint attributes to attribute parser
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

also removes E0452 and splits
`tests/rustdoc-ui/lints/renamed-lint-still-applies` into 2 tests

this is because of delayed warn lint being lost on compiler aborting on
error
also buffer any lints coming from pre-expansion, so that they are
emitted with proper lint level
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 26, 2026

☀️ Try build successful (CI)
Build commit: c5d8004 (c5d80041ba21dca2acce5d36c44b3f0a06ecc4e6, parent: 69b78537fac74de40f009b076bcbbf54b77683ad)

@rust-timer

This comment has been minimized.

@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-20-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
/dev/sda15       98M  6.4M   92M   7% /boot/efi
tmpfs           1.6G   16K  1.6G   1% /run/user/1001
================================================================================

Sufficient disk space available (120900768KB >= 52428800KB). Skipping cleanup.
##[group]Run echo "[CI_PR_NUMBER=$num]"
echo "[CI_PR_NUMBER=$num]"
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
---
set -ex

# Run a subset of tests. Used to run tests in parallel in multiple jobs.

# When this job partition is run as part of PR CI, skip tidy to allow revealing more failures. The
# dedicated `tidy` job failing won't block other PR CI jobs from completing, and so tidy failures
# shouldn't inhibit revealing other failures in PR CI jobs.
if [ "$PR_CI_JOB" == "1" ]; then
  echo "PR_CI_JOB set; skipping tidy"
  SKIP_TIDY="--skip tidy"
fi

../x.py --stage 2 test \
  ${SKIP_TIDY:+$SKIP_TIDY} \
  --skip compiler \
  --skip src
#!/bin/bash

set -ex

# Run a subset of tests. Used to run tests in parallel in multiple jobs.

# When this job partition is run as part of PR CI, skip tidy to allow revealing more failures. The
# dedicated `tidy` job failing won't block other PR CI jobs from completing, and so tidy failures
# shouldn't inhibit revealing other failures in PR CI jobs.
if [ "$PR_CI_JOB" == "1" ]; then
  echo "PR_CI_JOB set; skipping tidy"
  SKIP_TIDY="--skip tidy"
fi

../x.py --stage 2 test \
  ${SKIP_TIDY:+$SKIP_TIDY} \
  --skip tests \
  --skip coverage-map \
  --skip coverage-run \
  --skip library \
  --skip tidyselftest
---
Executing "/scripts/stage_2_test_set2.sh"
+ /scripts/stage_2_test_set2.sh
PR_CI_JOB set; skipping tidy
+ '[' 1 == 1 ']'
+ echo 'PR_CI_JOB set; skipping tidy'
+ SKIP_TIDY='--skip tidy'
+ ../x.py --stage 2 test --skip tidy --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.04s
##[endgroup]
downloading https://static.rust-lang.org/dist/2026-01-21/rustfmt-nightly-aarch64-unknown-linux-gnu.tar.xz
---
cannot access a scoped thread local variable without calling `set` first
stack backtrace:
   0: std::panicking::begin_panic
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/std/src/panicking.rs:761:5
   1: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::with::<<rustc_span::symbol::Symbol>::intern::{closure#0}, rustc_span::symbol::Symbol>
   2: <alloc::vec::into_iter::IntoIter<(alloc::string::String, rustc_lint_defs::Level)> as core::iter::traits::iterator::Iterator>::fold::<(), core::iter::adapters::map::map_fold<(alloc::string::String, rustc_lint_defs::Level), (rustc_span::symbol::Symbol, rustc_lint_defs::Level), (), <rustdoc::config::Options>::from_matches::{closure#1}, core::iter::traits::iterator::Iterator::for_each::call<(rustc_span::symbol::Symbol, rustc_lint_defs::Level), <alloc::vec::Vec<(rustc_span::symbol::Symbol, rustc_lint_defs::Level)>>::extend_trusted<core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<(alloc::string::String, rustc_lint_defs::Level)>, <rustdoc::config::Options>::from_matches::{closure#1}>>::{closure#0}>::{closure#0}>::{closure#0}>
   3: <alloc::vec::Vec<(rustc_span::symbol::Symbol, rustc_lint_defs::Level)> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<(rustc_span::symbol::Symbol, rustc_lint_defs::Level), core::iter::adapters::map::Map<alloc::vec::into_iter::IntoIter<(alloc::string::String, rustc_lint_defs::Level)>, <rustdoc::config::Options>::from_matches::{closure#1}>>>::from_iter
   4: <rustdoc::config::Options>::from_matches
   5: rustdoc::main_args
   6: rustc_span::fatal_error::catch_fatal_errors::<rustdoc::main::{closure#1}, ()>
   7: rustdoc::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: the compiler unexpectedly panicked. This is a bug

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-rustdoc&template=ice.md

note: please make sure that you have updated to the latest nightly

warning: the ICE couldn't be written to `/checkout/rustc-ice-2026-02-26T16_20_17-52313.txt`: Read-only file system (os error 30)

note: rustc 1.95.0-nightly (05ab7d1c8 2026-02-26) running on aarch64-unknown-linux-gnu

note: compiler flags: --crate-type lib -Z --test-args -C embed-bitcode=no -C symbol-mangling-version=v0 -Z annotate-moves -Z randomize-layout -Z unstable-options -Z crate-attr=warn(rust_2018_idioms) -Z force-unstable-if-unmarked -Z crate-attr=doc(rust_logo) -Z crate-attr=doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/") -Z crate-attr=feature(rustdoc_internals)

query stack during panic:
end of query stack
error: doctest failed, to rerun pass `-p rustc_abi --doc`
Bootstrap failed while executing `--stage 2 test --skip tidy --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest`

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (c5d8004): comparison URL.

Overall result: ❌ regressions - BENCHMARK(S) FAILED

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

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

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

  • tt-muncher
  • unicode-normalization-0.1.24
  • image-0.25.6
  • helloworld
  • large-workspace
  • bitmaps-3.2.1
  • include-blob
  • await-call-tree
  • coercions
  • eza-0.21.2
  • unused-warnings
  • clap_derive-4.5.32
  • externs
  • tuple-stress
  • issue-46449
  • cranelift-codegen-0.119.0
  • projection-caching
  • Job failure
  • libc-0.2.172
  • unify-linearly
  • hyper-1.6.0
  • nalgebra-0.33.0
  • deeply-nested-multi
  • ripgrep-14.1.1
  • issue-58319
  • syn-2.0.101
  • issue-88862
  • ucd
  • wf-projection-stress-65510
  • regression-31157
  • serde_derive-1.0.219
  • serde-1.0.219
  • stm32f4-0.15.1
  • wg-grammar
  • diesel-2.2.10
  • serde-1.0.219-threads4
  • derive
  • deep-vector
  • regex-automata-0.4.8
  • token-stream-stress
  • cargo-0.87.1
  • many-assoc-items
  • typenum-1.18.0
  • ctfe-stress-5
  • html5ever-0.31.0
  • match-stress

❗ ❗ ❗ ❗ ❗

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)
1.1% [0.2%, 6.0%] 106
Regressions ❌
(secondary)
0.4% [0.0%, 1.5%] 96
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.4% [-0.4%, -0.4%] 1
All ❌✅ (primary) 1.1% [0.2%, 6.0%] 106

Max RSS (memory usage)

Results (primary -0.5%, 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)
2.1% [2.1%, 2.1%] 1
Regressions ❌
(secondary)
4.2% [1.9%, 6.8%] 6
Improvements ✅
(primary)
-1.4% [-2.6%, -0.7%] 3
Improvements ✅
(secondary)
-1.9% [-2.2%, -1.4%] 3
All ❌✅ (primary) -0.5% [-2.6%, 2.1%] 4

Cycles

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

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 480.132s -> 482.287s (0.45%)
Artifact size: 395.80 MiB -> 396.08 MiB (0.07%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 26, 2026
@JonathanBrouwer
Copy link
Contributor

@rustbot author

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 27, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 27, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 27, 2026
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.

7 participants