Skip to content

rustc_on_unimplemented: introduce format specifiers#156161

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
mejrs:this_formatargs
May 26, 2026
Merged

rustc_on_unimplemented: introduce format specifiers#156161
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
mejrs:this_formatargs

Conversation

@mejrs
Copy link
Copy Markdown
Contributor

@mejrs mejrs commented May 4, 2026

...as printing options for the annotated item.

See also the test and dev guide prose. This only affects rustc_on_unimplemented, not (yet) the other diagnostic attributes. I plan to do that in some later PR.

#![feature(rustc_attrs)]

#[rustc_on_unimplemented(
    message = "normal: {This}, path: {This:path},  resolved: {This:resolved}"
)]
pub trait Trait<'lifetime, const CONST_GENERIC: usize, A, B> where A: Send {}

will do:

normal: Trait, path: Trait<'lifetime, CONST_GENERIC, A, B>,  resolved: Trait<'_, 6, u8, _>

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 4, 2026

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

The rustc-dev-guide subtree was changed. If this PR only touches the dev guide consider submitting a PR directly to rust-lang/rustc-dev-guide otherwise thank you for updating the dev guide with your changes.

cc @BoxyUwU, @tshepang

Some changes occurred in compiler/rustc_hir/src/attrs

cc @jdonszelmann, @JonathanBrouwer

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

rustbot commented May 4, 2026

r? @dingxiangfei2009

rustbot has assigned @dingxiangfei2009.
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 73 candidates
  • Random selection from 19 candidates

@mejrs mejrs removed the T-libs Relevant to the library team, which will review and decide on the PR/issue. label May 4, 2026
@rust-log-analyzer

This comment has been minimized.

@mejrs mejrs force-pushed the this_formatargs branch from d3030bc to 008ea3a Compare May 5, 2026 16:26
@mejrs
Copy link
Copy Markdown
Contributor Author

mejrs commented May 14, 2026

r? compiler

@rustbot rustbot assigned oli-obk and unassigned dingxiangfei2009 May 14, 2026
Copy link
Copy Markdown
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors r+

since this seems to be a multi-step undertaking, please add a tracking issue and link to it from every PR that makes progress on it

View changes since this review

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 26, 2026

📌 Commit 008ea3a has been approved by oli-obk

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-review Status: Awaiting review from the assignee but also interested parties. labels May 26, 2026
@oli-obk
Copy link
Copy Markdown
Contributor

oli-obk commented May 26, 2026

@bors rollup

rust-bors Bot pushed a commit that referenced this pull request May 26, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #156959 (stdarch subtree update)
 - #156541 (delegation: remove method call generation)
 - #156161 (rustc_on_unimplemented: introduce format specifiers)
 - #156752 (fix E0371 description)
 - #156761 (tidy: remove duplicate entry and alphabetize OS constants list)
 - #156872 (Drop skip_move_check_fns query.)
 - #156899 (fix breakpoint callback registration in `lldb_batchmode`)
 - #156927 (Reorganize `tests/ui/issues` [1/N])
 - #156947 (Update mdbook to 0.5.3)
@rust-bors rust-bors Bot merged commit 903a08c into rust-lang:main May 26, 2026
11 checks passed
@rustbot rustbot added this to the 1.98.0 milestone May 26, 2026
rust-timer added a commit that referenced this pull request May 26, 2026
Rollup merge of #156161 - mejrs:this_formatargs, r=oli-obk

rustc_on_unimplemented: introduce format specifiers

...as printing options for the annotated item.

See also the test and dev guide prose. This only affects rustc_on_unimplemented, not (yet) the other diagnostic attributes. I plan to do that in some later PR.

```rust
#![feature(rustc_attrs)]

#[rustc_on_unimplemented(
    message = "normal: {This}, path: {This:path},  resolved: {This:resolved}"
)]
pub trait Trait<'lifetime, const CONST_GENERIC: usize, A, B> where A: Send {}
```
will do:
```
normal: Trait, path: Trait<'lifetime, CONST_GENERIC, A, B>,  resolved: Trait<'_, 6, u8, _>
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-rustc-dev-guide Area: rustc-dev-guide S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

5 participants