Code change:
The following are some unexpected behaviors I see with the formatting strings in the attribute. I'm not sure that the attribute should actually be using std's format parsing, but if it is, the following seem like issues with the current implementation. Anything after the is ignored, and not included in the message output. Expectation: There should be a warning that the string is malformed. or These generate an error. However, my understanding of the attribute is that it tries to only generate warnings for things it doesn't understand. I would expect this to also generate a warning. This does not generate a warning or error. I would expect it to generate a warning that anything after the is ignored. This includes width, precision, debug formatting, etc. The error message generated with this is the type followed by a . I would expect this to generate a warning that the format arguments are not valid (similar to how works). : cc
I filled to hopefully address this.
Good catch! This should probably support a strict subset of formatting (only named arguments and no format options), and warn whenever the string is either not valid for or not in the supported subset. When it shows a warning, not sure what the behavior of the string should be -- maybe just take it as a literal without any interpolation?

Related discussion:
text: <ins> warning: unmatched `}` found --> $DIR/broken_format.rs:1:32 | LL | #[diagnostic::on_unimplemented(message = "{{Test } thing")] |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default warning: positional format arguments are not allowed here --> $DIR/broken_format.rs:6:32 | LL | #[diagnostic::on_unimplemented(message = "Test {}")] |                                ^^^^^^^^^^^^^^^^^^^ | = help: only named format arguments with the name of one of the generic types are allowed in this context warning: positional format arguments are not allowed here --> $DIR/broken_format.rs:11:32 | LL | #[diagnostic::on_unimplemented(message = "Test {1:}")] |                                ^^^^^^^^^^^^^^^^^^^^^ | = help: only named format arguments with the name of one of the generic types are allowed in this context warning: invalid format specifier --> $DIR/broken_format.rs:16:32 | LL | #[diagnostic::on_unimplemented(message = "Test {Self:123}")] |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: no format specifier are supported in this position warning: expected `'}'`, found `'!'` --> $DIR/broken_format.rs:21:32 | LL | #[diagnostic::on_unimplemented(message = "Test {Self:!}")] |                                ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unmatched `}` found --> $DIR/broken_format.rs:21:32 | LL | #[diagnostic::on_unimplemented(message = "Test {Self:!}")] |                                ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unmatched `}` found --> $DIR/broken_format.rs:1:32 | LL | #[diagnostic::on_unimplemented(message = "{{Test } thing")] |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: {{Test } thing --> $DIR/broken_format.rs:35:13 | LL |     check_1(()); |     ------- ^^ the trait `ImportantTrait1` is not implemented for `()` |     | |     required by a bound introduced by this call | help: this trait has no implementations, consider adding one --> $DIR/broken_format.rs:4:1 | LL | trait ImportantTrait1 {} | ^^^^^^^^^^^^^^^^^^^^^ note: required by a bound in `check_1` --> $DIR/broken_format.rs:28:20 | LL | fn check_1(_: impl ImportantTrait1) {} |                    ^^^^^^^^^^^^^^^ required by this bound in `check_1` warning: positional format arguments are not allowed here --> $DIR/broken_format.rs:6:32 | LL | #[diagnostic::on_unimplemented(message = "Test {}")] |                                ^^^^^^^^^^^^^^^^^^^ | = help: only named format arguments with the name of one of the generic types are allowed in this context = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: Test {} --> $DIR/broken_format.rs:37:13 | LL |     check_2(()); |     ------- ^^ the trait `ImportantTrait2` is not implemented for `()` |     | |     required by a bound introduced by this call | help: this trait has no implementations, consider adding one --> $DIR/broken_format.rs:9:1 | LL | trait ImportantTrait2 {} | ^^^^^^^^^^^^^^^^^^^^^ note: required by a bound in `check_2` --> $DIR/broken_format.rs:29:20 | LL | fn check_2(_: impl ImportantTrait2) {} |                    ^^^^^^^^^^^^^^^ required by this bound in `check_2` warning: positional format arguments are not allowed here --> $DIR/broken_format.rs:11:32 | LL | #[diagnostic::on_unimplemented(message = "Test {1:}")] |                                ^^^^^^^^^^^^^^^^^^^^^ | = help: only named format arguments with the name of one of the generic types are allowed in this context = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: Test {1} --> $DIR/broken_format.rs:39:13 | LL |     check_3(()); |     ------- ^^ the trait `ImportantTrait3` is not implemented for `()` |     | |     required by a bound introduced by this call | help: this trait has no implementations, consider adding one --> $DIR/broken_format.rs:14:1 | LL | trait ImportantTrait3 {} | ^^^^^^^^^^^^^^^^^^^^^ note: required by a bound in `check_3` --> $DIR/broken_format.rs:30:20 | LL | fn check_3(_: impl ImportantTrait3) {} |                    ^^^^^^^^^^^^^^^ required by this bound in `check_3` warning: invalid format specifier --> $DIR/broken_format.rs:16:32 | LL | #[diagnostic::on_unimplemented(message = "Test {Self:123}")] |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: no format specifier are supported in this position = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: Test () --> $DIR/broken_format.rs:41:13 | LL |     check_4(()); |     ------- ^^ the trait `ImportantTrait4` is not implemented for `()` |     | |     required by a bound introduced by this call | help: this trait has no implementations, consider adding one --> $DIR/broken_format.rs:19:1 | LL | trait ImportantTrait4 {} | ^^^^^^^^^^^^^^^^^^^^^ note: required by a bound in `check_4` --> $DIR/broken_format.rs:31:20 | LL | fn check_4(_: impl ImportantTrait4) {} |                    ^^^^^^^^^^^^^^^ required by this bound in `check_4` warning: expected `'}'`, found `'!'` --> $DIR/broken_format.rs:21:32 | LL | #[diagnostic::on_unimplemented(message = "Test {Self:!}")] |                                ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` warning: unmatched `}` found --> $DIR/broken_format.rs:21:32 | LL | #[diagnostic::on_unimplemented(message = "Test {Self:!}")] |                                ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: Test {Self:!} --> $DIR/broken_format.rs:43:13 | LL |     check_5(()); |     ------- ^^ the trait `ImportantTrait5` is not implemented for `()` |     | |     required by a bound introduced by this call | help: this trait has no implementations, consider adding one --> $DIR/broken_format.rs:26:1 | LL | trait ImportantTrait5 {} | ^^^^^^^^^^^^^^^^^^^^^ note: required by a bound in `check_5` --> $DIR/broken_format.rs:32:20 | LL | fn check_5(_: impl ImportantTrait5) {} |                    ^^^^^^^^^^^^^^^ required by this bound in `check_5` error: aborting due to 5 previous errors; 12 warnings emitted For more information about this error, try `rustc --explain E0277`. </ins>