Skip to content

Permit {This} in diagnostic attribute format literals#155662

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
mejrs:this_the_thing
Apr 25, 2026
Merged

Permit {This} in diagnostic attribute format literals#155662
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
mejrs:this_the_thing

Conversation

@mejrs
Copy link
Copy Markdown
Contributor

@mejrs mejrs commented Apr 22, 2026

My motivation was that yesterday I wanted to write something like this and reference $name in the string literal.

pub mod sym {
   // stuff here
}

macro_rules! my_macro {
    ($name:ident $(,)?) => {{
        #[diagnostic::on_unknown(
            message = "this is not present in symbol table",
            note = "you must add it to rustc_span::symbol::symbol!"
        )]
        use sym::$name as name;
        // ...
    }}
}

That is (as far as I can tell) impossible or at least very unergonomic. This adds the ability to just reference the name of the item the attribute is on. I imagine that's useful for use inside macros generally, so it's also added for some other attributes.

The affected attributes are all unstable, it is not implemented for diagnostic::on_unimplemented (will do in its own PR).

Note that {This} is already usable in #[rustc_on_unimplemented], so this does not implement it but just enables some more.

This PR also migrates one lint away from AttributeLintKind, and improves the messages for that lint.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 22, 2026

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 22, 2026
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 22, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 22, 2026

r? @petrochenkov

rustbot has assigned @petrochenkov.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 72 candidates
  • Random selection from 16 candidates

@mejrs mejrs force-pushed the this_the_thing branch 2 times, most recently from ab6b807 to f3f19dd Compare April 22, 2026 23:26
@rustbot

This comment has been minimized.

Comment thread compiler/rustc_resolve/src/imports.rs
Comment thread tests/ui/diagnostic_namespace/on_move/on_move_with_format.rs Outdated
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 23, 2026
@mejrs mejrs force-pushed the this_the_thing branch 2 times, most recently from 4749ea0 to ae94821 Compare April 23, 2026 20:35
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 23, 2026

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

cc @jdonszelmann, @JonathanBrouwer

@rustbot

This comment has been minimized.

@mejrs mejrs added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 23, 2026
@petrochenkov
Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 24, 2026

📌 Commit ae94821 has been approved by petrochenkov

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 24, 2026
@rust-bors

This comment has been minimized.

@rust-bors rust-bors Bot removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Apr 24, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 24, 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.

@mejrs
Copy link
Copy Markdown
Contributor Author

mejrs commented Apr 24, 2026

@bors r=petrochenkov

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 24, 2026

📌 Commit c2916be has been approved by petrochenkov

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 24, 2026
@rust-bors

This comment has been minimized.

@rust-bors rust-bors Bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 25, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 25, 2026

☀️ Test successful - CI
Approved by: petrochenkov
Duration: 3h 25m 47s
Pushing 80729d7 to main...

@rust-bors rust-bors Bot merged commit 80729d7 into rust-lang:main Apr 25, 2026
12 checks passed
@rustbot rustbot added this to the 1.97.0 milestone Apr 25, 2026
@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 7c61a35 (parent) -> 80729d7 (this PR)

Test differences

Show 16 test diffs

Stage 1

  • [ui] tests/ui/diagnostic_namespace/on_unknown/this_format_argument.rs: [missing] -> pass (J0)

Stage 2

  • [ui] tests/ui/diagnostic_namespace/on_unknown/this_format_argument.rs: [missing] -> pass (J1)

Additionally, 14 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 80729d7ce0ec05aef7a33d9892484cfd5cf34675 --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. pr-check-2: 35m 40s -> 45m 3s (+26.3%)
  2. x86_64-mingw-2: 2h 11m -> 2h 43m (+24.3%)
  3. i686-gnu-nopt-1: 2h 24m -> 1h 49m (-24.1%)
  4. x86_64-gnu-llvm-21-3: 1h 33m -> 1h 50m (+19.2%)
  5. arm-android: 1h 44m -> 1h 28m (-15.0%)
  6. dist-ohos-aarch64: 1h 2m -> 1h 12m (+14.6%)
  7. dist-ohos-x86_64: 1h 14m -> 1h 4m (-13.8%)
  8. dist-sparcv9-solaris: 1h 32m -> 1h 20m (-13.5%)
  9. pr-check-1: 33m 50s -> 29m 23s (-13.2%)
  10. x86_64-mingw-1: 2h 25m -> 2h 43m (+12.5%)
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 (80729d7): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -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
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.2% [-0.3%, -0.2%] 13
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary -1.9%)

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)
1.8% [1.1%, 2.2%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-5.6% [-7.7%, -1.6%] 3
All ❌✅ (primary) - - 0

Cycles

Results (secondary -8.5%)

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)
-8.5% [-19.4%, -2.4%] 3
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 491.842s -> 492.349s (0.10%)
Artifact size: 394.33 MiB -> 394.32 MiB (-0.00%)

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. 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.

4 participants