Skip to content

rustc_on_unimplemented: introduce format specifiers#156161

Open
mejrs wants to merge 1 commit intorust-lang:mainfrom
mejrs:this_formatargs
Open

rustc_on_unimplemented: introduce format specifiers#156161
mejrs wants to merge 1 commit intorust-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
Copy link
Copy Markdown
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
##[endgroup]
Executing "/scripts/stage_2_test_set2.sh"
+ /scripts/stage_2_test_set2.sh
+ '[' 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
PR_CI_JOB set; skipping tidy
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.04s
##[endgroup]
---
---- tests::diagnostic_format_flags stdout ----

thread 'tests::diagnostic_format_flags' (51155) panicked at compiler/rustc_parse_format/src/tests.rs:565:5:
assertion `left == right` failed
  left: Argument { position: ArgumentNamed("thing"), position_span: 2..7, format: FormatSpec { fill: None, fill_span: None, align: AlignUnknown, sign: None, alternate: false, zero_pad: false, debug_hex: None, precision: CountImplied, precision_span: None, width: CountImplied, width_span: None, ty: "blah", ty_span: Some(7..12) } }
 right: Argument { position: ArgumentNamed("thing"), position_span: 2..7, format: FormatSpec { fill: None, fill_span: None, align: AlignUnknown, sign: None, alternate: false, zero_pad: false, debug_hex: None, precision: CountImplied, precision_span: None, width: CountImplied, width_span: None, ty: ":blah", ty_span: Some(7..12) } }
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed::<rustc_parse_format::Argument, rustc_parse_format::Argument>
---
---- tests::diagnostic_format_mod stdout ----

thread 'tests::diagnostic_format_mod' (51156) panicked at compiler/rustc_parse_format/src/tests.rs:586:5:
assertion `left == right` failed
  left: Argument { position: ArgumentNamed("thing"), position_span: 2..7, format: FormatSpec { fill: None, fill_span: None, align: AlignUnknown, sign: None, alternate: false, zero_pad: false, debug_hex: None, precision: CountImplied, precision_span: None, width: CountImplied, width_span: None, ty: "+", ty_span: Some(7..9) } }
 right: Argument { position: ArgumentNamed("thing"), position_span: 2..7, format: FormatSpec { fill: None, fill_span: None, align: AlignUnknown, sign: None, alternate: false, zero_pad: false, debug_hex: None, precision: CountImplied, precision_span: None, width: CountImplied, width_span: None, ty: ":+", ty_span: Some(7..9) } }
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed::<rustc_parse_format::Argument, rustc_parse_format::Argument>

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants