rust
rust copied to clipboard
Infrastructure for lints during attribute parsing, specifically duplicate usages of attributes
r? @oli-obk
This PR adds a new field to OwnerInfo to buffer lints which are generated during attribute parsing and ast lowering in general. They can't be emitted at this stage because at that point there's no HIR yet, and early lints are already emitted.
This also adds the generic S: Stage to attribute parsers. Currently we don't emit any lints during early attribute parsing, but if we ever want to that logic will be different. That's because there we don't have hir ids yet, while at the same time still having access to node ids and early lints. Even though that logic isn't completely there in this PR (no worries, we don't use it), that's why the parameter is there.
With this PR, we also add 2 associated consts to SingleAttributeParser. Those determine what logic should be applied when finding a duplicate attribute.
This PR was getting pretty large, so the first code using this logic is in rust-lang/rust#138165. This code is all new things that weren't possible before so it also doesn't break any behaviour. However, some of it will be dead code right now. I recommend reviewing both before merging, though in some sense that doubles the size of the review again, and the other PR might be more controversial. Let me know how you want to do this @oli-obk
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.
There are merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.
You can start a rebase with the following commands:
$ # rebase
$ git pull --rebase https://github.com/rust-lang/rust.git master
$ git push --force-with-lease
The following commits are merge commits:
- 154b756b751cf8a55b26d0e8fede9844e207e8f3
- 3bc6ba043a2800be2436835966606d934e0f0c77
(am aware of merge commits, was just an easy way to get those changes in before they're on master so we can run CI on this PR. will obviously remove once those changes are on master and this PR can be merged)
The job mingw-check failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
Documenting rustc_target v0.0.0 (/checkout/compiler/rustc_target)
error: unresolved link to `rustc_attr_parsing::find_attr`
--> compiler/rustc_middle/src/ty/mod.rs:1761:70
|
1761 | /// To see if an item has a specific attribute, you should use [`rustc_attr_parsing::find_attr!`] so you can use matching.
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `rustc_attr_parsing` in scope
= note: `-D rustdoc::broken-intra-doc-links` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(rustdoc::broken_intra_doc_links)]`
Documenting rustc_error_messages v0.0.0 (/checkout/compiler/rustc_error_messages)
Documenting rustc_error_messages v0.0.0 (/checkout/compiler/rustc_error_messages)
error: could not document `rustc_middle`
warning: build failed, waiting for other jobs to finish...
Command has failed. Rerun with -v to see more details.
local time: Fri Mar 7 15:12:55 UTC 2025
network time: Fri, 07 Mar 2025 15:12:55 GMT
##[error]Process completed with exit code 1.
Post job cleanup.
The job mingw-check failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
#20 ERROR: rpc error: code = Canceled desc = grpc: the client connection is closing
------
> exporting to docker image format:
------
ERROR: failed to solve: Canceled: rpc error: code = Canceled desc = grpc: the client connection is closing
#0 building with "jolly_nightingale" instance using docker-container driver
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 3.37kB done
---
Documenting rustc_type_ir v0.0.0 (/checkout/compiler/rustc_type_ir)
error: unresolved link to `rustc_attr_parsing::find_attr`
--> compiler/rustc_middle/src/ty/mod.rs:1761:70
|
1761 | /// To see if an item has a specific attribute, you should use [`rustc_attr_parsing::find_attr!`] so you can use matching.
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `rustc_attr_parsing` in scope
= note: `-D rustdoc::broken-intra-doc-links` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(rustdoc::broken_intra_doc_links)]`
Documenting rustc_attr_data_structures v0.0.0 (/checkout/compiler/rustc_attr_data_structures)
Documenting rustc_attr_data_structures v0.0.0 (/checkout/compiler/rustc_attr_data_structures)
error: could not document `rustc_middle`
warning: build failed, waiting for other jobs to finish...
Command has failed. Rerun with -v to see more details.
local time: Sat Mar 8 19:30:55 UTC 2025
network time: Sat, 08 Mar 2025 19:30:55 GMT
##[error]Process completed with exit code 1.
Post job cleanup.
The job mingw-check failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
Documenting rustc_abi v0.0.0 (/checkout/compiler/rustc_abi)
error: unresolved link to `crate::context::ATTRIBUTE_MAPPING`
--> compiler/rustc_attr_parsing/src/attributes/mod.rs:15:57
|
15 | //! Attributes should be added to [`ATTRIBUTE_MAPPING`](crate::context::ATTRIBUTE_MAPPING) to be parsed.
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `ATTRIBUTE_MAPPING` in module `context`
= note: `-D rustdoc::broken-intra-doc-links` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(rustdoc::broken_intra_doc_links)]`
error: unresolved link to `AttributeDuplicates`
error: unresolved link to `AttributeDuplicates`
--> compiler/rustc_attr_parsing/src/attributes/mod.rs:145:35
|
145 | /// duplicate reason (see [`AttributeDuplicates`])
| ^^^^^^^^^^^^^^^^^^^ no item named `AttributeDuplicates` in scope
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
error: could not document `rustc_attr_parsing`
warning: build failed, waiting for other jobs to finish...
warning: build failed, waiting for other jobs to finish...
Command has failed. Rerun with -v to see more details.
local time: Sun Mar 9 15:58:46 UTC 2025
network time: Sun, 09 Mar 2025 15:58:46 GMT
##[error]Process completed with exit code 1.
Post job cleanup.
The job x86_64-gnu-tools failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
:umbrella: The latest upstream changes (presumably #138388) made this pull request unmergeable. Please resolve the merge conflicts.
@rustbot review
cc @workingjubilee
The job mingw-check-2 failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
Documenting rustc_incremental v0.0.0 (/checkout/compiler/rustc_incremental)
error: unresolved link to `AttributeKind::Stability`
--> compiler/rustc_attr_parsing/src/lib.rs:65:7
|
65 | //! [`AttributeKind::Stability`].
| ^^^^^^^^^^^^^^^^^^^^^^^^ no item named `AttributeKind` in scope
|
= note: `-D rustdoc::broken-intra-doc-links` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(rustdoc::broken_intra_doc_links)]`
error: could not document `rustc_attr_parsing`
warning: build failed, waiting for other jobs to finish...
Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:01:30
local time: Mon Jun 9 23:27:15 UTC 2025
network time: Mon, 09 Jun 2025 23:27:15 GMT
##[error]Process completed with exit code 1.
Post job cleanup.
@rustbot review
The job x86_64-gnu-llvm-19 failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
#18 exporting to docker image format
#18 sending tarball 26.8s done
#18 DONE 42.5s
##[endgroup]
Setting extra environment values for docker: --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-19]
[CI_JOB_NAME=x86_64-gnu-llvm-19]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Listening on address 127.0.0.1:4226
##[group]Configure the build
configure: processing command line
configure:
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-19', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'build.print-step-timings', '--enable-verbose-tests', '--set', 'build.metrics', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--set', 'gcc.download-ci-gcc=true', '--enable-new-symbol-mangling']
configure: build.build := x86_64-unknown-linux-gnu
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-19/bin/llvm-config
configure: llvm.link-shared := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
The job mingw-check-2 failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
thanks! let's hope this is the one

:pushpin: Commit 92205a20c8a551f750033779d80755eccde7eed3 has been approved by oli-obk
It is now in the queue for this repository.
:umbrella: The latest upstream changes (presumably #142381) made this pull request unmergeable. Please resolve the merge conflicts.
@bors r=oli_obk
:pushpin: Commit e2afe04e2e45aff24bcc4e78cae04acdba8edcef has been approved by oli_obk
It is now in the queue for this repository.
@bors r=oli-obk
:bulb: This pull request was already approved, no need to approve it again.
- There's another pull request that is currently being tested, blocking this pull request: #142399
:pushpin: Commit e2afe04e2e45aff24bcc4e78cae04acdba8edcef has been approved by oli-obk
It is now in the queue for this repository.
There are several open PRs touching adjacent areas that will conflict with this, and there is somewhat-timing-sensitive work that is strictly blocked on this. Bumping its priority accordingly.
@bors p=1 rollup=iffy
( Ideally it just lands in the rollup currently trying to land though. )
:hourglass: Testing commit e2afe04e2e45aff24bcc4e78cae04acdba8edcef with merge 573a01569000d395498a5f98f916d6e5305ac81a...
@workingjubilee I'm happy this gets merged but some of those I deliberately didn't r+ yet to wait for this one but this makes sure it work :)
:sunny: Test successful - checks-actions Approved by: oli-obk Pushing 573a01569000d395498a5f98f916d6e5305ac81a to master...
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 6c8138de8f1c96b2f66adbbc0e37c73525444750 (parent) -> 573a01569000d395498a5f98f916d6e5305ac81a (this PR)
Test differences
Show 147 test diffs
Stage 1
session_diagnostics::verify_attr_parsing_empty_confusables_30: pass -> [missing] (J0)session_diagnostics::verify_attr_parsing_empty_confusables_31: [missing] -> pass (J0)session_diagnostics::verify_attr_parsing_repr_ident_31: pass -> [missing] (J0)session_diagnostics::verify_attr_parsing_repr_ident_32: [missing] -> pass (J0)session_diagnostics::verify_attr_parsing_stability_outside_std_29: pass -> [missing] (J0)session_diagnostics::verify_attr_parsing_stability_outside_std_30: [missing] -> pass (J0)session_diagnostics::verify_attr_parsing_unrecognized_repr_hint_32: pass -> [missing] (J0)session_diagnostics::verify_attr_parsing_unrecognized_repr_hint_33: [missing] -> pass (J0)session_diagnostics::verify_attr_parsing_unused_duplicate_29: [missing] -> pass (J0)
Additionally, 138 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 573a01569000d395498a5f98f916d6e5305ac81a --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
- x86_64-apple-2: 5058.2s -> 6576.6s (30.0%)
- x86_64-apple-1: 7328.3s -> 9029.2s (23.2%)
- dist-x86_64-msvc-alt: 7179.2s -> 8838.4s (23.1%)
- dist-various-1: 4293.5s -> 4917.7s (14.5%)
- dist-x86_64-apple: 9693.9s -> 10934.9s (12.8%)
- dist-android: 2388.0s -> 2613.8s (9.5%)
- dist-apple-various: 6971.2s -> 6390.0s (-8.3%)
- dist-x86_64-solaris: 5465.3s -> 5020.7s (-8.1%)
- dist-aarch64-linux: 6155.9s -> 5682.4s (-7.7%)
- x86_64-mingw-1: 9148.9s -> 8527.6s (-6.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.
Finished benchmarking commit (573a01569000d395498a5f98f916d6e5305ac81a): comparison URL.
Overall result: ❌ regressions - 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-triagedto 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-performanceworking 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.5% | [0.1%, 1.0%] | 107 |
| Regressions ❌ (secondary) |
1.0% | [0.1%, 3.1%] | 56 |
| Improvements ✅ (primary) |
- | - | 0 |
| Improvements ✅ (secondary) |
- | - | 0 |
| All ❌✅ (primary) | 0.5% | [0.1%, 1.0%] | 107 |
Max RSS (memory usage)
Results (primary 1.7%, secondary 3.1%)
A less reliable metric. May be of interest, but not used to determine the overall result above.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
1.7% | [0.4%, 7.3%] | 9 |
| Regressions ❌ (secondary) |
4.4% | [1.0%, 13.6%] | 9 |
| Improvements ✅ (primary) |
- | - | 0 |
| Improvements ✅ (secondary) |
-8.5% | [-8.5%, -8.5%] | 1 |
| All ❌✅ (primary) | 1.7% | [0.4%, 7.3%] | 9 |
Cycles
Results (primary -1.0%, secondary 1.7%)
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.3% | [1.6%, 2.7%] | 6 |
| Improvements ✅ (primary) |
-1.0% | [-1.0%, -1.0%] | 1 |
| Improvements ✅ (secondary) |
-1.6% | [-1.6%, -1.6%] | 1 |
| All ❌✅ (primary) | -1.0% | [-1.0%, -1.0%] | 1 |
Binary size
This benchmark run did not return any relevant results for this metric.
Bootstrap: 754.987s -> 754.801s (-0.02%) Artifact size: 372.08 MiB -> 372.21 MiB (0.03%)