Raise errors on bad rustc_on_unimplemented format strings again

This commit is contained in:
mejrs 2025-03-29 13:48:14 +01:00
parent 9abaa9d4df
commit 10ec5cbe96
3 changed files with 41 additions and 13 deletions

View file

@ -20,7 +20,7 @@ trait BadAnnotation1
{}
#[rustc_on_unimplemented = "Unimplemented trait error on `{Self}` with params `<{A},{B},{C}>`"]
//~^ WARNING there is no parameter `C` on trait `BadAnnotation2`
//~^ ERROR cannot find parameter C on this trait
trait BadAnnotation2<A,B>
{}

View file

@ -11,22 +11,17 @@ LL | #[rustc_on_unimplemented = "message"]
LL | #[rustc_on_unimplemented(/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...")]
| ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
warning: there is no parameter `C` on trait `BadAnnotation2`
error[E0230]: cannot find parameter C on this trait
--> $DIR/bad-annotation.rs:22:90
|
LL | #[rustc_on_unimplemented = "Unimplemented trait error on `{Self}` with params `<{A},{B},{C}>`"]
| ^
|
= help: expect either a generic argument name or `{Self}` as format argument
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
warning: positional format arguments are not allowed here
error[E0231]: positional format arguments are not allowed here
--> $DIR/bad-annotation.rs:27:90
|
LL | #[rustc_on_unimplemented = "Unimplemented trait error on `{Self}` with params `<{A},{B},{}>`"]
| ^
|
= help: only named format arguments with the name of one of the generic types are allowed in this context
error[E0232]: this attribute must have a valid value
--> $DIR/bad-annotation.rs:32:26
@ -82,6 +77,7 @@ LL | #[rustc_on_unimplemented(on(desugared, on(desugared, message="x")), message
|
= note: eg `#[rustc_on_unimplemented(message="foo")]`
error: aborting due to 8 previous errors; 2 warnings emitted
error: aborting due to 10 previous errors
For more information about this error, try `rustc --explain E0232`.
Some errors have detailed explanations: E0230, E0231, E0232.
For more information about an error, try `rustc --explain E0230`.